其他地方沒有遇到過這個問題,多線程中遇到了。 所以我加了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(); } }`新聞熱點
疑難解答