Package javax.transaction

Examples of javax.transaction.UserTransaction.rollback()


                TableManager tableManager = new TableManager(dbName);
                tableManager.insertTable(TABLE);
            }
            utx.commit();
        } catch (Exception e) {
            utx.rollback();
            throw new TransactionException("Error during commit.", e);
        }

    }
View Full Code Here


        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            slsbCMTInheritance.dummyMethod1();
        } finally {
            utx.rollback();
        }
    }

    /**
     * Verifies if the transaction attribute defined in a method overrides the
View Full Code Here

        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            slsbCMTInheritance.dummyMethod4();
        } finally {
            utx.rollback();
        }
    }
}
View Full Code Here

     */
    public static void cleanTransaction() throws Exception {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            if (transactionIsActive()) {
                utx.rollback();
            }
        } catch (Exception e) {
            throw new Exception("Cannot clean the transaction. The test cannot be started", e);
        }
    }
View Full Code Here

        } catch (Exception e) {
            assertTrue(e instanceof EJBException,
                    "A method with transaction attribute never is not throwing an "
                    + "EJBException when it is called with transaction context");
        } finally {
            utx.rollback();
        }

        // cleans the db to avoid error
        deleteTable(DB_NAME, TABLE_NAME);
View Full Code Here

            System.out.println("Start a second transaction");
            utx.begin();
            System.out.println("Buy " + THIRD_BUY_AMOUNT + " amount.");
            statefulBean.buy(THIRD_BUY_AMOUNT);
            System.out.println("Rollback the transaction");
            utx.rollback();
        } catch (Exception e) {
            System.err.println("exception during 2nd Tx: " + e);
            System.exit(2);
        }
View Full Code Here

        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            bean.insertTableCorrectMandatory(DB_NAME, TABLE_NAME);
        } finally {
            utx.rollback();
        }
        try {
            slsbDatabaseManager.verifyTable(DB_NAME, TABLE_NAME);
            return false;
        } catch (SQLException e) {
View Full Code Here

        UserTransaction utx = TransactionHelper.getUserTransaction();
        try {
            utx.begin();
            beanMandatory.insertTableCorrect(DB_NAME, TABLE_NAME);
        } finally {
            utx.rollback();
        }
        try {
            slsbDatabaseManager.verifyTable(DB_NAME, TABLE_NAME);
            fail("The deployment descriptor did not override the "
                   + "annotation. The bean did not use the client transaction in mandatory mode.");
View Full Code Here

            }
            // does the commit in the nested transaction
            // does the commit in the nested transaction
            utxNested.commit();
        } catch (Exception e) {
            utxNested.rollback();
            if (this.getTransactionStatus() != Status.STATUS_NO_TRANSACTION) {
                utx.rollback();
            }
            throw new TransactionException("Error during commit.", e);
        }
View Full Code Here

      bean.setCounter(100);
      userTx.begin();
         bean.incCounter();
         bean.incCounter();
      userTx.rollback();
      counter = bean.getCounter();
      assertTrue("counter == 100", counter == 100);

      bean.remove();
   }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.