Package javax.transaction

Examples of javax.transaction.UserTransaction


      }
   }

   public void executeSql(String resource, Connection conn)
   {
     UserTransaction tx =null;
     try
     {
       tx =  (UserTransaction)new InitialContext().lookup("UserTransaction");
       tx.begin();
      
       log.debug("Execute SQL from resource: "+resource);

       URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
      
       log.debug("Execute SQL from resource URL: "+url);
      
       String sql = getStringFromStream(url.openStream());
       sql = sql.replaceAll("(?m)^--([^\n]+)?$", ""); // Remove all commented lines
       final String[] statements ;
       if (useEOL) {
           statements = sql.split("[\n;]");
       } else {
           statements = sql.split(";");
       }
       for (String statement : statements)
       {
         if ((statement == null) || ("".equals(statement.trim()))) {
         }
         else {
            Statement sqlStatement = conn.createStatement();
            try
            {
               sqlStatement.executeUpdate(statement);
            }
            finally
            {
               sqlStatement.close();
            }
         }
       }

       tx.commit();
     }
     catch (Throwable t)
     {
       if(tx!=null)
         try {
           tx.rollback();
         } catch (SystemException e) {
           //
         }
       throw new RuntimeException("Failed to create database", t);
     }
View Full Code Here


    }

  @SuppressWarnings("unchecked")
  public void clear() {
      try {
          UserTransaction ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
          ut.begin();
          List<ProcessInstanceLog> processInstances = getEntityManager()
        .createQuery("FROM ProcessInstanceLog").getResultList();
          for (ProcessInstanceLog processInstance: processInstances) {
            getEntityManager().remove(processInstance);
          }
        List<NodeInstanceLog> nodeInstances = getEntityManager()
        .createQuery("FROM NodeInstanceLog").getResultList();
        for (NodeInstanceLog nodeInstance: nodeInstances) {
          getEntityManager().remove(nodeInstance);
        }
        em.joinTransaction();
      ut.commit();
    } catch (SecurityException e) {
      e.printStackTrace();
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (RollbackException e) {
View Full Code Here

  private UserTransaction getUserTransaction()
      throws NamingException
  {
    InitialContext ctx = new InitialContext();
    UserTransaction tx = (UserTransaction)ctx.lookup("UserTransaction");
    return tx;
  }
View Full Code Here

   {
      try
      {
         if (configuration.isUseJTA())
         {
            UserTransaction tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
            if (tx.getStatus() == Status.STATUS_NO_TRANSACTION)
            {
               tx.begin();
            }
         }
         else
         {
            if (!idmService_.getIdentitySession().getTransaction().isActive())
View Full Code Here

   {
      try
      {
         if (configuration.isUseJTA())
         {
            UserTransaction tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
            tx.commit();
         }           
         else
         {
            idmService_.getIdentitySession().getTransaction().commit();
         }
View Full Code Here

               if (checkAndSetState())
               {
                  return;
               }
               long time = System.currentTimeMillis();
               UserTransaction tx = getTransaction();
               tx.begin();
               if (checkAndSetState())
               {
                  try
                  {
                     tx.rollback();
                  }
                  catch (Exception e)
                  {
                  }
                  return;
               }
               // the first worker would create a new node for the FQN
               // all the others would update the same node
               Fqn fqn = Fqn.fromString("/NODE/" + i);
               for (int m = 0; m < m_modificationsPerTx; m++)
               {
                  cache.put(fqn, m, i);
                  if (checkAndSetState())
                  {
                     try
                     {
                        tx.rollback();
                     }
                     catch (Exception e)
                     {
                     }
                     return;
                  }
               }
               tx.commit();
               if (checkAndSetState())
               {
                  return;
               }
               time = System.currentTimeMillis() - time;
View Full Code Here

        MyEntity myEntity = new MyEntity("This is a test Entity with annotation in fields");
        MyEntityMethods myEntityMethods = new MyEntityMethods("This is a test Entity with annotations in methods");
        MyEntityOnlyFields myEntityOnlyFields = new MyEntityOnlyFields("This is a test Entity with annotations in fields and without accesors methods");
        MyVariableSerializable myVariableSerializable = new MyVariableSerializable("This is a test SerializableObject");
        EntityManager em = emf.createEntityManager();
        UserTransaction utx = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        utx.begin();
        em.joinTransaction();
        em.persist(myEntity);
        em.persist(myEntityMethods);
        em.persist(myEntityOnlyFields);
        utx.commit();
        em.close();
        Environment env =  createEnvironment();
        KnowledgeBase kbase = createKnowledgeBase( "VariablePersistenceStrategyProcess.rf" );
        StatefulKnowledgeSession ksession = createSession( kbase, env );
View Full Code Here

        MyEntity myEntity = new MyEntity("This is a test Entity with annotation in fields");
        MyEntityMethods myEntityMethods = new MyEntityMethods("This is a test Entity with annotations in methods");
        MyEntityOnlyFields myEntityOnlyFields = new MyEntityOnlyFields("This is a test Entity with annotations in fields and without accesors methods");
        MyVariableSerializable myVariableSerializable = new MyVariableSerializable("This is a test SerializableObject");
        EntityManager em = emf.createEntityManager();
        UserTransaction utx = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        utx.begin();
        em.joinTransaction();
        em.persist(myEntity);
        em.persist(myEntityMethods);
        em.persist(myEntityOnlyFields);
        utx.commit();
        em.close();
        Environment env = createEnvironment();
        KnowledgeBase kbase = createKnowledgeBase( "VariablePersistenceStrategyProcessTypeChange.rf" );
        StatefulKnowledgeSession ksession = createSession( kbase, env );
       
View Full Code Here

        MyEntity myEntity = new MyEntity("This is a test Entity with annotation in fields");
        MyEntityMethods myEntityMethods = new MyEntityMethods("This is a test Entity with annotations in methods");
        MyEntityOnlyFields myEntityOnlyFields = new MyEntityOnlyFields("This is a test Entity with annotations in fields and without accesors methods");
        MyVariableSerializable myVariableSerializable = new MyVariableSerializable("This is a test SerializableObject");
        EntityManager em = emf.createEntityManager();
        UserTransaction utx = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        utx.begin();
        em.joinTransaction();
        em.persist(myEntity);
        em.persist(myEntityMethods);
        em.persist(myEntityOnlyFields);
        utx.commit();
        em.close();
        Environment env = createEnvironment();
        KnowledgeBase kbase = createKnowledgeBase( "VariablePersistenceStrategySubProcess.rf" );
        StatefulKnowledgeSession ksession = createSession( kbase, env );
      
View Full Code Here

    @Test
    public void testWorkItemWithVariablePersistence() throws Exception{
        MyEntity myEntity = new MyEntity("This is a test Entity");
        MyVariableSerializable myVariableSerializable = new MyVariableSerializable("This is a test SerializableObject");
        EntityManager em = emf.createEntityManager();
        UserTransaction utx = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        utx.begin();
       
        em.joinTransaction();
        em.persist(myEntity);
        utx.commit();
        em.close();
        Environment env = createEnvironment();
        KnowledgeBase kbase = createKnowledgeBase( "VPSProcessWithWorkItems.rf" );
        StatefulKnowledgeSession ksession = createSession( kbase , env);
       
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.