Package javax.persistence

Examples of javax.persistence.EntityManager.clear()


    Poem poem = new Poem();
    poem.setName( "L'albatros" );
    em.persist( poem );
    getTransactionManager().commit();

    em.clear();

    getTransactionManager().begin();
    poem = em.find( Poem.class, poem.getId() );
    assertThat( poem ).isNotNull();
    assertThat( poem.getName() ).isEqualTo( "L'albatros" );
View Full Code Here


    sh.setName( "Batman" );
    sh.setSpecialPower( "Technology and samurai techniques" );
    em.persist( sh );
    transactionManager.commit();

    em.clear();

    transactionManager.begin();
    Hero lh = em.find( Hero.class, h.getName() );
    assertThat( lh ).isNotNull();
    assertThat( lh ).isInstanceOf( Hero.class );
View Full Code Here

    hc.getMembers().add( h );
    hc.getMembers().add( sh );
    em.persist( hc );
    transactionManager.commit();

    em.clear();

    transactionManager.begin();
    HeroClub lhc = em.find( HeroClub.class, hc.getName() );
    assertThat( lhc ).isNotNull();
    Hero lh = lhc.getMembers().get( 0 );
View Full Code Here

        int id = emp.getId();

        em.getTransaction().commit();

        // detach
        em.clear();
        emp.setFirstName("Jane");

        Employee deserialized = (Employee) serializeObject(emp);

        assertNotNull(deserialized);
View Full Code Here

        em.getTransaction().begin();
        em.merge(deserialized);
        em.getTransaction().commit();

        em.clear();
        emp = em.find(Employee.class, id);

        assertEquals(deserialized, emp);
    }
View Full Code Here

    public void testEMClear() {
        EntityManager em = emf.createEntityManager();
        LRSEntity lrs = em.find(LRSEntity.class, id);
        assertLRS(lrs, "lrs");
        em.clear();
        assertNull(lrs.getLRSList());
        assertMerge(lrs);
        em.close();
    }
View Full Code Here

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        EntityWithCompositeId persistedEntity = em.find(EntityWithCompositeId.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();
View Full Code Here

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        // Find the entity and retrieve the objectId we use internally
        BasicEntity persistedEntity = em.find(BasicEntity.class, entity.getId());
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();
View Full Code Here

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        Person persistedEntity = em.find(Person.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();
View Full Code Here

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        DoubleObjIdEntity persistedEntity = em.find(DoubleObjIdEntity.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();
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.