Package javax.transaction

Examples of javax.transaction.UserTransaction.commit()


            batchBean.createBatch(batchName);
        } catch (Exception e) {
            userTransaction.rollback();
            throw e;
        }
        userTransaction.commit();

        // add step1 to the batch
        final String step1 = "Simple step1";
        userTransaction.begin();
        try {
View Full Code Here


            batchBean.step1(batchName, step1);
        } catch (Exception e) {
            userTransaction.rollback();
            throw e;
        }
        userTransaction.commit();

        String successFullyCompletedSteps = step1;

        // fetch the batch and make sure it contains the right state
        final Batch batchAfterStep1 = batchRetriever.fetchBatch(batchName);
View Full Code Here

        final Batch batchAfterStep2BeforeCommit = batchRetriever.fetchBatch(batchName);
        Assert.assertNotNull("Batch after step2, before commit was null", batchAfterStep2BeforeCommit);
        Assert.assertEquals("Unexpected steps in batch, after step2 before commit", successFullyCompletedSteps, batchAfterStep2BeforeCommit.getStepNames());

        // now commit
        userTransaction.commit();
        // keep track of successfully completely steps
        successFullyCompletedSteps = successFullyCompletedSteps + "," + step2;

        // now retrieve and check the batch
        final Batch batchAfterStep2 = batchRetriever.fetchBatch(batchName);
View Full Code Here

            tx.registerSynchronization(txObj);

            txObj.setMessage("Donate $1.000.000");
            assertNull("Uncommited message null", txObj.getMessage());

            userTx.commit();
        } catch (Exception ex) {
            userTx.setRollbackOnly();
            throw ex;
        }
View Full Code Here

            em.joinTransaction();
            MyEntity entity = em.find(MyEntity.class, id);
            entity.setName(name.toUpperCase());

            String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
            tx1.commit();

            return propagatedName.equals(name.toUpperCase());
        } catch (Exception e) {
            try {
                sessionContext.getUserTransaction().rollback();
View Full Code Here

            em.joinTransaction();
            MyEntity entity = em.find(MyEntity.class, id);
            entity.setName(name.toUpperCase());

            String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
            tx1.commit();

            return propagatedName.equals(name.toUpperCase());
        } catch (Exception e) {
            try {
                sessionContext.getUserTransaction().rollback();
View Full Code Here

            em.joinTransaction();
            MyEntity entity = em.find(MyEntity.class, id);
            entity.setName(name.toUpperCase());

            boolean result = cmtBean.execute(id, name.toLowerCase());
            tx1.commit();

            return result;
        } catch (Exception e) {
            try {
                sessionContext.getUserTransaction().rollback();
View Full Code Here

        UserTransaction tx1 = sessionContext.getUserTransaction();
        try {
            tx1.begin();
            em.joinTransaction();
            em.persist(emp);
            tx1.commit();
        }
        catch (Exception e) {
            throw new RuntimeException("couldn't start tx" , e);
        }
View Full Code Here

        UserTransaction tx1 = sessionContext.getUserTransaction();
        try {
            tx1.begin();
            em.joinTransaction();
            em.persist(emp);
            tx1.commit();
        }
        catch (Exception e) {
            throw new RuntimeException("couldn't start tx" , e);
        }
View Full Code Here

      q.executeUpdate();
     
      q = managedEm.createQuery("SELECT Count(c) from Car c");
      assertEquals(0l, q.getSingleResult());
    } finally {
      ut.commit();
    }
   
    Query countQuery = managedEm.createQuery("SELECT Count(c) from Car c");
    assertEquals(0l, countQuery.getSingleResult());
   
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.