/** * Return true if a JTA transaction is in progress * and false in *every* other cases (including in a JDBC transaction). */ public static boolean isTransactionInProgress(SessionFactoryImplementor factory) { TransactionManager tm = factory.getTransactionManager(); try { return tm != null && isTransactionInProgress( tm.getTransaction() ); } catch (SystemException se) { throw new TransactionException( "could not obtain JTA Transaction", se ); } }
public Session getSession() { /** * Handle non transactional mode by requesting a temporary session to the session factory * This session, will aggressively use the AFTER_STATEMENT connection release mode to be * sure the conenctions are released. Be aware that the session will not be closed explicitly. */ Session s; SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; if ( !JTAHelper.isTransactionInProgress( sfi ) ) { s = sfi.openTemporarySession(); ( (SessionImplementor) s ).setAutoClear( true ); } else { s = sessionFactory.getCurrentSession(); } return s; }
public Session getSession() { /** * Handle non transactional mode by requesting a temporary session to the session factory * This session, will aggressively use the AFTER_STATEMENT connection release mode to be * sure the conenctions are released. Be aware that the session will not be closed explicitly. */ Session s; SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; if ( !JTAHelper.isTransactionInProgress( sfi ) ) { s = sfi.openTemporarySession(); ( (SessionImplementor) s ).setAutoClear( true ); } else { s = sessionFactory.getCurrentSession(); } return s; }
private boolean isTransactionInProgress(Transaction tx) throws SystemException { return JTAHelper.isTransactionInProgress(tx) && ! JTAHelper.isRollback( tx.getStatus() ); }
public boolean isTransactionInProgress( JDBCContext jdbcContext, Context transactionContext, Transaction transaction) { try { return JTAHelper.isTransactionInProgress( transactionContext.getFactory().getTransactionManager().getTransaction() ); } catch( SystemException se ) { throw new TransactionException( "Unable to check transaction status", se ); } }
public boolean isTransactionInProgress( JDBCContext jdbcContext, TransactionFactory.Context transactionContext ) { try { return status == JoinStatus.JOINED && isTransactionInProgress( transactionContext.getFactory().getTransactionManager().getTransaction() ); } catch (SystemException se) { throw new TransactionException( "Unable to check transaction status", se ); } }
private boolean isTransactionInProgress(Transaction tx) throws SystemException { return JTAHelper.isTransactionInProgress(tx) && ! JTAHelper.isRollback( tx.getStatus() ); }