mt11.setGlobalAttribute1("1");
ClientMtTable1 mt12 = context.newObject(ClientMtTable1.class);
mt12.setGlobalAttribute1("2");
ClientMtTable2 mt21 = context.newObject(ClientMtTable2.class);
ClientMtTable2 mt22 = context.newObject(ClientMtTable2.class);
mt21.setTable1(mt11);
mt22.setTable1(mt11);
context.commitChanges();
ObjectContext child = context.createChildContext();
SelectQuery q = new SelectQuery(ClientMtTable1.class);
q.addOrdering("globalAttribute1", SortOrder.ASCENDING);
q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
List results = child.performQuery(q);
blockQueries();
try {
ClientMtTable1 o1 = (ClientMtTable1) results.get(0);
assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
assertSame(child, o1.getObjectContext());
List<ClientMtTable2> children1 = o1.getTable2Array();
assertEquals(2, children1.size());
Iterator<ClientMtTable2> it = children1.iterator();
while (it.hasNext()) {
ClientMtTable2 o = it.next();
assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
assertSame(child, o.getObjectContext());
assertEquals(o1, o.getTable1());
}
ClientMtTable1 o2 = (ClientMtTable1) results.get(1);
assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
assertSame(child, o2.getObjectContext());