details: /erp/devel/pi/rev/8e0cb4346d50
changeset: 6955:8e0cb4346d50
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Apr 08 09:47:11 2010 +0200
summary: fixes issue 12901: OBDal.getInstance().getConnection() does not
setup dateFormat correctly
diffstat:
src/org/openbravo/dal/service/OBDal.java | 17 ++++++++++++++++-
src/org/openbravo/service/db/DalConnectionProvider.java | 13 ++-----------
2 files changed, 18 insertions(+), 12 deletions(-)
diffs (74 lines):
diff -r 13d2fc73db5d -r 8e0cb4346d50 src/org/openbravo/dal/service/OBDal.java
--- a/src/org/openbravo/dal/service/OBDal.java Thu Apr 08 09:45:22 2010 +0200
+++ b/src/org/openbravo/dal/service/OBDal.java Thu Apr 08 09:47:11 2010 +0200
@@ -20,8 +20,10 @@
package org.openbravo.dal.service;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.apache.log4j.Logger;
import org.hibernate.Session;
@@ -34,6 +36,7 @@
import org.openbravo.base.model.UniqueConstraint;
import org.openbravo.base.provider.OBProvider;
import org.openbravo.base.provider.OBSingleton;
+import org.openbravo.base.session.OBPropertiesProvider;
import org.openbravo.base.structure.BaseOBObject;
import org.openbravo.base.structure.ClientEnabled;
import org.openbravo.base.structure.OrganizationEnabled;
@@ -90,7 +93,19 @@
final ClassLoader currentLoader =
Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader());
- return ((SessionImplementor)
SessionHandler.getInstance().getSession()).connection();
+ final Connection connection = ((SessionImplementor)
SessionHandler.getInstance().getSession())
+ .connection();
+
+ // set the date formatting
+ try {
+ final Properties props =
OBPropertiesProvider.getInstance().getOpenbravoProperties();
+ final String dbSessionConfig = props.getProperty("bbdd.sessionConfig");
+ PreparedStatement pstmt = connection.prepareStatement(dbSessionConfig);
+ pstmt.executeQuery();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ return connection;
} finally {
Thread.currentThread().setContextClassLoader(currentLoader);
}
diff -r 13d2fc73db5d -r 8e0cb4346d50
src/org/openbravo/service/db/DalConnectionProvider.java
--- a/src/org/openbravo/service/db/DalConnectionProvider.java Thu Apr 08
09:45:22 2010 +0200
+++ b/src/org/openbravo/service/db/DalConnectionProvider.java Thu Apr 08
09:47:11 2010 +0200
@@ -59,16 +59,6 @@
public Connection getConnection() throws NoConnectionAvailableException {
if (connection == null) {
connection = OBDal.getInstance().getConnection();
-
- // set the date formatting
- try {
- final String dbSessionConfig =
getProperties().getProperty("bbdd.sessionConfig");
- PreparedStatement pstmt = connection.prepareStatement(dbSessionConfig);
- pstmt.executeQuery();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
-
}
// always flush all remaining actions
@@ -87,8 +77,9 @@
public Connection getTransactionConnection() throws
NoConnectionAvailableException, SQLException {
Connection conn = getConnection();
- if (conn == null)
+ if (conn == null) {
throw new NoConnectionAvailableException("Couldn“t get an available
connection");
+ }
conn.setAutoCommit(false);
return conn;
}
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits