当前位置:   article > 正文

EntityListIterator 必须在tranction 中_findlistiteratorbycondition

findlistiteratorbycondition

其他地方没有遇到过这个问题,多线程中遇到了。
所以我加了tranction ,这里有疑惑:为什么其他地方不加可以,在单开一个县城就必须包含在事务中
可能的 原因,主线程的其他地方开启了事物。

代码`EntityListIterator eli = null;
boolean beganTransaction = false;
try {
beganTransaction=TransactionUtil.begin();
EntityFindOptions findOptions = new EntityFindOptions();
findOptions.setDistinct(true);
eli = delegator.findListIteratorByCondition(dynamicView,EntityCondition.makeCondition(con, EntityOperator.AND), null, fieldToSelect, null, findOptions);
List orderList = eli.getCompleteList();
if (orderList != null) {
result = orderList;
}

    } catch (GenericEntityException e1) {

        // TODO Auto-generated catch block
        e1.printStackTrace();
    }finally{
        if(eli!=null){
            try {
                eli.close();
            } catch (GenericEntityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        try {
            TransactionUtil.commit(beganTransaction);
        } catch (GenericTransactionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }`
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/856332
推荐阅读
相关标签
  

闽ICP备14008679号