ConcreteBar1 bar = new ConcreteBar1();
bar.setAbstractName("abstract");
bar.setConcreteName("concrete");
foo.setBar(bar);
persist.saveObject(foo);
ConcreteBar2 bar2 = new ConcreteBar2();
bar2.setAbstractName("f");
bar2.setConcreteName("C");
foo.setBar(bar2);
persist.saveObject(foo);
persist.close();
persist = new PersistenceManager(driver, database, login, password);
// assert that there are no ConcreteBar1 objects
List<ConcreteBar1> cbar1s = persist.getObjects(ConcreteBar1.class, new All());
assertEquals(0, cbar1s.size());
// assert that there is one ConcreteBar2 object
List<ConcreteBar2> cbar2s = persist.getObjects(ConcreteBar2.class, new All());
assertEquals(1, cbar2s.size());
// assert that there is one AbstractBar object
List<AbstractBar> bars = persist.getObjects(AbstractBar.class, new All());
assertEquals(1, bars.size());
// create a Foo search object
Foo searchFoo = new Foo();
// assert that the Foo object can be retrieved with a ConcreteBar2
// object.
ConcreteBar2 cbar2 = new ConcreteBar2();
cbar2.setAbstractName("f");
cbar2.setConcreteName("C");
searchFoo.setBar(cbar2);
List<Foo> foos = persist.getObjects(Foo.class, new Equal(searchFoo));
assertEquals(1, foos.size());
// assert that the Foo object can be retrieved with a ConcreteBar1