Package javax.transaction

Examples of javax.transaction.UserTransaction


        store.setId(store.hashCode());
        store.setName(name);
        entityManager.persist(store);

        // flush only if there is a transaction
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        if (utx != null) {
            if (utx.getStatus() == Status.STATUS_ACTIVE) {
                entityManager.flush();
            }
        }

        if (entityManager.find(EBStore.class, Integer.valueOf(store.hashCode())) == null){
View Full Code Here


     * @throws NamingException if a problem to get the transaction occurs.
     * @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();
    }
View Full Code Here

     * @throws HeuristicMixedException if a heuristic decision was made and some
     *         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

     * @param bean the bean that is verified.
     * @return true if the bean uses the same transaction that the client, false otherwise.
     * @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 {
            slsbDatabaseManager.verifyTable(DB_NAME, TABLE_NAME);
            return false;
        } catch (SQLException e) {
View Full Code Here

            NotSupportedException, HeuristicRollbackException, RollbackException, HeuristicMixedException,
            TransactionException {
        // does a begin in the bean transaction
        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
        utxNested.commit();
        // does the commit in the bean transaction
        utx.commit();

    }
View Full Code Here

     */
    public void testMandatory() throws Exception {
        //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 {
            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

     */
    public void insertTableWithNewTransaction() throws SQLException, NamingException, SystemException,
            NotSupportedException, HeuristicRollbackException, RollbackException, HeuristicMixedException,
            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);
            }
            // 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

        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
        //gets the initialcontext
        Context initialContext = new InitialContext();
        //gets the usertransaction
        UserTransaction utx = (UserTransaction) initialContext.lookup("javax.transaction.UserTransaction");
        return utx;
    }
View Full Code Here

     */
    public static UserTransaction getUserTransaction() throws NamingException {
        //gets the initialcontext
        Context initialContext = new InitialContext();
        //gets the usertransaction
        UserTransaction utx = (UserTransaction) initialContext.lookup("java:comp/UserTransaction");
        return utx;
    }
View Full Code Here

     * @throws Exception if a problem occurs
     */
    public static void checkJNDI() throws Exception{
        Context ctx = new InitialContext();

        UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/env/UserTransaction");
        if (utx == null){
            throw new Exception("UserTransaction reference obtained using JNDI API is null.");
        }
    }
View Full Code Here

TOP

Related Classes of javax.transaction.UserTransaction

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.