赞
踩
其他地方没有遇到过这个问题,多线程中遇到了。
所以我加了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(); } }`
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。