Fixed issue 33507: Incorrect Audit info was generated sometimes.
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Fri, 29 Jul 2016 11:18:31 +0200
changeset 30053 6bef7cf32538
parent 30052 1ab2615fd80d
child 30054 429081c6bccb
Fixed issue 33507: Incorrect Audit info was generated sometimes.

There was a problem when creating audit info data by some sqlc processes, sometimes wrong data was being created. The problem was that when the processes used the getTransactionConnection, the context information table was not correctly set. This table is set by the SessionInfo.setDBSessionInfo method.
To fix this, a call to this method has been added in the ConnectionProviderImpl.getTransactionConnection() and in the DalConnectionProvider.getTransactionConnection().
src-core/src/org/openbravo/database/ConnectionProviderImpl.java
src/org/openbravo/service/db/DalConnectionProvider.java
--- a/src-core/src/org/openbravo/database/ConnectionProviderImpl.java	Fri Jul 29 11:40:03 2016 +0200
+++ b/src-core/src/org/openbravo/database/ConnectionProviderImpl.java	Fri Jul 29 11:18:31 2016 +0200
@@ -264,7 +264,6 @@
     } else {
       conn = getCommonsDbcpPoolConnection(poolName);
     }
-
     return conn;
   }
 
@@ -341,6 +340,7 @@
     if (conn == null)
       throw new NoConnectionAvailableException("CouldnĀ“t get an available connection");
     conn.setAutoCommit(false);
+    SessionInfo.setDBSessionInfo(conn);
     return conn;
   }
 
--- a/src/org/openbravo/service/db/DalConnectionProvider.java	Fri Jul 29 11:40:03 2016 +0200
+++ b/src/org/openbravo/service/db/DalConnectionProvider.java	Fri Jul 29 11:18:31 2016 +0200
@@ -31,6 +31,7 @@
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.database.ConnectionProvider;
+import org.openbravo.database.SessionInfo;
 import org.openbravo.exception.NoConnectionAvailableException;
 
 /**
@@ -113,6 +114,7 @@
       throw new NoConnectionAvailableException("Couldn't get an available connection");
     }
     conn.setAutoCommit(false);
+    SessionInfo.setDBSessionInfo(conn);
     return conn;
   }