public void testArrayOfArraysMatching() throws Exception
{
PersistenceManager persist = new PersistenceManager(driver, database, login, password);
// create a complex object with an Integer array as object
SimplestObject[][] array = new SimplestObject[][] { {},
{ new SimplestObject(), new SimplestObject(), new SimplestObject() }, {} };
for (int x = 0; x < array[1].length; x++)
{
array[1][x].setFoo((double) (x + 1));
}
ComplexObject co = new ComplexObject();
co.setObject(array);
persist.saveObject(co);
// close the persistence object
persist.close();
// re-open the persistence object
persist = new PersistenceManager(driver, database, login, password);
// create an integer array where all entries but one is null
SimplestObject[][] searchArray = new SimplestObject[3][3];
searchArray[1][2] = new SimplestObject();
searchArray[1][2].setFoo(2.0);
// make sure this matches no results
ComplexObject search = new ComplexObject();
search.setObject(searchArray);
List<ComplexObject> none = persist.getObjectsMatching(search);
assertEquals(0, none.size());
// change the search so that one object is returned
searchArray[1][1] = new SimplestObject();
searchArray[1][1].setFoo(2.0);
searchArray[1][2].setFoo(3.0);
List<ComplexObject> one = persist.getObjectsMatching(search);
assertEquals(1, one.size());