Package org.springframework.transaction

Examples of org.springframework.transaction.IllegalTransactionStateException


    boolean joinTx = false;
    boolean newSynch = false;

    if (existingTx) {
      if (pb == TransactionDefinition.PROPAGATION_NEVER) {
        throw new IllegalTransactionStateException(
            "Transaction propagation 'never' but existing transaction found");
      }
      if (pb == TransactionDefinition.PROPAGATION_NESTED) {
        throw new NestedTransactionNotSupportedException(
            "Transaction propagation 'nested' not supported for WebSphere UOW transactions");
      }
      if (pb == TransactionDefinition.PROPAGATION_SUPPORTS ||
          pb == TransactionDefinition.PROPAGATION_REQUIRED || pb == TransactionDefinition.PROPAGATION_MANDATORY) {
        joinTx = true;
        newSynch = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
      }
      else if (pb == TransactionDefinition.PROPAGATION_NOT_SUPPORTED) {
        uowType = UOWSynchronizationRegistry.UOW_TYPE_LOCAL_TRANSACTION;
        newSynch = (getTransactionSynchronization() == SYNCHRONIZATION_ALWAYS);
      }
      else {
        newSynch = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
      }
    }
    else {
      if (pb == TransactionDefinition.PROPAGATION_MANDATORY) {
        throw new IllegalTransactionStateException(
            "Transaction propagation 'mandatory' but no existing transaction found");
      }
      if (pb == TransactionDefinition.PROPAGATION_SUPPORTS ||
          pb == TransactionDefinition.PROPAGATION_NOT_SUPPORTED || pb == TransactionDefinition.PROPAGATION_NEVER) {
        uowType = UOWSynchronizationRegistry.UOW_TYPE_LOCAL_TRANSACTION;
View Full Code Here


  protected void doBegin(Object transaction, TransactionDefinition definition) {
    JdoTransactionObject txObject = (JdoTransactionObject) transaction;

    if (txObject.hasConnectionHolder() && !txObject.getConnectionHolder().isSynchronizedWithTransaction()) {
      throw new IllegalTransactionStateException(
          "Pre-bound JDBC Connection found! JdoTransactionManager does not support " +
          "running within DataSourceTransactionManager if told to manage the DataSource itself. " +
          "It is recommended to use a single JdoTransactionManager for all transactions " +
          "on a single DataSource, no matter whether JDO or JDBC access.");
    }
View Full Code Here

    JtaTransactionObject txObject = (JtaTransactionObject) transaction;
    try {
      doJtaResume(txObject, suspendedResources);
    }
    catch (InvalidTransactionException ex) {
      throw new IllegalTransactionStateException("Tried to resume invalid JTA transaction", ex);
    }
    catch (IllegalStateException ex) {
      throw new TransactionSystemException("Unexpected internal transaction state", ex);
    }
    catch (SystemException ex) {
View Full Code Here

  protected void doBegin(Object transaction, TransactionDefinition definition) {
    HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;

    if (txObject.hasConnectionHolder() && !txObject.getConnectionHolder().isSynchronizedWithTransaction()) {
      throw new IllegalTransactionStateException(
          "Pre-bound JDBC Connection found! HibernateTransactionManager does not support " +
          "running within DataSourceTransactionManager if told to manage the DataSource itself. " +
          "It is recommended to use a single HibernateTransactionManager for all transactions " +
          "on a single DataSource, no matter whether Hibernate or JDBC access.");
    }
View Full Code Here

  protected void doBegin(Object transaction, TransactionDefinition definition) {
    JpaTransactionObject txObject = (JpaTransactionObject) transaction;

    if (txObject.hasConnectionHolder() && !txObject.getConnectionHolder().isSynchronizedWithTransaction()) {
      throw new IllegalTransactionStateException(
          "Pre-bound JDBC Connection found! JpaTransactionManager does not support " +
          "running within DataSourceTransactionManager if told to manage the DataSource itself. " +
          "It is recommended to use a single JpaTransactionManager for all transactions " +
          "on a single DataSource, no matter whether JPA or JDBC access.");
    }
View Full Code Here

  protected void doBegin(Object transaction, TransactionDefinition definition) {
    HibernateTransactionObject txObject = (HibernateTransactionObject) transaction;

    if (txObject.hasConnectionHolder() && !txObject.getConnectionHolder().isSynchronizedWithTransaction()) {
      throw new IllegalTransactionStateException(
          "Pre-bound JDBC Connection found! HibernateTransactionManager does not support " +
          "running within DataSourceTransactionManager if told to manage the DataSource itself. " +
          "It is recommended to use a single HibernateTransactionManager for all transactions " +
          "on a single DataSource, no matter whether Hibernate or JDBC access.");
    }
View Full Code Here

      throw new InvalidTimeoutException("Invalid transaction timeout", definition.getTimeout());
    }

    // No existing transaction found -> check propagation behavior to find out how to proceed.
    if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_MANDATORY) {
      throw new IllegalTransactionStateException(
          "No existing transaction found for transaction marked with propagation 'mandatory'");
    }
    else if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRED ||
        definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRES_NEW ||
        definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NESTED) {
View Full Code Here

  private TransactionStatus handleExistingTransaction(
      TransactionDefinition definition, Object transaction, boolean debugEnabled)
      throws TransactionException {

    if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NEVER) {
      throw new IllegalTransactionStateException(
          "Existing transaction found for transaction marked with propagation 'never'");
    }

    if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NOT_SUPPORTED) {
      if (debugEnabled) {
View Full Code Here

   * @see #doCommit
   * @see #rollback
   */
  public final void commit(TransactionStatus status) throws TransactionException {
    if (status.isCompleted()) {
      throw new IllegalTransactionStateException(
          "Transaction is already completed - do not call commit or rollback more than once per transaction");
    }

    DefaultTransactionStatus defStatus = (DefaultTransactionStatus) status;
    if (defStatus.isLocalRollbackOnly()) {
View Full Code Here

   * @see #doRollback
   * @see #doSetRollbackOnly
   */
  public final void rollback(TransactionStatus status) throws TransactionException {
    if (status.isCompleted()) {
      throw new IllegalTransactionStateException(
          "Transaction is already completed - do not call commit or rollback more than once per transaction");
    }

    DefaultTransactionStatus defStatus = (DefaultTransactionStatus) status;
    processRollback(defStatus);
View Full Code Here

TOP

Related Classes of org.springframework.transaction.IllegalTransactionStateException

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.