public void testCollectionElementLoadingWithPrefetch() {
int NBOBJ = 2;
PersistenceManager pm = pmf.getPersistenceManager();
//create persistent instances
pm.currentTransaction().begin();
G g = new G("g1_testCollectionElementLoadingWithPrefetch");
Collection hs = g.getHs();
for(int i=0; i<NBOBJ; i++) {
H h = new H("hid_" + i);
h.setH1("h1_testCollectionElementLoadingWithPrefetch");
hs.add(h);
}
hs = null;
pm.makePersistent(g);
Object g_oid = pm.getObjectId(g);
g = null;
pm.currentTransaction().commit();
//evict all instances
pm.evictAll();
pm.currentTransaction().begin();
Query q = pm.newQuery(H.class);
q.declareParameters("String p1");
q.setFilter("hid == p1");
Object o = new ArrayList(((Collection) q.execute("hid_" + (NBOBJ-1))));
q.closeAll();
g = (G) pm.getObjectById(g_oid, false);
for (Iterator iter = g.getHs().iterator(); iter.hasNext();) {
iter.next();
}
pm.currentTransaction().commit();
//Clean up
pm.currentTransaction().begin();
pm.deletePersistentAll(g.getHs());
pm.deletePersistent(g);
pm.currentTransaction().commit();
pm.close();
}