use of org.apache.cayenne.testdo.compound.CharFkTestEntity in project cayenne by apache.
the class DataContextPrefetchExtrasIT method testPrefetchToManyOnCharKey.
@Test
public void testPrefetchToManyOnCharKey() throws Exception {
createPrefetchToManyOnCharKeyDataSet();
SelectQuery q = new SelectQuery(CharPkTestEntity.class);
q.addPrefetch("charFKs");
q.addOrdering(CharPkTestEntity.OTHER_COL.asc());
List<?> pks = context.performQuery(q);
assertEquals(2, pks.size());
CharPkTestEntity pk1 = (CharPkTestEntity) pks.get(0);
assertEquals("n1", pk1.getOtherCol());
List<?> toMany = (List<?>) pk1.readPropertyDirectly("charFKs");
assertNotNull(toMany);
assertFalse(((ValueHolder) toMany).isFault());
assertEquals(3, toMany.size());
CharFkTestEntity fk1 = (CharFkTestEntity) toMany.get(0);
assertEquals(PersistenceState.COMMITTED, fk1.getPersistenceState());
assertSame(pk1, fk1.getToCharPK());
}
Aggregations