Package javax.transaction

Examples of javax.transaction.UserTransaction.begin()


      try
      {
         InitialContext ctx = new InitialContext();
        
         t = (UserTransaction) ctx.lookup("UserTransaction");
         t.begin();
     
         EntityManager em = (EntityManager) Component.getInstance("entityManager", true);
        
         List<Auction> auctions = em.createQuery("from Auction").getResultList();
        
View Full Code Here


                throw new SynapseException("Require to begin a new transaction, " +
                        "but a transaction already exist");
            }

            try {
                tx.begin();
            } catch (Exception e) {
                handleException("Unable to begin a new transaction", e, synCtx);
            }

        } else if (action.equals(ACTION_USE_EXISTING_OR_NEW)) {
View Full Code Here

                handleException("Unable to query transaction status", e, synCtx);
            }

            try {
                if (status == Status.STATUS_NO_TRANSACTION) {
                    tx.begin();
                }
            } catch (Exception e) {
                handleException("Unable to begin a new transaction", e, synCtx);
            }
View Full Code Here

      UserTransaction userTransaction = newTransactionRequired ? transaction : null;
     
      if (newTransactionRequired)
      {
         log.debug("beginning transaction");
         userTransaction.begin();
      }
     
      try
      {
         T result = work();
View Full Code Here

        T out = null;
        EntityManager em = emf.createEntityManager();

        UserTransaction utx = getUtx();
        try {
            utx.begin();
            em.joinTransaction();
            out = call.call(em);
            utx.commit();
        } catch (Exception e) {
            utx.rollback();
View Full Code Here

                            em.getDelegate());
                }
                extendedEntityManager = em;

                UserTransaction userTransaction = ejbContext.getUserTransaction();
                userTransaction.begin();
                try {
                    em.getFlushMode();
                } finally {
                    userTransaction.commit();
                }
View Full Code Here

                // Note: this code also tests EBJ 3.0 Persistence spec 5.9.1 "UserTransaction is begun within the method, the
                // container associates the persistence context with the JTA transaction and calls EntityManager.joinTransaction."
                // If our the extended entity manager were not associted with the transaction, the non-extended entity manager would
                // not see it.
                UserTransaction userTransaction = ejbContext.getUserTransaction();
                userTransaction.begin();
                try {
                    Assert.assertSame("Extended non-extended entity manager to be same instance as extendend entity manager",
                            inheritedDelegate,
                            nonExtendedEm.getDelegate());
                } finally {
View Full Code Here

            httpServletResponse.getOutputStream().print("\nTest EJB app managed entity manager factory test OK: " + result);

            //test servlet access using spec dd refs
            TestSessionBean bean = new TestSessionBean();
            UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
            ut.begin();
            result = bean.testEntityManager();
            httpServletResponse.getOutputStream().print("\nTest servlet container managed entity manager test OK: " + result);
            result = bean.testEntityManagerFactory();
            httpServletResponse.getOutputStream().print("\nTest servlet app managed entity manager factory test OK: " + result);
            ut.commit();
View Full Code Here

        ks.newKieBuilder( kfs ).buildAll();

        KieBase kbase = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).getKieBase();

        UserTransaction ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        ut.begin();
        KieSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
        ut.commit();

        List<?> list = new ArrayList<Object>();
View Full Code Here

        List<?> list = new ArrayList<Object>();

        // insert and commit
        ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        ut.begin();
        ksession.setGlobal( "list",
                            list );
        ksession.insert( 1 );
        ksession.insert( 2 );
        ksession.fireAllRules();
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.