Package javax.persistence

Examples of javax.persistence.EntityManager.joinTransaction()


        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();
View Full Code Here


        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();
View Full Code Here

        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();
View Full Code Here

        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" );
View Full Code Here

             * Since the Entity Manager (EM) is not managed by the container the developer must explicitly tell the EM
             * to join the transaction. Compare this with ManagedComponent where the container automatically
             * enlists the EM with the transaction. The persistence context managed by the EM will then be scoped
             * to the JTA transaction which means that all entities will be detached when the transaction commits.
             */
            entityManager.joinTransaction();

            // make some transactional changes
            String result = updateKeyValueDatabase(entityManager, key, value);

            /*
 
View Full Code Here

        if (values != null) {
            transactionTemplate.execute(new TransactionCallback<Object>() {
                public Object doInTransaction(TransactionStatus status) {
                    if (getEndpoint().isJoinTransaction()) {
                        entityManager.joinTransaction();
                    }

                    if (values.getClass().isArray()) {
                        Object[] array = (Object[])values;
                        for (Object element : array) {
View Full Code Here

    int nbrOfBlogEntries = 350000;
    System.out.printf( "Warm up period done\nSaving %s Blog entries\n", nbrOfBlogEntries );
    long start = System.nanoTime();
    getTransactionManager().begin();
    em.joinTransaction();
    for ( int j = 0; j < nbrOfBlogEntries / 200; j++ ) {
      save200BlogEntriesAndCommit( em, nbrOfAuthors, true );
    }
    getTransactionManager().commit();
    System.out.printf( "Writing %s took %sms ie %sns/entry\n", nbrOfBlogEntries,
View Full Code Here

    System.out.printf( "Writing %s took %sms ie %sns/entry\n", nbrOfBlogEntries,
        ( System.nanoTime() - start ) / 1000000, ( System.nanoTime() - start ) / ( nbrOfBlogEntries ) );
    System.out.printf( "Collection ratio %s entries per collection\n", nbrOfBlogEntries / nbrOfAuthors );

    getTransactionManager().begin();
    em.joinTransaction();
    em = getFactory().createEntityManager();
    int nbr_of_reads = 100000;
    start = System.nanoTime();
    for ( int i = 0; i < nbr_of_reads; i++ ) {
      int primaryKey = rand.nextInt( nbrOfBlogEntries - 1 ) + 1; // start from 1
View Full Code Here

    if ( blogReads > 10000 ) {
      blogReads = 10000;
    }
    for ( int i = 0; i < blogReads; i++ ) {
      getTransactionManager().begin();
      em.joinTransaction();
      int primaryKey = randId( nbrOfAuthors );
      Blog blog = em.find( Blog.class, primaryKey );

      assertThat( blog.getTitle() ).isNotEmpty();
      assertThat( blog.getId() ).isEqualTo( primaryKey );
View Full Code Here

    int nbrOfBlogEntries = 350000;
    System.out.printf( "Warm up period done\nSaving %s Blog entries\n", nbrOfBlogEntries );
    long start = System.nanoTime();
    getTransactionManager().begin();
    em.joinTransaction();
    for ( int j = 0; j < nbrOfBlogEntries / 200; j++ ) {
      save200BlogEntriesAndCommit( em, nbrOfAuthors, false );
    }
    getTransactionManager().commit();
    System.out.printf( "Writing %s took %sms ie %sns/entry\n", nbrOfBlogEntries,
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.