final String name = "testAdding_" + System.currentTimeMillis();
TransactionExt tx = (TransactionExt) odmg.newTransaction();
tx.begin();
// create DSet and bound by name
DSet list = odmg.newDSet();
database.bind(list, name);
tx.commit();
tx.begin();
tx.getBroker().clearCache();
Object obj = database.lookup(name);
tx.commit();
assertNotNull("binded DSet not found", obj);
tx.begin();
// add objects to list
for (int i = 0; i < 5; i++)
{
DListTest.DObject a = createObject(name);
list.add(a);
}
tx.commit();
// check current list
Iterator iter = list.iterator();
while (iter.hasNext())
{
DListTest.DObject a = (DListTest.DObject) iter.next();
assertNotNull(a);
}
tx.begin();
tx.getBroker().clearCache();
// lookup list and check entries
DSet lookedUp = (DSet) database.lookup(name);
assertNotNull("binded DSet not found", lookedUp);
//System.out.println("sequence of items in lookedup list:");
iter = lookedUp.iterator();
Iterator iter1 = list.iterator();
while (iter.hasNext())
{
DListTest.DObject a = (DListTest.DObject) iter.next();
DListTest.DObject b = (DListTest.DObject) iter1.next();
assertNotNull(a);
assertNotNull(b);
assertEquals(a.getId(), b.getId());
}
tx.commit();
// add new entries to list
tx.begin();
for (int i = 0; i < 3; i++)
{
DListTest.DObject a = createObject(name + "_new_entry");
list.add(a);
}
tx.commit();
tx.begin();
tx.getBroker().clearCache();
lookedUp = (DSet) database.lookup(name);
iter = lookedUp.iterator();
iter1 = list.iterator();
assertEquals("Wrong number of DListEntry found", 8, list.size());
while (iter.hasNext())
{
DListTest.DObject a = (DListTest.DObject) iter.next();