/*
we expect 3 created 'fish'
*/
assertEquals(3, fishs.size());
Transaction tx = odmg.newTransaction();
tx.begin();
query = odmg.newOQLQuery();
query.create("select gourmets from " + ODMGGourmet.class.getName() +
" where name=$1");
query.bind(doris.getName());
List result = (List) query.execute();
assertEquals("We should found a gourmet_doris", 1, result.size());
ODMGGourmet gourmet_doris = (ODMGGourmet)result.get(0);
assertEquals(3, gourmet_doris.getFavoriteFood().size());
/*
now we lock main object and add remove a reference object
*/
tx.lock(gourmet_doris, Transaction.WRITE);
List foodList = gourmet_doris.getFavoriteFood();
foodList.remove(0);
//gourmet_doris.setFavoriteFood(foodList);
tx.commit();
query = odmg.newOQLQuery();
query.create("select gourmets from " + ODMGGourmet.class.getName() +
" where name=$1");
query.bind(doris.getName());
tx = odmg.newTransaction();
tx.begin();
result = (List) query.execute();
assertEquals("We should found a gourmet_doris", 1, result.size());
gourmet_doris = (ODMGGourmet)result.get(0);
tx.commit();
assertEquals(
"We removed one fish, so doris should only have two entries left",
2, gourmet_doris.getFavoriteFood().size());
}