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