protected void testOneKeyGen(final Class objClass, final Class extClass)
throws Exception {
OQLQuery oql;
UuidObject object;
UuidObject ext;
QueryResults enumeration;
// Open transaction in order to perform JDO operations
_db.begin();
// Create first object
object = (UuidObject) objClass.newInstance();
LOG.debug("Creating first object: " + object);
_db.create(object);
LOG.debug("Created first object: " + object);
// Create second object
ext = (UuidObject) extClass.newInstance();
LOG.debug("Creating second object: " + ext);
_db.create(ext);
LOG.debug("Created second object: " + ext);
_db.commit();
_db.begin();
// Find the first object and remove it
//object = (TestUuidObject) _db.load( objClass, object.getId() );
oql = _db.getOQLQuery();
oql.create("SELECT object FROM " + objClass.getName()
+ " object WHERE id = $1");
oql.bind(object.getId());
enumeration = oql.execute();
LOG.debug("Removing first object: " + object);
if (enumeration.hasMore()) {
object = (UuidObject) enumeration.next();
_db.remove(object);
LOG.debug("OK: Removed");
} else {
LOG.error("first object not found");
fail("first object not found");
}
// Find the second object and remove it
//ext = (TestUuidObject) _db.load( extClass, ext.getId() );
oql = _db.getOQLQuery();
oql.create("SELECT ext FROM " + extClass.getName()
+ " ext WHERE id = $1");
oql.bind(ext.getId());
enumeration = oql.execute();
LOG.debug("Removing second object: " + ext);
if (enumeration.hasMore()) {
ext = (UuidObject) enumeration.next();
_db.remove(ext);
LOG.debug("OK: Removed");
} else {
LOG.error("second object not found");
fail("second object not found");