当前位置:斗抓文库 > 专业资料 > IT/计算机 > 互联网 > 正文
免费下载此文档

Ofbiz 带条件检索用的方法

Ofbiz检索用的方法:

1、 通过delegator.find

例如:

List<EntityCondition>conds = FastList.newInstance();

conds.add(EntityCondition.makeCondition("merchantTypeId",

EntityOperator.IN, shopTypeList));

List<GenericValue>partyGroupList = delegator.findList("PartyGroup", EntityCondition.makeCondition(conds), null, UtilMisc.toList("partyId"), null, true);

2、 TemplatePageUtil.performFindList

例如:

Map<String, Object>inputField = FastMap.newInstance();

Map<String,Object>findResult = FastMap.newInstance();

inputField.put("partyId", partyIds);

inputField.put("partyId_op", "in");

//当不需要任何的条件的时候,往inputField中添加noConditionFind

//inputField.put("noConditionFind","Y")

findResult = TemplatePageUtil.performFindList(dispatcher, null, inputField, viewIndex, viewSize, "thruDate", "Coupon");

3、 通过调用服务

例如:

List<EntityCondition>conditionList = FastList.newInstance();

Map<String, Object>replResp = FastMap.newInstance();

LocalDispatcher dispatcher = (LocalDispatcher)

request.getAttribute("dispatcher");

conditionList.add(EntityCondition.makeCondition("partyId",

EntityOperator.EQUALS, storeInfo.get("partyId")));

conditionList.add(EntityCondition.makeCondition("statusId",

EntityOperator.NOT_EQUAL, "COUPON_DELETED"));

Map<String, Object>findContext = UtilMisc.toMap("entityName", "Coupon", "entityConditionList", conditionList);

replResp = dispatcher.runSync("performAdvanceFind", findContext); List<GenericValue>couponList = FastList.newInstance();

if (UtilValidate.isNotEmpty(replResp)) {

couponList = UtilGenerics.cast(replResp.get("listIt"));

}

4、 Ofbiz创建和更新数据

a) 创建一个对象

GenericValueentity= delegator.makeValue("EntityName");

entity.put("field", value);

entity.create();

b) 更新对象

GenericValueentity=delegator.findOne("entityName", false,

第1 / 2页

1 2 Next >

免费下载Word文档免费下载:Ofbiz 带条件检索用的方法 文档

(下载 共2页)

关键词:(带条件,条件检索,检索方法)

我要评论

返回顶部