use of org.jpox.samples.abstractclasses.self.Module in project tests by datanucleus.
the class AbstractClassesTest method testAbstractWithCollection.
/**
* Test of a complex self-referencing assembly, with collections of abstract objects
*/
public void testAbstractWithCollection() {
Object id = null;
try {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Module module = new Module();
pm.makePersistent(module);
tx.commit();
id = pm.getObjectId(module);
tx.begin();
Extent extent = pm.getExtent(Module.class, true);
Iterator mods = extent.iterator();
Module mod = (Module) mods.next();
mod.getRoot().traverse(1);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
} finally {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Module mod = (Module) pm.getObjectById(id);
// Clears all relations
mod.clearRoot();
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
clean(Module.class);
clean(ComplexAssembly.class);
}
}
Aggregations