private TransactionManager getTransactionManager() { SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory(); return sessionFactory.getTransactionManager(); }
private TransactionManager getTransactionManager() { return transactionContext.getFactory().getTransactionManager(); }
public javax.transaction.Transaction getTransaction() throws SystemException { return transactionContext.getFactory().getTransactionManager().getTransaction(); }
public TransactionManager getTransactionManager() { return getCurrentSessionFactoryImplementor().getTransactionManager(); }
/** * Try to retrieve the JTA TransactionManager from the given SessionFactory * and/or Session. Check the passed-in SessionFactory for implementing * SessionFactoryImplementor (the usual case), falling back to the * SessionFactory reference that the Session itself carries. * @param sessionFactory Hibernate SessionFactory * @param session Hibernate Session (can also be {@code null}) * @return the JTA TransactionManager, if any * @see javax.transaction.TransactionManager * @see SessionFactoryImplementor#getTransactionManager * @see Session#getSessionFactory * @see org.hibernate.impl.SessionFactoryImpl */ public static TransactionManager getJtaTransactionManager(SessionFactory sessionFactory, Session session) { SessionFactoryImplementor sessionFactoryImpl = null; if (sessionFactory instanceof SessionFactoryImplementor) { sessionFactoryImpl = ((SessionFactoryImplementor) sessionFactory); } else if (session != null) { SessionFactory internalFactory = session.getSessionFactory(); if (internalFactory instanceof SessionFactoryImplementor) { sessionFactoryImpl = (SessionFactoryImplementor) internalFactory; } } return (sessionFactoryImpl != null ? sessionFactoryImpl.getTransactionManager() : null); }
/** * 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 ); } }
protected void markAsRollback() { log.debug( "mark transaction for rollback"); if ( tx.isActive() ) { tx.setRollbackOnly(); } else { //no explicit use of the tx. boudaries methods if ( PersistenceUnitTransactionType.JTA == transactionType ) { TransactionManager transactionManager = ( (SessionFactoryImplementor) getRawSession().getSessionFactory() ).getTransactionManager(); if ( transactionManager == null ) { throw new PersistenceException( "Using a JTA persistence context wo setting hibernate.transaction.manager_lookup_class" ); } try { transactionManager.setRollbackOnly(); } catch (SystemException e) { throw new PersistenceException( "Unable to set the JTA transaction as RollbackOnly", e ); } } } }
private boolean isTransactionInProgress() { try { Transaction transaction = transactionContext.getFactory().getTransactionManager().getTransaction(); return isTransactionInProgress(transaction); } 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 ); } }
public boolean isTransactionInProgress() { TransactionManager tm = owner.getFactory().getTransactionManager(); try { return isHibernateTransactionActive || ( tm!=null && isJTATransactionInProgress( tm.getTransaction() ) ); } catch (SystemException se) { throw new TransactionException( "could not obtain JTA Transaction", se ); } }
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 ); } }
public boolean registerSynchronizationIfPossible() { if ( isTransactionCallbackRegistered ) return true; TransactionManager tm = owner.getFactory().getTransactionManager(); if ( tm == null ) { return false; } else { try { javax.transaction.Transaction tx = tm.getTransaction(); if ( isJTATransactionInProgress(tx) ) { tx.registerSynchronization( new CacheSynchronization(owner, this, tx, null) ); isTransactionCallbackRegistered = true; log.debug("successfully registered Synchronization"); return true; } else { log.debug("no active transaction, could not register Synchronization"); return false; } } catch (Exception e) { throw new TransactionException( "could not register synchronization with JTA TransactionManager", e ); } } }
private boolean isTransactionInProgress(Transaction tx) throws SystemException { return JTAHelper.isTransactionInProgress(tx) && ! JTAHelper.isRollback( tx.getStatus() ); }
public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException { TransactionManager transactionManager = session.getFactory().getTransactionManager(); Transaction surroundingTransaction = null; Connection connection = null;
/** * Ensures that all processing actually performed by the given work will * occur on a seperate transaction. * * @param work The work to be performed. * @param session The session from which this request is originating. * @throws HibernateException */ public static void doIsolatedWork(IsolatedWork work, SessionImplementor session) throws HibernateException { boolean isJta = session.getFactory().getTransactionManager() != null; if ( isJta ) { new JtaDelegate( session ).delegateWork( work, true ); } else { new JdbcDelegate( session ).delegateWork( work, true ); } }
public Session currentSession() throws HibernateException { TransactionManager transactionManager = factory.getTransactionManager(); if ( transactionManager == null ) { throw new HibernateException( "No TransactionManagerLookup specified" );
TransactionManager tm = owner.getFactory().getTransactionManager(); if ( tm == null ) {
protected void markAsRollback() { log.debug( "mark transaction for rollback"); if ( tx.isActive() ) { tx.setRollbackOnly(); } else { //no explicit use of the tx. boudaries methods if ( PersistenceUnitTransactionType.JTA == transactionType ) { TransactionManager transactionManager = ( (SessionFactoryImplementor) getRawSession().getSessionFactory() ).getTransactionManager(); if ( transactionManager == null ) { throw new PersistenceException( "Using a JTA persistence context wo setting hibernate.transaction.manager_lookup_class" ); } try { transactionManager.setRollbackOnly(); } catch (SystemException e) { throw new PersistenceException( "Unable to set the JTA transaction as RollbackOnly", e ); } } } }
TransactionManager tm = session.getFactory().getTransactionManager();