OFBiz使用小的注意点

  • 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代替

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值