Package javax.persistence

Examples of javax.persistence.TransactionRequiredException


   }

   public void verifyInTx()
   {
      Transaction tx = session.getTransaction();
      if (tx == null || !TxUtils.isActive(tx)) throw new TransactionRequiredException("EntityManager must be access within a transaction");
      if (!TxUtils.isActive(tx))
         throw new TransactionRequiredException("Transaction must be active to access EntityManager");
   }
View Full Code Here


  private javax.persistence.LockModeType jpaLockMode = javax.persistence.LockModeType.NONE;

  @SuppressWarnings({ "unchecked" })
  public TypedQuery<X> setLockMode(javax.persistence.LockModeType lockModeType) {
    if (! getEntityManager().isTransactionInProgress()) {
      throw new TransactionRequiredException( "no transaction is in progress" );
    }
    if ( ! canApplyLockModes() ) {
      throw new IllegalStateException( "Not a JPAQL/Criteria query" );
    }
    this.jpaLockMode = lockModeType;
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

  }

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

  public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    LockOptions lockOptions = null;
    try {
      if ( !isTransactionInProgress() ) {
        throw new TransactionRequiredException( "no transaction is in progress" );
      }
      if ( !contains( entity ) ) {
        throw new IllegalArgumentException( "entity not in the persistence context" );
      }
      getSession().buildLockRequest( ( lockOptions = getLockRequest( lockModeType, properties ) ) )
View Full Code Here

            if ( ignoreNotJoining ) {
              log.debug( "No JTA transaction found" );
              return;
            }
            else {
              throw new TransactionRequiredException(
                  "No active JTA transaction on joinTransaction call"
              );
            }
          }
          else if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.MARKED_FOR_JOINED ) {
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

    return Collections.unmodifiableMap( properties );
  }

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

  }

  public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    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

            if ( ignoreNotJoining ) {
              log.debug( "No JTA transaction found" );
              return;
            }
            else {
              throw new TransactionRequiredException(
                  "No active JTA transaction on joinTransaction call"
              );
            }
          }
          else if ( joinableCMTTransaction.getStatus() == JoinableCMTTransaction.JoinStatus.MARKED_FOR_JOINED ) {
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.