}
public void testBasic() throws Exception {
ClassMetaData cmd = repo.getMetaData(BasicEntity.class, null, true);
try {
JPAFacadeHelper.toOpenJPAObjectId(cmd, new BasicEntity());
fail("Didn't fail!");
} catch (UserException re) {
// expected
}
try {
JPAFacadeHelper.toOpenJPAObjectId(cmd, "a");
fail("Didn't fail!");
} catch (UserException re) {
// expected
}
BasicEntity entity = new BasicEntity();
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();
assertEquals(oid, JPAFacadeHelper.toOpenJPAObjectId(cmd, entity.getId()));
Object o = JPAFacadeHelper.toOpenJPAObjectId(cmd, entity.getId());