use of org.apache.cayenne.testdo.inheritance_people.AbstractPerson in project cayenne by apache.
the class SingleTableInheritanceIT method testRelationshipAbstractFromSuperPrefetchingDisjoint.
@Test
public void testRelationshipAbstractFromSuperPrefetchingDisjoint() {
context.performGenericQuery(new SQLTemplate(AbstractPerson.class, "INSERT INTO PERSON (PERSON_ID, NAME, PERSON_TYPE) VALUES (3, 'AA', 'EE')"));
context.performGenericQuery(new SQLTemplate(PersonNotes.class, "INSERT INTO PERSON_NOTES (ID, NOTES, PERSON_ID) VALUES (3, 'AA', 3)"));
context.performGenericQuery(new SQLTemplate(PersonNotes.class, "INSERT INTO PERSON_NOTES (ID, NOTES, PERSON_ID) VALUES (4, 'BB', 3)"));
SelectQuery query = new SelectQuery(AbstractPerson.class);
query.addPrefetch(AbstractPerson.NOTES.disjoint());
final AbstractPerson person = (AbstractPerson) Cayenne.objectForQuery(context, query);
assertTrue(person instanceof Employee);
queryBlocker.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
assertEquals(2, person.getNotes().size());
String[] names = new String[2];
names[0] = person.getNotes().get(0).getNotes();
names[1] = person.getNotes().get(1).getNotes();
List<String> nameSet = Arrays.asList(names);
assertTrue(nameSet.contains("AA"));
assertTrue(nameSet.contains("BB"));
}
});
}
Aggregations