//bind object to name
tx.begin();
// get new DList instance
DList dlist = odmg.newDList();
Article a1 = createArticle();
Article a2 = createArticle();
Article a3 = createArticle();
dlist.add(a1);
dlist.add(a2);
dlist.add(a3);
database.bind(dlist, bindingName);
// lookup the named object - DList
List value = (List) database.lookup(bindingName);
assertNotNull("Could not lookup object for binding name: "+bindingName, value);
tx.commit();
try
{
tx.begin();
database.bind(dlist, bindingName);
tx.commit();
fail("We expected a ObjectNameNotUniqueException, but was not thrown");
}
catch (ObjectNameNotUniqueException ex)
{
// we wait for this exception
assertTrue(true);
tx.abort();
}
try
{
tx.begin();
tx.getBroker().clearCache();
database.bind(dlist, bindingName);
tx.commit();
fail("We expected a ObjectNameNotUniqueException, but was not thrown");
}
catch (ObjectNameNotUniqueException ex)
{
// we wait for this exception
assertTrue(true);
tx.abort();
}
tx.begin();
List result = (List) database.lookup(bindingName);
assertNotNull(result);
assertEquals(3, result.size());
Article newA1 = (Article) result.get(0);
assertNotNull(newA1);
assertEquals(a1.getArticleName(), newA1.getArticleName());
tx.commit();
tx.begin();
// we want to completely remove the named object
// the persisted DList with all DList entries,