Package org.drools.persistence

Examples of org.drools.persistence.TransactionManager


        String testName = getTestName();
       
        // Setup the JtaTransactionmanager
        Environment env = createEnvironment(context);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main" + testName);
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub" + testName);
        mainObject.setSubObject(subObject);
     
        // Commit the mainObject after "commiting" the subObject
        EntityManager em = emf.createEntityManager();
        try {
            // Begin the real trasnaction
            boolean txOwner = txm.begin();
     
            // Do the "sub" transaction
            // - the txm doesn't really commit,
            //   because we keep track of who's the tx owner.
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.commit(notTxOwner);
      
            // Finish the transaction off
            em.persist(subObject);
            txm.commit(txOwner);
        }
        catch( Throwable t ) {
            fail( "No exception should have been thrown: " + t.getMessage() );
        }
    }
View Full Code Here


  
    @Test
    public void basicTransactionRollbackTest() {
        Environment env = createEnvironment(context);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main");
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub");
        mainObject.setSubObject(subObject);
      
        EntityManager em = emf.createEntityManager();
        try {
            boolean txOwner = txm.begin();
           
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.rollback(notTxOwner);
       
            em.persist(subObject);
            txm.rollback(txOwner);
        }
        catch( Exception e ) {
            fail("There should not be an exception thrown here: " + e.getMessage());
        }
       
View Full Code Here

        String testName = getTestName();
       
        // Setup the JtaTransactionmanager
        Environment env = createEnvironment(context);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main" + testName);
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub" + testName);
        mainObject.setSubObject(subObject);
     
        // Commit the mainObject after "commiting" the subObject
        EntityManager em = emf.createEntityManager();
        try {
            // Begin the real trasnaction
            boolean txOwner = txm.begin();
     
            // Do the "sub" transaction
            // - the txm doesn't really commit,
            //   because we keep track of who's the tx owner.
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.commit(notTxOwner);
      
            // Finish the transaction off
            em.persist(subObject);
            txm.commit(txOwner);
        }
        catch( Throwable t ) {
            fail( "No exception should have been thrown: " + t.getMessage() );
        }
    }
View Full Code Here

  
    @Test
    public void basicTransactionRollbackTest() {
        Environment env = createEnvironment(context);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main");
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub");
        mainObject.setSubObject(subObject);
      
        EntityManager em = emf.createEntityManager();
        try {
            boolean txOwner = txm.begin();
           
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.rollback(notTxOwner);
       
            em.persist(subObject);
            txm.rollback(txOwner);
        }
        catch( Exception e ) {
            fail("There should not be an exception thrown here: " + e.getMessage());
        }
       
View Full Code Here

        String testName = getTestName();
       
        // Setup the JtaTransactionmanager
        Environment env = createEnvironment(context);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main" + testName);
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub" + testName);
        mainObject.setSubObject(subObject);
     
        // Commit the mainObject after "commiting" the subObject
        EntityManager em = emf.createEntityManager();
        try {
            // Begin the real trasnaction
            boolean txOwner = txm.begin();
     
            // Do the "sub" transaction
            // - the txm doesn't really commit,
            //   because we keep track of who's the tx owner.
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.commit(notTxOwner);
      
            // Finish the transaction off
            em.persist(subObject);
            txm.commit(txOwner);
        }
        catch( Throwable t ) {
            fail( "No exception should have been thrown: " + t.getMessage() );
        }
    }
View Full Code Here

  
    @Test
    public void basicTransactionRollbackTest() {
        Environment env = createEnvironment(context);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main");
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub");
        mainObject.setSubObject(subObject);
      
        EntityManager em = emf.createEntityManager();
        try {
            boolean txOwner = txm.begin();
           
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.rollback(notTxOwner);
       
            em.persist(subObject);
            txm.rollback(txOwner);
        }
        catch( Exception e ) {
            fail("There should not be an exception thrown here: " + e.getMessage());
        }
       
View Full Code Here

       
        // Setup the JtaTransactionmanager
        Environment env = createEnvironment(context);
        //TransactionManager txm = (TransactionManager) env.get( EnvironmentName.TRANSACTION_MANAGER );
        javax.transaction.TransactionManager tm = (javax.transaction.TransactionManager) env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main" + testName);
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub" + testName);
        mainObject.setSubObject(subObject);
     
        // Commit the mainObject after "commiting" the subObject
        Cache<Serializable, Object> cache = cm.getCache("jbpm-configured-cache");
        try {
            // Begin the real trasnaction
            boolean txOwner = txm.begin();
     
            // Do the "sub" transaction
            // - the txm doesn't really commit,
            //   because we keep track of who's the tx owner.
            boolean notTxOwner = txm.begin();
          Serializable s = generateId(mainObject);
          mainObject.setId(Long.valueOf(s.toString()));
            cache.put(s, mainObject);
            txm.commit(notTxOwner);
      
            // Finish the transaction off
          Serializable s2 = generateId(subObject);
          subObject.setId(Long.valueOf(s2.toString()));
            cache.put(s2, subObject);
            txm.commit(txOwner);
        }
        catch( Throwable t ) {
            fail( "No exception should have been thrown: " + t.getMessage() );
        }
    }
View Full Code Here

    @Test
    public void basicTransactionRollbackTest() {
        Environment env = createEnvironment(context);
        //TransactionManager txm = (TransactionManager) env.get( EnvironmentName.TRANSACTION_MANAGER );
        javax.transaction.TransactionManager tm = (javax.transaction.TransactionManager) env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main");
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub");
        mainObject.setSubObject(subObject);
      
        Cache<Serializable, Object> cache = cm.getCache("jbpm-configured-cache");
        try {
            boolean notTxOwner = txm.begin();
          Serializable s = generateId(mainObject);
          mainObject.setId(Long.valueOf(s.toString()));
            cache.put(s, mainObject);
            txm.rollback(notTxOwner);
        } catch ( Exception e ) {
          fail("There should not be an exception thrown here: " + e.getMessage());
        }
    }
View Full Code Here

        String testName = getTestName();
       
        // Setup the JtaTransactionmanager
        Environment env = initializeEnvironment(emf);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main" + testName);
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub" + testName);
        mainObject.setSubObject(subObject);
     
        // Commit the mainObject after "commiting" the subObject
        EntityManager em = emf.createEntityManager();
        try {
            // Begin the real trasnaction
            boolean txOwner = txm.begin();
     
            // Do the "sub" transaction
            // - the txm doesn't really commit,
            //   because we keep track of who's the tx owner.
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.commit(notTxOwner);
      
            // Finish the transaction off
            em.persist(subObject);
            txm.commit(txOwner);
        }
        catch( Throwable t ) {
            fail( "No exception should have been thrown: " + t.getMessage() );
        }
    }
View Full Code Here

  
    @Test
    public void basicTransactionRollbackTest() {
        Environment env = initializeEnvironment(emf);
        Object tm = env.get( EnvironmentName.TRANSACTION_MANAGER );
        TransactionManager txm = new JtaTransactionManager( env.get( EnvironmentName.TRANSACTION ),
                env.get( EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                tm );
          
        // Create linked transactionTestObjects
        TransactionTestObject mainObject = new TransactionTestObject();
        mainObject.setName("main");
        TransactionTestObject subObject = new TransactionTestObject();
        subObject.setName("sub");
        mainObject.setSubObject(subObject);
      
        EntityManager em = emf.createEntityManager();
        try {
            boolean txOwner = txm.begin();
           
            boolean notTxOwner = txm.begin();
            em.persist(mainObject);
            txm.rollback(notTxOwner);
       
            em.persist(subObject);
            txm.rollback(txOwner);
        }
        catch( Exception e ) {
            fail("There should not be an exception thrown here: " + e.getMessage());
        }
       
View Full Code Here

TOP

Related Classes of org.drools.persistence.TransactionManager

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.