Package javax.transaction

Examples of javax.transaction.UserTransaction.begin()


        // The transaction attribute is never, so when the method is called with
        // a transactional context, an exception must be throw.
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            bean.insertTable03(DB_NAME, TABLE_NAME);
            fail("A method with transaction attribute never is not throwing an "
                    + "EJBException when it is called with transaction context");
        } catch (Exception e) {
            assertTrue(e instanceof EJBException,
View Full Code Here


        // the transaction attribute defined for all methods is required, so the
        // method must work with or without a client transaction.

        // the method is working with transaction...
        utx.begin();
        bean.insertTable03(DB_NAME, TABLE_NAME, 1);
        utx.commit();

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

        }

        // First transaction (committed)
        try {
            System.out.println("Start a first transaction");
            utx.begin();
            System.out.println("First request on the new bean");
            statefulBean.buy(FIRST_BUY_AMOUNT);
            System.out.println("Second request on the bean");
            statefulBean.buy(SECOND_BUY_AMOUNT);
            System.out.println("Commit the transaction");
View Full Code Here

        }

        // Start another transaction (rolled back)
        try {
            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) {
View Full Code Here

     * @throws NotSupportedException if the bean is already associated with a transaction.
     * @throws SystemException if an unexpected error occurs during the transaction.
     */
    public void openTransaction() throws NamingException, NotSupportedException, SystemException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
    }

    /**
     * Verifies if the bean has a bean-managed transaction. If the transaction
     * type is defined as container managed transaction, this method must throw
View Full Code Here

     *         relevant update was commited and others rolled back.
     */
    public void verifyBMT() throws IllegalStateException, SecurityException, HeuristicMixedException,
            HeuristicRollbackException, RollbackException, SystemException, NotSupportedException, NamingException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
        utx.commit();
    }
}
View Full Code Here

     * @throws Exception if an error occurs.
     */
    private boolean usesClientTransaction(final ItfTransAttributeDefinition bean) throws Exception {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            bean.insertTableCorrectMandatory(DB_NAME, TABLE_NAME);
        } finally {
            utx.rollback();
        }
        try {
View Full Code Here

        utx.begin();
        // creates a new transaction
        UserTransaction utxNested = TransactionHelper.getUserTransaction();

        // does a begin in other transaction
        utxNested.begin();
        // creates the table
        if (!bolOnlyCreateTrans) {
            tableManager.insertTable(TABLE);
        }
        // does the commit in the nested transaction
View Full Code Here

        //cleans the database to avoid errors.
        deleteTable(DB_NAME, TABLE_NAME);

        UserTransaction utx = TransactionHelper.getUserTransaction();
        try {
            utx.begin();
            beanMandatory.insertTableCorrect(DB_NAME, TABLE_NAME);
        } finally {
            utx.rollback();
        }
        try {
View Full Code Here

            TransactionException {
        // creates a new transaction
        UserTransaction utxNested = TransactionHelper.getUserTransaction();

        // does a begin in other transaction
        utxNested.begin();
        try {
            // creates the table
            if (!bolOnlyCreateTrans) {
                tableManager.insertTable(TABLE);
            }
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.