- delegator是与数据库交互的对象
GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");//过期,但有效
Delegator delegator = (GenericDelegator) request.getAttribute("delegator");//通过ofbiz的请求时有效
-
EntityComparisonOperator已经不可用了,用EntityOperator代替
- String module = TrustsgMallGeneralServices.class.getName();//用于 DEBUG 写方法名
-
GenericValue 通用实体对象(定义于entity_model.xml映射到数据库)
-
内置验证方法 org.ofbiz.base.util . UtilValidate
-
查数据,查出来的也是对象
Iterator iterator = UtilMisc.toIterator(delegator.findByCondition("TrustsgMallInfo", condition, UtilMisc.toList(field), null)); if (iterator.hasNext()) { GenericEntity ge = (GenericEntity) iterator.next(); String b = (String) ge.get(field); byte[] images = null; images = new EncoderBase64().decode(b); Debug.logInfo("showimage_logo get images length:" + images.length + ":", module); responseOutputStream.write(images); }else{ response.sendError(HttpServletResponse.SC_NOT_FOUND); }
-
condition = new EntityExpr("planetId", EntityOperator.EQUALS, "EARTH"); data = delegator.findByCondition("Planet", condition, null, null); 以上代码等价于 SELECT * FROM Planet WHERE planetId = "EARTH" 其中 EntityOperator 为ofbiz逻辑操作符号类。 EQUALS NOT_EQUAL LESS_THAN GREATER_THAN LESS_THAN_EQUAL_TO (less than or equal to) GREATER_THAN_EQUAL_TO IN NOT_IN BETWEEN LIKE NOT_LIKE NOT
-
Of biz 的 return 在 org.ofbiz.webapp.event.CoreEvents 中有 returnSuccess 等方法
- findByConditin 方法已经过期,现在可以用findList代替