em.close();
}
public void testPCMapEager() {
PersistenceUnitUtil puu = emf.getPersistenceUnitUtil();
EntityManager em = emf.createEntityManager();
MapValEntity mve = new MapValEntity();
mve.setIntVal(10);
MapKeyEmbed mke = new MapKeyEmbed();
mke.setFirstName("Jane");
mke.setLastName("Doe");
MapEntity me = new MapEntity();
assertEquals(false, puu.isLoaded(me));
assertEquals(false, puu.isLoaded(me,
"mapValEntity"));
assertEquals(false, puu.isLoaded(me,
"mapEntities"));
assertEquals(false, puu.isLoaded(mve));
// Create a circular ref
me.setMapValEntity(mve);
mve.setMapEntity(me);
HashMap<MapKeyEmbed, MapValEntity> hm =
new HashMap<MapKeyEmbed, MapValEntity>();
hm.put(mke, mve);
me.setMapEntities(hm);
em.getTransaction().begin();
em.persist(me);
em.getTransaction().commit();
assertEquals(true, puu.isLoaded(me));
assertEquals(true, puu.isLoaded(me,
"mapValEntity"));
assertEquals(true, puu.isLoaded(me,
"mapEntities"));
assertEquals(true, puu.isLoaded(mve));
em.close();
}