/** * Returns the connection used by the hibernate session. * * @param doFlush * if true then the current actions are first flushed. * * @return the current database connection * @see #flush() */ public Connection getConnection(boolean doFlush) { if (doFlush) { // before returning a connection flush all other hibernate actions // to the database. flush(); } // NOTE: workaround for this issue: // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529 final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader()); final Connection connection = ((SessionImplementor) SessionHandler.getInstance().getSession()) .connection(); return connection; } finally { Thread.currentThread().setContextClassLoader(currentLoader); } }
/** * Note method sets user session information in the database and opens a connection for this. */ public Session openSession(Connection connection, Interceptor interceptor) { // NOTE: workaround for this issue: // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529 final Session session = delegateSessionFactory.openSession(connection, interceptor); final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader()); Connection conn = ((SessionImplementor) session).connection(); SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties() .getProperty("bbdd.rdbms")); SessionInfo.setDBSessionInfo(conn); } finally { Thread.currentThread().setContextClassLoader(currentLoader); } return session; }
/** * Note method sets user session information in the database and opens a connection for this. */ public Session openSession(Connection connection) { // NOTE: workaround for this issue: // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529 final Session session = delegateSessionFactory.openSession(connection); final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader()); Connection conn = ((SessionImplementor) session).connection(); SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties() .getProperty("bbdd.rdbms")); SessionInfo.setDBSessionInfo(conn); } finally { Thread.currentThread().setContextClassLoader(currentLoader); } return session; }
/** * Note method sets user session information in the database and opens a connection for this. */ public Session openSession(Interceptor interceptor) throws HibernateException { // NOTE: workaround for this issue: // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529 final Session session = delegateSessionFactory.openSession(interceptor); final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader()); Connection conn = ((SessionImplementor) session).connection(); SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties() .getProperty("bbdd.rdbms")); SessionInfo.setDBSessionInfo(conn); } finally { Thread.currentThread().setContextClassLoader(currentLoader); } return session; }
/** * Note method sets user session information in the database and opens a connection for this. */ public StatelessSession openStatelessSession(Connection connection) { // NOTE: workaround for this issue: // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529 final StatelessSession session = delegateSessionFactory.openStatelessSession(connection); final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader()); Connection conn = ((SessionImplementor) session).connection(); SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties() .getProperty("bbdd.rdbms")); SessionInfo.setDBSessionInfo(conn); } finally { Thread.currentThread().setContextClassLoader(currentLoader); } return session; }
/** * Note method sets user session information in the database and opens a connection for this. */ public StatelessSession openStatelessSession() { // NOTE: workaround for this issue: // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529 final StatelessSession session = delegateSessionFactory.openStatelessSession(); final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader()); Connection conn = ((SessionImplementor) session).connection(); SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties() .getProperty("bbdd.rdbms")); SessionInfo.setDBSessionInfo(conn); } finally { Thread.currentThread().setContextClassLoader(currentLoader); } return session; }