Package javax.persistence

Examples of javax.persistence.EntityManager.joinTransaction()


        em.close();
    }
   
    public void testPostRemoveNotInvokedAfterRollback() {
        EntityManager em = emf.createEntityManager();
        em.joinTransaction();
        PostRemoveCallbackEntity pc = new PostRemoveCallbackEntity();
        em.persist(pc);
        em.remove(pc);
        assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
        rollback();
View Full Code Here


        em.close();
    }
   
    public void testPostRemoveNotInvokedAfterRollbackWithIntermediateFlush() {
        EntityManager em = emf.createEntityManager();
        em.joinTransaction();
        PostRemoveCallbackEntity pc = new PostRemoveCallbackEntity();
        em.persist(pc);
        em.flush();
        assertFalse("PostRemove called after flush", isPostRemovedInvoked(pc));
        em.remove(pc);
View Full Code Here

        em.close();
    }
   
    public void testPostRemoveInvokedOnFlushThatIssuesDatabaseDelete() {
        EntityManager em = emf.createEntityManager();
        em.joinTransaction();
        PostRemoveCallbackEntity pc = new PostRemoveCallbackEntity();
        em.persist(pc);
        commit();
        em.close();
       
View Full Code Here

        em.persist(pc);
        commit();
        em.close();
       
        em = emf.createEntityManager();
        em.joinTransaction();
        pc = em.find(PostRemoveCallbackEntity.class, pc.getId());
        assertNotNull(pc);
        em.remove(pc);
        assertFalse("PostRemove called after logical remove", isPostRemovedInvoked(pc));
        em.flush();
View Full Code Here

    }


    public void testPostRemoveNotInvokedAfterDatabaseInsert() {
        EntityManager em = emf.createEntityManager();
        em.joinTransaction();
        PostRemoveCallbackEntity pc = new PostRemoveCallbackEntity();
        em.persist(pc);
        assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
        commit();
        assertFalse("PostRemove called after commit", isPostRemovedInvoked(pc));
View Full Code Here

        emp.setName(name);

        EntityTransaction tx1 = em.getTransaction();
        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

            }
            final EntityManager entityManager = entityManagerTracker.getEntityManager();

            // if transaction is active, we need to register the entity manager with the transaction manager
            if (transactionActive) {
                entityManager.joinTransaction();
                transactionRegistry.putResource(txKey, entityManager);
            }

            return entityManager;
        } else {
View Full Code Here

            }

            for (final Map.Entry<EntityManagerFactory, EntityManagerTracker> entry : entityManagers.entrySet()) {
                final EntityManagerFactory entityManagerFactory = entry.getKey();
                final EntityManager entityManager = entry.getValue().getEntityManager();
                entityManager.joinTransaction();
                final EntityManagerTxKey txKey = new EntityManagerTxKey(entityManagerFactory);
                transactionRegistry.putResource(txKey, entityManager);
            }
        }
    }
View Full Code Here

            }
            final EntityManager entityManager = entityManagerTracker.getEntityManager();

            // if transaction is active, we need to register the entity manager with the transaction manager
            if (transactionActive) {
                entityManager.joinTransaction();
                transactionRegistry.putResource(txKey, entityManager);
            }

            return entityManager;
        } else {
View Full Code Here

            }

            for (final Map.Entry<EntityManagerFactory, EntityManagerTracker> entry : entityManagers.entrySet()) {
                final EntityManagerFactory entityManagerFactory = entry.getKey();
                final EntityManager entityManager = entry.getValue().getEntityManager();
                entityManager.joinTransaction();
                final EntityManagerTxKey txKey = new EntityManagerTxKey(entityManagerFactory);
                transactionRegistry.putResource(txKey, entityManager);
            }
        }
    }
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.