/** * An ENtityTransaction cannot be used at the same time as a JTA transaction * throw an exception */ public EntityTransaction getTransaction(){ throw new IllegalStateException(TransactionException.entityTransactionWithJTANotAllowed().getMessage()); }
/** * Determine whether the current transaction has been marked for rollback. * * @throws IllegalStateException * if isActive() is false. */ public boolean getRollbackOnly() { if (!isActive()) { throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } return this.rollbackOnly; }
/** * Mark the current transaction so that the only possible outcome of the * transaction is for the transaction to be rolled back. * * @throws IllegalStateException * if isActive() is false. */ public void setRollbackOnly() { if (!isActive()) { throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } this.rollbackOnly = true; }
protected void throwCheckTransactionFailedException() { throw new TransactionRequiredException(TransactionException.transactionNotActive().getMessage()); }
protected void throwCheckTransactionFailedException() { throw new TransactionRequiredException(TransactionException.externalTransactionNotActive().getMessage()); }
/** * Start the current transaction. This can only be invoked if * {@link #isActive()} returns <code>false</code>. * * @throws IllegalStateException * if isActive() is true. */ public void begin() { if (isActive()) { throw new IllegalStateException(TransactionException.transactionIsActive().getMessage()); } //bug307445 : Throw IllegalStateException if entityManager was closed this.wrapper.getEntityManager().verifyOpen(); // always extended this.wrapper.localUOW = this.wrapper.getEntityManager().getActivePersistenceContext(null); this.wrapper.localUOW.setShouldTerminateTransaction(false); this.active = true; }
throw new PersistenceException(TransactionException.errorBindingToExternalTransaction(e).getMessage(), e);
/** * Roll back the current transaction, discarding any changes that have * happened in this transaction. This can only be invoked if * {@link #isActive()} returns <code>true</code>. * * @throws IllegalStateException * if isActive() is false. */ public void rollback() { if (!isActive()) { throw new IllegalStateException(TransactionException.transactionNotActive().getMessage()); } // Make sure any open queries are closed. closeOpenQueries(); try { if (wrapper.getLocalUnitOfWork() != null) { this.wrapper.localUOW.setShouldTerminateTransaction(true); this.wrapper.localUOW.release(); this.wrapper.localUOW.getParent().release(); } } finally { this.active = false; this.rollbackOnly = false; this.wrapper.getEntityManager().removeExtendedPersistenceContext(); this.wrapper.setLocalUnitOfWork(null); } }
throw new IllegalStateException(TransactionException.transactionNotActive().getMessage());