Package javax.persistence

Examples of javax.persistence.EntityManager.joinTransaction()


        assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
    }
   
    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


        assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
    }
   
    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

        assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
    }
   
    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

                throw new IllegalStateException("InternalError: an entity manager should already be registered for this entended persistence unit");
            }

            // 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 (Map.Entry<EntityManagerFactory, EntityManager> entry : entityManagers.entrySet()) {
                EntityManagerFactory entityManagerFactory = entry.getKey();
                EntityManager entityManager = entry.getValue();
                entityManager.joinTransaction();
                EntityManagerTxKey txKey = new EntityManagerTxKey(entityManagerFactory);
                transactionRegistry.putResource(txKey, entityManager);
            }
        }
    }
View Full Code Here

                          this.cmdScopedEntityManager );
            cmdScopedEntityManager = this.cmdScopedEntityManager;
        } else {
            internalCmdScopedEntityManager = false;
        }
        cmdScopedEntityManager.joinTransaction();
        appScopedEntityManager.joinTransaction();
    }

    public void endCommandScopedEntityManager() {
        if ( this.internalCmdScopedEntityManager ) {
View Full Code Here

        // Initialized persistence/tx's and persist to db
        EntityManager em = emf.createEntityManager();
        em.setFlushMode(FlushModeType.COMMIT);
        UserTransaction tx = findUserTransaction();
        tx.begin();
        em.joinTransaction();
        em.persist(badMainObject);
       
        boolean rollBackExceptionthrown = false;
        try {
            logger.info("The following " + IllegalStateException.class.getSimpleName() + " SHOULD be thrown.");
View Full Code Here

        mainObject.setName("main" + testName);
        mainObject.setSubObject(subObject);
       
        // Now persist both..
        tx.begin();
        em.joinTransaction();
        em.persist(mainObject);
        em.persist(subObject);
       
        try {
            tx.commit();
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.