@Test public void testGetSession() throws SQLException { assertNotNull("DB connection should not be null", connection); assertTrue("A transaction should be open by default", connection.getTransaction().isActive()); connection.getTransaction().rollback(); assertFalse("Transaction should be closed after rollback", connection.getTransaction().isActive()); Session currentSession = connection.getSession(); assertTrue("New transaction should be open after getSession() call", connection.getTransaction().isActive()); assertEquals("Multiple calls to getSession should return same Session", currentSession, connection.getSession()); }
@Override public Session getSession() throws SQLException { if (!isTransActionAlive()) { sessionFactory.getCurrentSession().beginTransaction(); configureDatabaseMode(); } return sessionFactory.getCurrentSession(); }
HibernateDBConnection implements DBConnection<Session> { @Override public Session getSession() throws SQLException { if (!isTransActionAlive()) { sessionFactory.getCurrentSession().beginTransaction(); configureDatabaseMode(); } return sessionFactory.getCurrentSession(); } }
HibernateDBConnection implements DBConnection<Session> { @Override public Session getSession() throws SQLException { if (!isTransActionAlive()) { sessionFactory.getCurrentSession().beginTransaction(); configureDatabaseMode(); } return sessionFactory.getCurrentSession(); }  }
HibernateDBConnection implements DBConnection<Session> { @Override public Session getSession() throws SQLException { if (!isTransActionAlive()) { sessionFactory.getCurrentSession().beginTransaction(); configureDatabaseMode(); } return sessionFactory.getCurrentSession(); }  @Override Session getSession(); @Override boolean isTransActionAlive(); @Override boolean isSessionAlive(); @Override void rollback(); @Override void closeDBConnection(); @Override void commit(); @Override synchronized void shutdown(); @Override String getType(); @Override DataSource getDataSource(); @Override DatabaseConfigVO getDatabaseConfig(); @Override long getCacheSize(); @Override @SuppressWarnings("unchecked") E reloadEntity(final E entity); @Override void setConnectionMode(final boolean batchOptimized, final boolean readOnlyOptimized); @Override boolean isOptimizedForBatchProcessing(); @Override void uncacheEntity(E entity); }
HibernateDBConnection implements DBConnection<Session> { @Override public Session getSession() throws SQLException { if (!isTransActionAlive()) { sessionFactory.getCurrentSession().beginTransaction(); configureDatabaseMode(); } return sessionFactory.getCurrentSession(); }  @Override Session getSession(); @Override boolean isTransActionAlive(); @Override boolean isSessionAlive(); @Override void rollback(); @Override void closeDBConnection(); @Override void commit(); @Override synchronized void shutdown(); @Override String getType(); @Override DataSource getDataSource(); @Override DatabaseConfigVO getDatabaseConfig(); @Override long getCacheSize(); @Override @SuppressWarnings("unchecked") E reloadEntity(final E entity); @Override void setConnectionMode(final boolean batchOptimized, final boolean readOnlyOptimized); @Override boolean isOptimizedForBatchProcessing(); @Override void uncacheEntity(E entity);  }