/** * Close the current transaction's EntityManager. * Called after a transaction begin attempt failed. * @param txObject the current transaction */ protected void closeEntityManagerAfterFailedBegin(JpaTransactionObject txObject) { if (txObject.isNewEntityManagerHolder()) { EntityManager em = txObject.getEntityManagerHolder().getEntityManager(); try { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } catch (Throwable ex) { logger.debug("Could not rollback EntityManager after failed transaction begin", ex); } finally { EntityManagerFactoryUtils.closeEntityManager(em); } txObject.setEntityManagerHolder(null, false); } }
@Override protected void doRollback(DefaultTransactionStatus status) { JpaTransactionObject txObject = (JpaTransactionObject) status.getTransaction(); if (status.isDebug()) { logger.debug("Rolling back JPA transaction on EntityManager [" + txObject.getEntityManagerHolder().getEntityManager() + "]"); } try { EntityTransaction tx = txObject.getEntityManagerHolder().getEntityManager().getTransaction(); if (tx.isActive()) { tx.rollback(); } } catch (PersistenceException ex) { throw new TransactionSystemException("Could not roll back JPA transaction", ex); } finally { if (!txObject.isNewEntityManagerHolder()) { // Clear all pending inserts/updates/deletes in the EntityManager. // Necessary for pre-bound EntityManagers, to avoid inconsistent state. txObject.getEntityManagerHolder().getEntityManager().clear(); } } }
/** * Close the current transaction's EntityManager. * Called after a transaction begin attempt failed. * @param txObject the current transaction */ protected void closeEntityManagerAfterFailedBegin(JpaTransactionObject txObject) { if (txObject.isNewEntityManagerHolder()) { EntityManager em = txObject.getEntityManagerHolder().getEntityManager(); try { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } catch (Throwable ex) { logger.debug("Could not rollback EntityManager after failed transaction begin", ex); } finally { EntityManagerFactoryUtils.closeEntityManager(em); } txObject.setEntityManagerHolder(null, false); } }
if (txObject.isNewEntityManagerHolder()) { TransactionSynchronizationManager.unbindResourceIfPossible(obtainEntityManagerFactory());
new JpaTransactionDefinition(definition, timeoutToUse, txObject.isNewEntityManagerHolder())); txObject.setTransactionData(transactionData); if (txObject.isNewEntityManagerHolder()) { TransactionSynchronizationManager.bindResource( obtainEntityManagerFactory(), txObject.getEntityManagerHolder());
if (txObject.isNewEntityManagerHolder()) { TransactionSynchronizationManager.unbindResourceIfPossible(obtainEntityManagerFactory()); if (txObject.isNewEntityManagerHolder()) { EntityManager em = txObject.getEntityManagerHolder().getEntityManager(); if (logger.isDebugEnabled()) {
@Override protected void doRollback(DefaultTransactionStatus status) { JpaTransactionObject txObject = (JpaTransactionObject) status.getTransaction(); if (status.isDebug()) { logger.debug("Rolling back JPA transaction on EntityManager [" + txObject.getEntityManagerHolder().getEntityManager() + "]"); } try { EntityTransaction tx = txObject.getEntityManagerHolder().getEntityManager().getTransaction(); if (tx.isActive()) { tx.rollback(); } } catch (PersistenceException ex) { throw new TransactionSystemException("Could not roll back JPA transaction", ex); } finally { if (!txObject.isNewEntityManagerHolder()) { // Clear all pending inserts/updates/deletes in the EntityManager. // Necessary for pre-bound EntityManagers, to avoid inconsistent state. txObject.getEntityManagerHolder().getEntityManager().clear(); } } }
new JpaTransactionDefinition(definition, timeoutToUse, txObject.isNewEntityManagerHolder())); txObject.setTransactionData(transactionData); if (txObject.isNewEntityManagerHolder()) { TransactionSynchronizationManager.bindResource( obtainEntityManagerFactory(), txObject.getEntityManagerHolder());
if (txObject.isNewEntityManagerHolder()) { TransactionSynchronizationManager.unbindResourceIfPossible(obtainEntityManagerFactory()); if (txObject.isNewEntityManagerHolder()) { EntityManager em = txObject.getEntityManagerHolder().getEntityManager(); if (logger.isDebugEnabled()) {