1 21 package com.db4o.test; 22 23 import com.db4o.*; 24 import com.db4o.query.*; 25 26 public class SodaEvaluation { 27 28 public SodaEvaluation child; 29 public String name; 30 31 public void store(){ 32 Test.deleteAllInstances(this); 33 name = "one"; 34 Test.store(this); 35 SodaEvaluation se = new SodaEvaluation(); 36 se.child= new SodaEvaluation(); 37 se.child.name = "three"; 38 se.name = "two"; 39 Test.store(se); 40 41 } 42 43 public void test(){ 44 final String nameConstraint = "three"; 45 Query q = Test.query(); 46 Query cq = q; 47 q.constrain(this.getClass()); 48 cq = cq.descend("child"); 49 cq.constrain(new Evaluation() { 50 public void evaluate(Candidate candidate) { 51 candidate.include(((SodaEvaluation)candidate.getObject()).name.equals(nameConstraint)); 52 } 53 }); 54 ObjectSet os = q.execute(); 55 Test.ensure(os.size() == 1); 56 SodaEvaluation se = (SodaEvaluation)os.next(); 57 Test.ensure(se.name.equals("two")); 58 59 } 60 61 } 62 | Popular Tags |