Fixes Issue 30414. Refreshes Transaction Object before accessing to it
authorDavid Miguelez <david.miguelez@openbravo.com>
Thu, 23 Jul 2015 17:05:01 +0200
changeset 27566 7ea341ccbf45
parent 27565 6273bf287bb7
child 27567 c1a6e9f89016
Fixes Issue 30414. Refreshes Transaction Object before accessing to it
again to fix a LazyInitializationException Hibernate exception.
Also removes unnecessary save, since flush is done afterwards.
src/org/openbravo/costing/CostingServer.java
--- a/src/org/openbravo/costing/CostingServer.java	Thu Jul 23 13:51:40 2015 +0200
+++ b/src/org/openbravo/costing/CostingServer.java	Thu Jul 23 17:05:01 2015 +0200
@@ -114,13 +114,14 @@
             .intValue(), RoundingMode.HALF_UP);
         log4j.debug("  *** Transaction cost amount: " + trxCost.toString());
         // Save calculated cost on M_Transaction.
+        OBDal.getInstance().flush();
+        transaction = OBDal.getInstance().get(MaterialTransaction.class, transaction.getId());
         transaction.setTransactionCost(trxCost);
         transaction.setCurrency(currency);
         transaction.setCostCalculated(true);
         transaction.setCostingStatus("CC");
         // insert on m_transaction_cost
         createTransactionCost();
-        OBDal.getInstance().save(transaction);
         OBDal.getInstance().flush();
 
         setNotPostedTransaction();