tMtTable2.insert(1, 1, "g1");
CayenneContext c1 = (CayenneContext) runtime.newContext();
CayenneContext c2 = (CayenneContext) runtime.newContext();
ClientMtTable2 o1 = (ClientMtTable2) Cayenne.objectForQuery(
c1,
new ObjectIdQuery(new ObjectId("MtTable2", "TABLE2_ID", 1)));
ClientMtTable2 o2 = (ClientMtTable2) Cayenne.objectForQuery(
c2,
new ObjectIdQuery(new ObjectId("MtTable2", "TABLE2_ID", 1)));
assertEquals("g1", o1.getTable1().getGlobalAttribute1());
assertEquals("g1", o2.getTable1().getGlobalAttribute1());
ClientMtTable1 o1r = (ClientMtTable1) Cayenne.objectForQuery(
c1,
new ObjectIdQuery(new ObjectId("MtTable1", "TABLE1_ID", 2)));
o1.setTable1(o1r);
c1.commitChanges();
// let the events propagate to peers
Thread.sleep(500);
assertEquals("g2", o2.getTable1().getGlobalAttribute1());
assertEquals(o1r.getObjectId(), o2.getTable1().getObjectId());
assertFalse(c1.internalGraphManager().hasChanges());
assertFalse(c2.internalGraphManager().hasChanges());
}