@Override public Transaction accessTransaction() { return delegate.accessTransaction(); }
@Override public Transaction accessTransaction() { return delegate.accessTransaction(); }
@Override public Transaction accessTransaction() { return getSessionImplementor().accessTransaction(); }
private void rollbackTransaction(SessionImplementor session) throws Exception { try { if ( transactionManager != null ) { transactionManager.rollback(); } else { session.accessTransaction().rollback(); } } catch (Exception e) { log.errorRollingBackTransaction( e.getMessage(), e ); } }
private void rollbackTransaction(SessionImplementor session) throws Exception { try { if ( transactionManager != null ) { transactionManager.rollback(); } else { session.accessTransaction().rollback(); } } catch (Exception e) { log.errorRollingBackTransaction( e.getMessage(), e ); } }
@Override public void purge(String entity) { Class<?> clazz = getEntityClass( entity ); try ( Session session = hibernateSessionFactory.openSession() ) { FullTextSession fullTextSession = Search.getFullTextSession( session ); Transaction transaction = ( (SessionImplementor) session ).accessTransaction(); final boolean controlTransactions = ! transaction.isActive(); if ( controlTransactions ) { transaction.begin(); } try { fullTextSession.purgeAll( clazz ); } finally { if ( controlTransactions ) { transaction.commit(); } } } }
HibernateOrmSearchManager searchManager = getSearchManager( sessionImplementor ); if ( sessionImplementor.isTransactionInProgress() ) { final Transaction transactionIdentifier = sessionImplementor.accessTransaction(); TransientReference<Map<Transaction, PojoWorkPlan>> reference = (TransientReference<Map<Transaction, PojoWorkPlan>>) sessionImplementor.getProperties()
private void registerSynchronization(SessionImplementor sessionImplementor, Synchronization synchronization) { //use {Before|After}TransactionCompletionProcess instead of registerSynchronization because it does not //swallow transactions. /* * HSEARCH-540: the pre process must be both a BeforeTransactionCompletionProcess and a TX Synchronization. * * In a resource-local tx env, the beforeCommit phase is called after the flush, and prepares work queue. * Also, any exceptions that occur during that are propagated (if a Synchronization was used, the exceptions * would be eaten). * * In a JTA env, the before transaction completion is called before the flush, so not all changes are yet * written. However, Synchronization-s do propagate exceptions, so they can be safely used. */ final ActionQueue actionQueue = sessionImplementor.getActionQueue(); SynchronizationAdapter adapter = new SynchronizationAdapter( synchronization ); boolean isLocal = isLocalTransaction( sessionImplementor ); if ( isLocal ) { //if local tx never use Synchronization actionQueue.registerProcess( (BeforeTransactionCompletionProcess) adapter ); } else { //TODO could we remove the action queue registration in this case? actionQueue.registerProcess( (BeforeTransactionCompletionProcess) adapter ); sessionImplementor.accessTransaction().registerSynchronization( adapter ); } //executed in all environments actionQueue.registerProcess( (AfterTransactionCompletionProcess) adapter ); }