Package javax.persistence

Examples of javax.persistence.TransactionRequiredException


     */
    private void assertTransactionNotRequired()
    {
        if (persistenceContextType == PersistenceContextType.TRANSACTION && !isTransactionActive())
        {
            throw new TransactionRequiredException(LOCALISER.msg("EM.TransactionRequired"));
        }
    }
View Full Code Here


     * @throws javax.persistence.PersistenceException if there the flush fails
   * @see javax.persistence.EntityManager#flush()
   */
  public void flush() {
    if (!tx.isActive()) {
      throw new TransactionRequiredException(
          "transaction required for the flush operation");
    }
    try {
      speedoFlush();
    } catch (PersistenceException e) {
View Full Code Here

        else {
          if (!enforce) {
            logger.debug("No local transaction to join");
          }
          else {
            throw new TransactionRequiredException("No local transaction to join");
          }
        }
      }
    }
View Full Code Here

        else {
          if (!enforce) {
            logger.debug("No local transaction to join");
          }
          else {
            throw new TransactionRequiredException("No local transaction to join");
          }
        }
      }
    }
View Full Code Here

    }

    private EntityManager getEntityManager(boolean activeRequired) {
        TransactionImpl transaction = (TransactionImpl) transactionManager.getTransaction();
        if (activeRequired && (transaction == null || transaction.getStatus() != Status.STATUS_ACTIVE)) {
            throw new TransactionRequiredException("No active transaction");
        }
        if (transaction == null) {
            return null;
        }
        EntityManagerWrapper entityManagerWrapper = (EntityManagerWrapper) transactionManager.getResource(persistenceUnit);
        if (entityManagerWrapper == null) {
            EntityManager entityManager = createEntityManager();
            entityManagerWrapper = new EntityManagerWrapperTxScoped(entityManager);
            transactionManager.putResource(persistenceUnit, entityManagerWrapper);
            try {
                transaction.registerSynchronization(entityManagerWrapper);
            } catch (javax.transaction.RollbackException e) {
                throw (TransactionRequiredException) new TransactionRequiredException("No active transaction").initCause(e);
            } catch (SystemException e) {
                throw (TransactionRequiredException) new TransactionRequiredException("No active transaction").initCause(e);
            }
        }
        return entityManagerWrapper.getEntityManager();
    }
View Full Code Here

     * required for some operations on the entity manager.
     * @throws TransactionRequiredException if non-extended and a transaction is not active
     */
    private void assertTransactionActive() throws TransactionRequiredException {
        if (!extended && !isTransactionActive()) {
            throw new TransactionRequiredException();
        }
    }
View Full Code Here

    }

    private EntityManager getEntityManager(boolean activeRequired) {
        TransactionImpl transaction = (TransactionImpl) transactionManager.getTransaction();
        if (activeRequired && (transaction == null || transaction.getStatus() != Status.STATUS_ACTIVE)) {
            throw new TransactionRequiredException("No active transaction");
        }
        if (transaction == null) {
            return null;
        }
        EntityManagerWrapper entityManagerWrapper = (EntityManagerWrapper) transaction.getEntityManager(persistenceUnit);
View Full Code Here

    public EntityTransaction getTransaction(){
        throw new IllegalStateException(TransactionException.entityTransactionWithJTANotAllowed().getMessage());
    }

    protected void throwCheckTransactionFailedException() {
        throw new TransactionRequiredException(TransactionException.externalTransactionNotActive().getMessage());
    }
View Full Code Here

            this.getTransaction().setRollbackOnly();
        }
    }
       
    protected void throwCheckTransactionFailedException() {
        throw new TransactionRequiredException(TransactionException.transactionNotActive().getMessage());
    }
View Full Code Here

    public EntityManagerImpl getEntityManager(){
        return entityManager;
    }

    public void registerUnitOfWorkWithTxn(UnitOfWorkImpl uow){
        throw new TransactionRequiredException(ExceptionLocalization.buildMessage("join_trans_called_on_entity_trans"));// no JTA transactions availab
    }
View Full Code Here

TOP

Related Classes of javax.persistence.TransactionRequiredException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.