Package javax.persistence

Examples of javax.persistence.TransactionRequiredException


     */
    private void assertIsActive()
    {
        if (!isTransactionActive())
        {
            throw new TransactionRequiredException(LOCALISER.msg("EM.TransactionRequired"));
        }
    }
View Full Code Here


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

        } catch (SystemException e) {
            throw new IllegalStateException("Cannot get current transaction", e);
        }

        if (currentTx == null) {
            throw new TransactionRequiredException("The operation needs to be executed within a transaction");
        }

    }
View Full Code Here

    throws TransactionRequiredException, SQLException
  {
    // XXX: also needs to check PersistenceContextType.TRANSACTION/EXTENDED.

    if (! (_isXA || isActiveTransaction()))
      throw new TransactionRequiredException(L.l("{0}() operation can only be executed in the scope of a transaction or with an extended persistence context.", operation));
  }
View Full Code Here

      return;
    }

    try {
      if (_ut.getStatus() == Status.STATUS_NO_TRANSACTION)
        throw new TransactionRequiredException(L.l("persist must be called within transaction."));
    } catch (SystemException e) {
      throw new RuntimeException(e);
    }

    em = createEntityManager();
View Full Code Here

      return;
    }

    try {
      if (_ut.getStatus() == Status.STATUS_NO_TRANSACTION)
        throw new TransactionRequiredException(L.l("remove must be called within transaction."));
    } catch (SystemException e) {
      throw new RuntimeException(e);
    }

    em = createEntityManager();
View Full Code Here

      return;
    }

    try {
      if (_ut.getStatus() == Status.STATUS_NO_TRANSACTION)
        throw new TransactionRequiredException(L.l("refresh must be called within transaction."));
    } catch (SystemException e) {
      throw new RuntimeException(e);
    }

    em = createEntityManager();
View Full Code Here

  }

  private void checkTransactionNeeded() {
    if ( persistenceContextType == PersistenceContextType.TRANSACTION && !isTransactionInProgress() ) {
      //no need to mark as rollback, no tx in progress
      throw new TransactionRequiredException(
          "no transaction is in progress for a TRANSACTION type persistence context"
      );
    }
  }
View Full Code Here

  @Override
  public void flush() {
    checkOpen();

    if ( !isTransactionInProgress() ) {
      throw new TransactionRequiredException( "no transaction is in progress" );
    }
    try {
      internalGetSession().flush();
    }
    catch ( RuntimeException e ) {
View Full Code Here

  public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    checkOpen();

    LockOptions lockOptions = null;
    if ( !isTransactionInProgress() ) {
      throw new TransactionRequiredException( "no transaction is in progress" );
    }

    try {
      if ( !contains( entity ) ) {
        throw new IllegalArgumentException( "entity not in the persistence context" );
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.