Package org.apache.openjpa.persistence.jdbc.common.apps.mappingApp

Examples of org.apache.openjpa.persistence.jdbc.common.apps.mappingApp.EntityWithCompositeId


    }

    public void testCompositeId() throws Exception {
        ClassMetaData cmd = repo.getMetaData(EntityWithCompositeId.class, null, true);
        try {
            JPAFacadeHelper.toOpenJPAObjectId(cmd, new EntityWithCompositeId());
            fail("Didn't fail!");
        } catch (UserException re) {
            // expected
        }
        int intId = 1;
        String nameId = "CompositeEntity";
        EntityWithCompositeId entity = new EntityWithCompositeId();
        entity.setId(intId);
        entity.setName(nameId);
        CompositeId id = new CompositeId(intId, nameId);

        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();

        assertEquals(oid, JPAFacadeHelper.toOpenJPAObjectId(cmd, id));
    }
View Full Code Here


    }

    public void testCompositeId() throws Exception {
        ClassMetaData cmd = repo.getMetaData(EntityWithCompositeId.class, null, true);
        try {
            JPAFacadeHelper.toOpenJPAObjectId(cmd, new EntityWithCompositeId());
            fail("Didn't fail!");
        } catch (UserException re) {
            // expected

        }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.jdbc.common.apps.mappingApp.EntityWithCompositeId

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.