public void testA() {
try {
PersistenceManager pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
for(int i=0; i<5; i++) {
IntervenantHelper ih = new IntervenantHelper();
ih.setNomep(i);
ih.setConventions(new ArrayList());
for(int j=0; j<i; j++) {
ConventionHelper ch = new ConventionHelper();
ch.setCdmec("cdmec" + i + "_" + j);
ch.setCdmem("cdmem" + i + "_" + j);
ch.setCdmed("cdmed" + i + "_" + j);
ch.setNomep(i);
ch.setIntervenant(ih);
ch.setDdmec(Calendar.getInstance().getTime());
ch.setCdmese("cdmese" + i + "_" + j);
ih.getConventions().add(ch);
}
pm.makePersistent(ih);
}
pm.currentTransaction().commit();
pm.evictAll(); //clear the L2 cache
pm.currentTransaction().begin();
IntervenantHelper ih = (IntervenantHelper) pm.getObjectById(
pm.newObjectIdInstance(IntervenantHelper.class, "" + 2),
false);
assertEquals("Bad convention elements in collection",
2,
ih.getConventions().size());
pm.close();
deleteAllInstances(IntervenantHelper.class);
deleteAllInstances(ConventionHelper.class);
} catch (Exception e) {
logger.log(BasicLevel.ERROR, "Exception", e);