use of org.apache.cayenne.testdo.compound.CompoundPkTestEntity in project cayenne by apache.
the class DataContextCompoundRelIT method testInsert.
@Test
public void testInsert() {
CompoundPkTestEntity master = context.newObject(CompoundPkTestEntity.class);
CompoundFkTestEntity detail = context.newObject(CompoundFkTestEntity.class);
master.addToCompoundFkArray(detail);
master.setName("m1");
master.setKey1("key11");
master.setKey2("key21");
detail.setName("d1");
context.commitChanges();
context.invalidateObjects(master, detail);
SelectQuery q = new SelectQuery(CompoundPkTestEntity.class);
List<?> objs = context1.performQuery(q);
assertEquals(1, objs.size());
master = (CompoundPkTestEntity) objs.get(0);
assertEquals("m1", master.getName());
List<?> details = master.getCompoundFkArray();
assertEquals(1, details.size());
detail = (CompoundFkTestEntity) details.get(0);
assertEquals("d1", detail.getName());
}
Aggregations