public boolean isOpen() { //adjustFlushMode(); //don't adjust, can't be done on closed EM try { if ( open ) getSession().isOpen(); //to force enlistment in tx return open; } catch (HibernateException he) { throwPersistenceException( he ); return false; } }
public boolean isOpen() { //adjustFlushMode(); //don't adjust, can't be done on closed EM try { if ( open ) getSession().isOpen(); //to force enlistment in tx return open; } catch (HibernateException he) { throwPersistenceException( he ); return false; } }
public static Session getHibernateSession(EntityManager entityManager) { Session session; if (entityManager.getDelegate() instanceof EntityManagerImpl) { EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManager.getDelegate(); session = entityManagerImpl.getSession(); } else { session = (Session) entityManager.getDelegate(); } return session; }
if ( !discardOnClose && isTransactionInProgress() ) { getSession().getTransaction().registerSynchronization( new Synchronization() { public void beforeCompletion() {
public boolean isOpen() { //adjustFlushMode(); //don't adjust, can't be done on closed EM checkEntityManagerFactory(); try { if ( open ) { getSession().isOpen(); //to force enlistment in tx } return open; } catch (HibernateException he) { throwPersistenceException( he ); return false; } }
if ( !discardOnClose && isTransactionInProgress() ) { getSession().getTransaction().registerSynchronization( new Synchronization() { public void beforeCompletion() {
public void close() { checkEntityManagerFactory(); if ( !open ) { throw new IllegalStateException( "EntityManager is closed" ); } if ( !discardOnClose && isTransactionInProgress() ) { //delay the closing till the end of the enlisted transaction getSession().getTransaction().registerSynchronization(new Synchronization() { public void beforeCompletion() { // nothing to do } public void afterCompletion( int i ) { if (session != null) if (session.isOpen()) { LOG.debugf("Closing entity manager after transaction completion"); session.close(); } else LOG.entityManagerClosedBySomeoneElse(Environment.AUTO_CLOSE_SESSION); // TODO session == null should not happen } }); } else { //close right now if ( session != null ) { session.close(); } } open = false; }