Author: jleroux
Date: Tue Mar 28 05:25:01 2017 New Revision: 1789045 URL: http://svn.apache.org/viewvc?rev=1789045&view=rev Log: Fixed: ERROR: Cannot do a find that returns an EntityListIterator with no transaction in place (OFBIZ-9286) While working on OFBIZ-8202 ("Use try-with-resources statement wherever it's possible") I missed that you must begin the transaction before the try-with-resources, this fixes it. Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1789045&r1=1789044&r2=1789045&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java Tue Mar 28 05:25:01 2017 @@ -5330,7 +5330,7 @@ public class OrderServices { Transaction trans = null; try { - // disable transaction procesing + // disable transaction processing trans = TransactionUtil.suspend(); // get the cart @@ -5560,10 +5560,14 @@ public class OrderServices { List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("automaticExtend", EntityOperator.EQUALS, "Y"), EntityCondition.makeCondition("orderId", EntityOperator.NOT_EQUAL, null), EntityCondition.makeCondition("productId", EntityOperator.NOT_EQUAL, null)); + try { + beganTransaction = TransactionUtil.begin(); + } catch (GenericTransactionException e1) { + Debug.logError(e1, "[Delegator] Could not begin transaction: " + e1.toString(), module); + } try (EntityListIterator eli = EntityQuery.use(delegator).from("Subscription").where(exprs).queryIterator()) { - beganTransaction = TransactionUtil.begin(); if (eli != null) { GenericValue subscription; while (((subscription = eli.next()) != null)) { Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=1789045&r1=1789044&r2=1789045&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java Tue Mar 28 05:25:01 2017 @@ -35,6 +35,7 @@ import org.apache.ofbiz.base.util.UtilVa import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; +import org.apache.ofbiz.entity.transaction.GenericTransactionException; import org.apache.ofbiz.entity.transaction.TransactionUtil; import org.apache.ofbiz.entity.util.EntityListIterator; import org.apache.ofbiz.entity.util.EntityQuery; @@ -129,9 +130,13 @@ public class ShoppingListServices { .from("ShoppingList") .where("shoppingListTypeId", "SLT_AUTO_REODR", "isActive", "Y") .orderBy("-lastOrderedDate"); - - try (EntityListIterator eli = eq.queryIterator()) { + try { beganTransaction = TransactionUtil.begin(); + } catch (GenericTransactionException e1) { + Debug.logError(e1, "[Delegator] Could not begin transaction: " + e1.toString(), module); + } + + try (EntityListIterator eli = eq.queryIterator()) { if (eli != null) { GenericValue shoppingList; while (((shoppingList = eli.next()) != null)) { |
Free forum by Nabble | Edit this page |