List<Painting> results = context.performQuery(q);
assertEquals(1, results.size());
}
public void testPrefetch_ReflexiveRelationship() throws Exception {
ArtGroup parent = (ArtGroup) context.newObject("ArtGroup");
parent.setName("parent");
ArtGroup child = (ArtGroup) context.newObject("ArtGroup");
child.setName("child");
child.setToParentGroup(parent);
context.commitChanges();
SelectQuery q = new SelectQuery("ArtGroup");
q.setQualifier(ExpressionFactory.matchExp("name", "child"));
q.addPrefetch("toParentGroup");
final List<ArtGroup> results = context.performQuery(q);
queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
assertEquals(1, results.size());
ArtGroup fetchedChild = results.get(0);
// The parent must be fully fetched, not just HOLLOW (a fault)
assertEquals(PersistenceState.COMMITTED, fetchedChild.getToParentGroup().getPersistenceState());
}
});
}