File testFileDir = new File(TEST_DATA_DIR);
testFileDir.mkdirs();
File testFile = new File(testFileDir,NQTests.class.getSimpleName()+(_testCounter++)+".jdb");
testFile.delete();
JODBSessionContainer sessionContainer = getContainerForFile(testFile);
ObjectA objectA = new ObjectA((byte)2,(byte)3,null);
ObjectA objectA1 = new ObjectA((byte)4,(byte)3,null);
ObjectB objectB = new ObjectB();
objectB._val3 = objectA;
sessionContainer.set(objectA);
sessionContainer.set(objectA1);
sessionContainer.set(objectB);
sessionContainer.commit();
if(reopen){
sessionContainer.close();
sessionContainer = getContainerForFile(testFile);
}
Predicate<ObjectA> predicate = new Predicate<ObjectA>(){
@Override
public boolean match(ObjectA candidate) throws IOException {
if(candidate.getVal1()==4){
return true;
}
return false;
}
};
if(_checkOptimization && !sessionContainer.isOptimizedQuery(predicate, null)){
throw new RuntimeException();
}
ObjectSet<ObjectA> result = sessionContainer.query(predicate);
if(result.size() != 1){
throw new RuntimeException(""+result.size());
}
ObjectA objectA2 = result.get(0);
if(!objectA2.equals(objectA1)){
throw new RuntimeException();
}
sessionContainer.close();
// objectWithStringfromDb = (ObjectWithString) list.get(0);