use of javax.ejb.TransactionAttribute in project wildfly by wildfly.
the class SFSB4LC method updateEmployeeAddress.
/**
* Update Employee's address
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateEmployeeAddress(int id, String address, boolean fail) {
EntityManager em = emf.createEntityManager();
Employee emp = em.find(Employee.class, id);
emp.setAddress(address);
em.merge(emp);
em.flush();
if (fail) {
// Asked to fail...throwing exception for rollback
throw new RollbackException();
}
}
use of javax.ejb.TransactionAttribute in project wildfly by wildfly.
the class SFSBCMT method queryEmployeeNameRequireNewTX.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Employee queryEmployeeNameRequireNewTX(int id) {
Query q = em.createQuery("SELECT e FROM Employee e where id=?");
q.setParameter(1, new Integer(id));
return (Employee) q.getSingleResult();
}
use of javax.ejb.TransactionAttribute in project wildfly by wildfly.
the class TransactionalBean method intermittentCommitFailureTwoPhase.
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void intermittentCommitFailureTwoPhase() {
try {
Transaction txn = tm.getTransaction();
log.debugf("Invocation to #intermittentCommitFailure with transaction: %s", txn);
txn.enlistResource(new TestCommitFailureXAResource(transactionCheckerSingleton));
txn.enlistResource(new PersistentTestXAResource(transactionCheckerSingleton));
} catch (Exception e) {
throw new IllegalStateException("Cannot enlist one of the XAResources " + TestCommitFailureXAResource.class.getSimpleName() + " or " + PersistentTestXAResource.class.getSimpleName() + " to the transaction", e);
}
}
use of javax.ejb.TransactionAttribute in project wildfly by wildfly.
the class TransactionalBean method intermittentCommitFailure.
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void intermittentCommitFailure() {
try {
Transaction txn = tm.getTransaction();
log.debugf("Invocation to #intermittentCommitFailure with the transaction: %s", txn);
txn.enlistResource(new TestCommitFailureXAResource(transactionCheckerSingleton));
} catch (Exception e) {
throw new IllegalStateException("Cannot enlist single " + TestCommitFailureXAResource.class.getSimpleName() + " to the transaction", e);
}
}
use of javax.ejb.TransactionAttribute in project wildfly by wildfly.
the class TransactionalBean method enlistOnePersistentXAResource.
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void enlistOnePersistentXAResource() {
try {
log.debugf("Invocation to #enlistOnePersistentXAResource with transaction", tm.getTransaction());
tm.getTransaction().enlistResource(new PersistentTestXAResource(transactionCheckerSingleton));
} catch (Exception e) {
throw new IllegalStateException("Cannot enlist single " + PersistentTestXAResource.class.getSimpleName() + " to transaction", e);
}
}
Aggregations