javax.transaction.HeuristicRollbackException Java Examples

The following examples show how to use javax.transaction.HeuristicRollbackException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PeopleTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void createUsers() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException, NotSupportedException
    {
        txn = transactionService.getUserTransaction();
        txn.begin();
        for (UserInfo user : userInfos)
        {
            String username = user.getUserName();
            NodeRef nodeRef = personService.getPersonOrNull(username);
            boolean create = nodeRef == null;
            if (create)
            {
                PropertyMap testUser = new PropertyMap();
                testUser.put(ContentModel.PROP_USERNAME, username);
                testUser.put(ContentModel.PROP_FIRSTNAME, user.getFirstName());
                testUser.put(ContentModel.PROP_LASTNAME, user.getLastName());
                testUser.put(ContentModel.PROP_EMAIL, user.getUserName() + "@acme.test");
                testUser.put(ContentModel.PROP_PASSWORD, "password");

                nodeRef = personService.createPerson(testUser);
            }
            userNodeRefs.add(nodeRef);
//            System.out.println((create ? "create" : "existing")+" user " + username + " nodeRef=" + nodeRef);
        }
        txn.commit();
    }
 
Example #2
Source File: CDIDelegatingTransactionManager.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Overrides {@link TransactionManager#commit()} to
 * additionally {@linkplain Event#fire(Object) fire} an {@link Object}
 * representing the {@linkplain BeforeDestroyed before destruction} and
 * the {@linkplain Destroyed destruction}
 * of the {@linkplain TransactionScoped transaction scope}.
 *
 * @see TransactionManager#commit()
 */
@Override
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException,
        IllegalStateException, SystemException {
    if (this.transactionScopeBeforeDestroyed != null) {
        this.transactionScopeBeforeDestroyed.fire(this.getTransaction());
    }

    try {
        delegate.commit();
    } finally {
        if (this.transactionScopeDestroyed != null) {
            this.transactionScopeDestroyed.fire(this.toString());
        }
    }
}
 
Example #3
Source File: JPAResource.java    From boost with Eclipse Public License 1.0 6 votes vote down vote up
public void createThing(StringBuilder builder)
        throws NamingException, NotSupportedException, SystemException, IllegalStateException, SecurityException,
        HeuristicMixedException, HeuristicRollbackException, RollbackException {
    Context ctx = new InitialContext();
    // Before getting an EntityManager, start a global transaction
    UserTransaction tran = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    tran.begin();

    // Now get the EntityManager from JNDI
    EntityManager em = (EntityManager) ctx.lookup(JNDI_NAME);
    builder.append("Creating a brand new Thing with " + em.getDelegate().getClass()).append(newline);

    // Create a Thing object and persist it to the database
    Thing thing = new Thing();
    em.persist(thing);

    // Commit the transaction
    tran.commit();
    int id = thing.getId();
    builder.append("Created Thing " + id + ":  " + thing).append(newline);
}
 
Example #4
Source File: JPAResource.java    From boost with Eclipse Public License 1.0 6 votes vote down vote up
public void createThing(StringBuilder builder)
        throws NamingException, NotSupportedException, SystemException, IllegalStateException, SecurityException,
        HeuristicMixedException, HeuristicRollbackException, RollbackException {
    Context ctx = new InitialContext();
    // Before getting an EntityManager, start a global transaction
    UserTransaction tran = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    tran.begin();

    // Now get the EntityManager from JNDI
    EntityManager em = (EntityManager) ctx.lookup(JNDI_NAME);
    builder.append("Creating a brand new Thing with " + em.getDelegate().getClass()).append(newline);

    // Create a Thing object and persist it to the database
    Thing thing = new Thing();
    em.persist(thing);

    // Commit the transaction
    tran.commit();
    int id = thing.getId();
    builder.append("Created Thing " + id + ":  " + thing).append(newline);
}
 
Example #5
Source File: JPAResource.java    From boost with Eclipse Public License 1.0 6 votes vote down vote up
public void createThing(StringBuilder builder)
        throws NamingException, NotSupportedException, SystemException, IllegalStateException, SecurityException,
        HeuristicMixedException, HeuristicRollbackException, RollbackException {
    Context ctx = new InitialContext();
    // Before getting an EntityManager, start a global transaction
    UserTransaction tran = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    tran.begin();

    // Now get the EntityManager from JNDI
    EntityManager em = (EntityManager) ctx.lookup(JNDI_NAME);
    builder.append("Creating a brand new Thing with " + em.getDelegate().getClass()).append(newline);

    // Create a Thing object and persist it to the database
    Thing thing = new Thing();
    em.persist(thing);

    // Commit the transaction
    tran.commit();
    int id = thing.getId();
    builder.append("Created Thing " + id + ":  " + thing).append(newline);
}
 
Example #6
Source File: DefaultTransaction.java    From piranha with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Commit the transaction.
 *
 * @throws RollbackException when a rollback error occurs.
 * @throws HeuristicMixedException when the heuristics were mixed.
 * @throws HeuristicRollbackException when a rollback error occurs.
 * @throws SecurityException when a security error occurs.
 * @throws IllegalStateException when the transaction is not active.
 * @throws SystemException when a serious error occurs.
 */
@Override
public synchronized void commit() throws RollbackException, HeuristicMixedException,
        HeuristicRollbackException, SecurityException,
        IllegalStateException, SystemException {
    handleBeforeCompletion();
    try {
        switch (status) {
            case Status.STATUS_COMMITTED:
                break;
            case Status.STATUS_MARKED_ROLLBACK: {
                rollback();
                throw new HeuristicRollbackException();
            }
            case Status.STATUS_ROLLEDBACK: {
                throw new RollbackException();
            }
            default: {
                status = Status.STATUS_COMMITTED;
            }
        }
    } finally {
        handleAfterCompletion();
    }
}
 
Example #7
Source File: TransactionManagerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   Transaction tx = registry.getTransaction();

   if (tx == null)
      throw new SystemException();

   if (tx.getStatus() == Status.STATUS_ROLLEDBACK ||
       tx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
      throw new RollbackException();

   registry.commitTransaction();
}
 
Example #8
Source File: ManagedTransaction.java    From requery with Apache License 2.0 6 votes vote down vote up
@Override
public void commit() {
    if (initiatedTransaction) {
        try {
            transactionListener.beforeCommit(entities.types());
            getUserTransaction().commit();
            transactionListener.afterCommit(entities.types());
        } catch (RollbackException | SystemException | HeuristicMixedException |
            HeuristicRollbackException e) {
            throw new TransactionException(e);
        }
    }
    try {
        entities.clear();
    } finally {
        close();
    }
}
 
Example #9
Source File: JPAResource.java    From microprofile-sandbox with Apache License 2.0 6 votes vote down vote up
public void createThing(StringBuilder builder)
        throws NamingException, NotSupportedException, SystemException, IllegalStateException, SecurityException,
        HeuristicMixedException, HeuristicRollbackException, RollbackException {
    Context ctx = new InitialContext();
    // Before getting an EntityManager, start a global transaction
    UserTransaction tran = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    tran.begin();

    // Now get the EntityManager from JNDI
    EntityManager em = (EntityManager) ctx.lookup(JNDI_NAME);
    builder.append("Creating a brand new Thing with " + em.getDelegate().getClass()).append(newline);

    // Create a Thing object and persist it to the database
    Thing thing = new Thing();
    em.persist(thing);

    // Commit the transaction
    tran.commit();
    int id = thing.getId();
    builder.append("Created Thing " + id + ":  " + thing).append(newline);
}
 
Example #10
Source File: TransactionImpl.java    From ByteJTA with GNU Lesser General Public License v3.0 6 votes vote down vote up
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
		SecurityException, IllegalStateException, CommitRequiredException, SystemException {

	if (this.transactionStatus == Status.STATUS_ACTIVE) {
		this.fireCommit();
	} else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) {
		this.fireRollback();
		throw new HeuristicRollbackException();
	} else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ {
		throw new RollbackException();
	} else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ {
		logger.debug("Current transaction has already been committed.");
	} else {
		throw new IllegalStateException();
	}

}
 
Example #11
Source File: TransactionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   if (status == Status.STATUS_UNKNOWN)
      throw new IllegalStateException("Status unknown");

   if (status == Status.STATUS_MARKED_ROLLBACK)
      throw new IllegalStateException("Status marked rollback");

   finish(true);
}
 
Example #12
Source File: UserTransactionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void commit() throws RollbackException,
                            HeuristicMixedException,
                            HeuristicRollbackException,
                            SecurityException,
                            IllegalStateException,
                            SystemException
{
   Transaction tx = registry.getTransaction();

   if (tx == null)
      throw new SystemException();

   if (tx.getStatus() == Status.STATUS_ROLLING_BACK ||
       tx.getStatus() == Status.STATUS_ROLLEDBACK ||
       tx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
      throw new RollbackException();

   registry.commitTransaction();
}
 
Example #13
Source File: LazyUserTransaction.java    From lastaflute with Apache License 2.0 6 votes vote down vote up
@Override
protected void doCommit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException,
        SecurityException, SystemException {
    if (canTerminateTransactionReally()) {
        if (logger.isDebugEnabled()) {
            logger.debug("#lazyTx ...Committing the transaction: {}", buildLazyTxExp());
        }
        superDoCommit();
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("#lazyTx *No commit because of non-begun transaction: {}", buildLazyTxExp());
        }
    }
    if (canLazyTransaction()) {
        decrementHierarchyLevel();
        resumeForcedlyBegunLazyTransactionIfNeeds(); // when nested transaction
    }
    if (isLazyTransactionReadyLazy() && isHerarchyLevelZero()) { // lazy transaction is supported only for root
        returnToReadyLazy();
    }
}
 
Example #14
Source File: CmrMappingTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void validateOneToManyRelationship() throws NotSupportedException, SystemException, Exception, HeuristicMixedException, HeuristicRollbackException, RollbackException {
    try {
        final OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);


        // verify one side has a set containing the many bean
        final Set set = inverseLocal.getManyOwningSide();
        Assert.assertEquals(1, set.size());
        final ManyOwningSideLocal owningLocal = (ManyOwningSideLocal) set.iterator().next();
        Assert.assertEquals(compoundPK_20_10, owningLocal.getPrimaryKey());

        // verify the many bean has a back reference to the one
        final OneInverseSideLocal oneInverseSide = owningLocal.getOneInverseSide();
        Assert.assertNotNull(oneInverseSide);
        Assert.assertEquals(compoundPK_20_10_field1, oneInverseSide.getPrimaryKey());

        completeTransaction();
    } finally {
        completeTransaction();
    }
}
 
Example #15
Source File: DumbTransactionFactory.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
public UserTransaction getUserTransaction() {
    return new UserTransaction() {
        public void begin() throws NotSupportedException, SystemException {
        }

        public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
        }

        public int getStatus() throws SystemException {
            return TransactionUtil.STATUS_NO_TRANSACTION;
        }

        public void rollback() throws IllegalStateException, SecurityException, SystemException {
        }

        public void setRollbackOnly() throws IllegalStateException, SystemException {
        }

        public void setTransactionTimeout(int i) throws SystemException {
        }
    };
}
 
Example #16
Source File: CompensableTransactionImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 6 votes vote down vote up
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
		SecurityException, IllegalStateException, SystemException {

	if (this.transactionStatus == Status.STATUS_ACTIVE) {
		this.fireCommit();
	} else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) {
		this.fireRollback();
		throw new HeuristicRollbackException();
	} else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ {
		throw new RollbackException();
	} else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ {
		logger.debug("Current transaction has already been committed.");
	} else {
		throw new IllegalStateException();
	}

}
 
Example #17
Source File: CompensableManagerImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void invokeTransactionCommitIfNotLocalTransaction(CompensableTransaction compensable) throws RollbackException,
		HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {

	Transaction transaction = compensable.getTransaction();
	org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();
	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();

	TransactionXid transactionXid = transactionContext.getXid();
	try {
		transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS);

		TransactionContext compensableContext = compensable.getTransactionContext();
		logger.error("{}> jta-transaction in try-phase cannot be xa transaction.",
				ByteUtils.byteArrayToString(compensableContext.getXid().getGlobalTransactionId()));

		transactionCoordinator.rollback(transactionXid);
		throw new HeuristicRollbackException();
	} catch (XAException xaEx) {
		transactionCoordinator.forgetQuietly(transactionXid);
		SystemException sysEx = new SystemException(xaEx.errorCode);
		sysEx.initCause(xaEx);
		throw sysEx;
	}
}
 
Example #18
Source File: CompensableManagerImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void invokeCompensableCommitIfNotLocalTransaction(CompensableTransaction compensable)
		throws HeuristicRollbackException, SystemException {

	TransactionParticipant transactionCoordinator = this.beanFactory.getTransactionNativeParticipant();
	Transaction transaction = compensable.getTransaction();
	org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext();

	TransactionXid transactionXid = transactionContext.getXid();
	try {
		transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS);
		TransactionContext compensableContext = compensable.getTransactionContext();
		logger.error("{}| jta-transaction in compensating-phase cannot be xa transaction.",
				ByteUtils.byteArrayToString(compensableContext.getXid().getGlobalTransactionId()));

		transactionCoordinator.rollback(transactionXid);
		throw new HeuristicRollbackException();
	} catch (XAException xaex) {
		transactionCoordinator.forgetQuietly(transactionXid);
		SystemException sysEx = new SystemException(xaex.errorCode);
		sysEx.initCause(xaex);
		throw sysEx;
	}
}
 
Example #19
Source File: CompensableManagerImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void fireCompensableCommit(CompensableTransaction transaction) throws RollbackException, HeuristicMixedException,
		HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
	try {
		this.associateThread(transaction);

		transaction.commit();
	} finally {
		this.desociateThread();
	}
}
 
Example #20
Source File: TransactionManagerImpl.java    From clearpool with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void commit() throws RollbackException, HeuristicMixedException,
    HeuristicRollbackException, SecurityException, SystemException {
  Transaction action = TX_HOLDER.get();
  if (action == null) {
    throw new IllegalStateException("this is no transaction held");
  }
  try {
    action.commit();
  } finally {
    TX_HOLDER.set(null);
  }
}
 
Example #21
Source File: DefaultTransactionManager.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Commit a transaction.
 *
 * @throws RollbackException when a rollback error occurs.
 * @throws HeuristicMixedException when heuristics are being mixed.
 * @throws HeuristicRollbackException when a rollback error occurs.
 * @throws SecurityException when a security error occurs.
 * @throws IllegalStateException when the transaction is not active.
 * @throws SystemException when a serious error occurs.
 */
@Override
public void commit() throws RollbackException, HeuristicMixedException,
        HeuristicRollbackException, SecurityException,
        IllegalStateException, SystemException {
    Transaction transaction = getTransaction();
    try {
        transaction.commit();
    } finally {
        Thread currentThread = Thread.currentThread();
        threadTransactionMap.remove(currentThread);
    }
}
 
Example #22
Source File: TemporaryBuildsCleanerTest.java    From pnc with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDeleteTemporaryBuildWithArtifactsTest() throws SystemException, NotSupportedException,
        HeuristicRollbackException, HeuristicMixedException, RollbackException, ValidationException {
    // given
    Artifact artifact1 = storeAndGetArtifact();
    Artifact artifact2 = storeAndGetArtifact();
    Artifact artifact3 = storeAndGetArtifact();
    Artifact artifact4 = storeAndGetArtifact();

    Set<Artifact> dependencies = new HashSet<>();
    dependencies.add(artifact3);
    dependencies.add(artifact4);

    BuildRecord tempBr = initBuildRecordBuilder().temporaryBuild(true).build();

    tempBr.setDependencies(dependencies);
    BuildRecord savedTempBr = buildRecordRepository.save(tempBr);
    artifact1.setBuildRecord(savedTempBr);
    artifactRepository.save(artifact1);
    artifact2.setBuildRecord(savedTempBr);
    artifactRepository.save(artifact2);

    List<BuildRecord> givenBuilds = buildRecordRepository.queryAll();
    int numberOfBuilds = givenBuilds.size();

    // when
    temporaryBuildsCleaner.deleteTemporaryBuild(tempBr.getId(), "");

    // then
    assertEquals(numberOfBuilds - 1, buildRecordRepository.queryAll().size());
    assertNull(buildRecordRepository.queryById(tempBr.getId()));
    assertNull(artifactRepository.queryById(artifact1.getId()));
    assertNull(artifactRepository.queryById(artifact2.getId()));
    assertNotNull(artifactRepository.queryById(artifact3.getId()));
    assertNotNull(artifactRepository.queryById(artifact4.getId()));
}
 
Example #23
Source File: UserCompensableImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void compensableRecoveryCommit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
		SecurityException, IllegalStateException, SystemException {
	CompensableManager compensableManager = this.beanFactory.getCompensableManager();
	CompensableTransaction compensable = compensableManager.getCompensableTransactionQuietly();
	if (compensable == null) {
		throw new IllegalStateException();
	}

	TransactionContext transactionContext = compensable.getTransactionContext();
	if (transactionContext.isCoordinator() == false) {
		throw new IllegalStateException();
	}
	this.invokeCompensableCommit(compensable);
}
 
Example #24
Source File: JtaTransaction.java    From cdi with Apache License 2.0 5 votes vote down vote up
private void attemptCommit() {
    logger.debug("Committing JTA transaction if required and possible.");

    if (userTransaction != null) {
        try {
            if (owned) {
                if (userTransaction.getStatus() == Status.STATUS_ACTIVE) {
                    logger.debug("Committing BMT transaction.");
                    userTransaction.commit();
                } else {
                    logger.warn("Cannot commit BMT transaction, current transaction status is {}.",
                            statusToString(userTransaction.getStatus()));
                }
            } else {
                logger.debug("Cannot commit non-owned BMT transaction.");
            }
        } catch (SystemException | RollbackException
                | HeuristicMixedException | HeuristicRollbackException
                | SecurityException | IllegalStateException ex) {
            logger.warn("Had trouble trying to commit BMT transaction.", ex);
        }
    } else {
        if (registry != null) {
            logger.debug("Not allowed to commit CMT transaction, the current transaction status is {}.",
                    statusToString(registry.getTransactionStatus()));
        } else {
            logger.warn("No JTA APIs available in this context. No commit done.");
        }
    }
}
 
Example #25
Source File: QueriesPeopleApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void createTestUsers() throws IllegalArgumentException, SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException
{
    AuthenticationUtil.setFullyAuthenticatedUser(user1);
    for (String[] properties: userProperties)
    {
        int l = properties.length;
        if (l > 0)
        {
            PersonInfo personInfo = newPersonInfo(properties);
            String originalUsername = personInfo.getUsername();
            String id = createUser(personInfo, networkOne);
            Person person = new Person(
                           id,
                           null, // Not set to originalUsername, as the returned JSON does not set it
                           true, // enabled
                personInfo.getFirstName(),
                personInfo.getLastName(),
                personInfo.getCompany(),
                personInfo.getSkype(),
                personInfo.getLocation(),
                personInfo.getTel(),
                personInfo.getMob(),
                personInfo.getInstantmsg(),
                personInfo.getGoogle(),
                           null); // description
            testUsernames.add(originalUsername);
            testPersons.add(person);

            // The following call to personService.getPerson(id) returns a NodeRef like:
            //    workspace://SpacesStore/9db76769-96de-4de4-bdb4-a127130af362
            // We call tenantService.getName(nodeRef) to get a fully qualified NodeRef as Solr returns this.
            // They look like:
            //    workspace://@org.alfresco.rest.api.tests.queriespeopleapitest@SpacesStore/9db76769-96de-4de4-bdb4-a127130af362
            NodeRef nodeRef = personService.getPerson(id);
            nodeRef = tenantService.getName(nodeRef);
            testPersonNodeRefs.add(nodeRef);
        }
    }
}
 
Example #26
Source File: CompensableTransactionImpl.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
public synchronized void participantCommit(boolean opc) throws RollbackException, HeuristicMixedException,
		HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException {

	// Recover if transaction is recovered from tx-log.
	this.recoverIfNecessary();

	if (this.transactionStatus != Status.STATUS_COMMITTED) {
		this.fireCommit(); // TODO
	}

}
 
Example #27
Source File: JMS2AMQTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void serialize() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException {
    final JMSContext c = SerializationUtils.deserialize(SerializationUtils.serialize(Serializable.class.cast(context)));
    ut.begin();
    session.ok();
    ut.commit();
}
 
Example #28
Source File: RequiredInterceptor.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void commit(final State state) {
    if (state.old != state.current) {
        try {
            state.current.commit();
        } catch (final HeuristicMixedException | HeuristicRollbackException | RollbackException | SystemException e) {
            throw new TransactionalException(e.getMessage(), e);
        }
    }
}
 
Example #29
Source File: MultiThreadedTx.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SecurityException, SystemException
{
    boolean performAfterCompletion = false;
    try
    {
        synchronized (this)
        {
            this.status.get().prePrepareCheck(this);
            bestEffortEndResources();
            this.status.get().beforeCompletion(this);
            // at this point, our status is either ACTIVE or MARKED_ROLLBACK
            this.status.get().chooseStateForPrepare(this);
            // possible statuses are now PREPARING, COMMITTED, COMMITTING, ROLLING_BACK
            this.status.get().prepare(this);
            // possible statuses are now COMMITTED, COMMITTING, ROLLING_BACK
            performAfterCompletion = true;
            this.status.get().commitOrPossiblyRollback(this);
        }
    }
    finally
    {
        if (performAfterCompletion)
        {
            // possible statuses are now COMMITTED, ROLLED_BACK
            this.status.get().afterCompletion(this);
            multiThreadedTm.removeTransactionFromThread(this);
        }
    }
    this.status.get().postCommitCheck(this);
}
 
Example #30
Source File: MdwTransactionManager.java    From mdw with Apache License 2.0 5 votes vote down vote up
@Override
public void commit() throws HeuristicMixedException,
        HeuristicRollbackException, IllegalStateException,
        RollbackException, SecurityException, SystemException {
    transaction.commit();
    transaction = null;
}