MyFooContainer fooer = new MyFooContainer();
fooer.setFoo("oneFooer");
one.setFooContainer(fooer);
FooContainerOwner two = new FooContainerOwner();
MyExtendedFooContainer extfooer = new MyExtendedFooContainer();
extfooer.setFoo("twoFooer");
two.setFooContainer(extfooer);
// save FooContainerOwner objects.
persist.saveObject(one);
persist.saveObject(two);
persist.close();
// re-open connection
persist = new PersistenceManager(driver, database, login, password);
// check that there are two FooContainerOwners
List<FooContainerOwner> fooableowners = persist.getObjects(FooContainerOwner.class, new All());
assertEquals(2, fooableowners.size());
// check that there are two FooContainers
List<FooContainer> fooables = persist.getObjects(FooContainer.class, new All());
assertEquals(2, fooables.size());
// check that there is one ExtendedFooContainer
List<ExtendedFooContainer> extendedfooables = persist.getObjects(ExtendedFooContainer.class, new All());
assertEquals(1, extendedfooables.size());
FooContainerOwner searchObject = new FooContainerOwner();
// get the first foo based on strict search
fooer = new MyFooContainer();
fooer.setFoo("oneFooer");
searchObject.setFooContainer(fooer);
fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
assertEquals(1, fooableowners.size());
// get second foo based on strict search
extfooer = new MyExtendedFooContainer();
extfooer.setFoo("twoFooer");
searchObject.setFooContainer(extfooer);
fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
assertEquals(1, fooableowners.size());
// check that second foo can't be gotten by strict search
fooer.setFoo("twoFooer");
searchObject.setFooContainer(fooer);
fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
assertEquals(0, fooableowners.size());
// get second foo based on non-strict search
fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject, false));
assertEquals(1, fooableowners.size());
// check that the first foo can't be gotten by strict search
extfooer.setFoo("oneFooer");
searchObject.setFooContainer(extfooer);
fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
assertEquals(0, fooableowners.size());
// get first foo based on non-strict search