Using an S.O.D.A. Query

Listing 4. Use this S.O.D.A. query to locate all of the 'Network Throughput' test suites that have at least one test case whose result is less than a specified value.

   . . .
TestSuite testsuite;
		
// Open the database
ObjectContainer db = Db4o.openFile("testsuites.YAP");

// Construct the query
Query query = db.query();
query.constrain(TestSuite.class);
Constraint nameConst = query.descend("name").
  constrain("Network Throughput");
query.descend("cases").descend("result").
  constrain(100.0f).smaller().and(nameConst);
		
System.out.println("Results:");
// Execute the query
ObjectSet result = query.execute();
if(result.isEmpty())
  System.out.println("NOTHING TO DISPLAY");
		
while(result.hasNext())
{
  testsuite = (TestSuite)(result.next());
  System.out.println(testsuite.toString());
}

db.close();
   . . .