refetch2);
assertEquals(object.getObjectId(), refreshedObject.getObjectId());
}
public void testCompoundPkChangeAllElements() throws Exception {
DataContext context = createDataContext();
CompoundPkTestEntity object = context.newObject(CompoundPkTestEntity.class);
CompoundPkTestEntity refreshedObject = null;
object.setKey1(key1v1);
object.setKey2(key2v1);
object.setName("testing testing");
context.commitChanges();
assertEquals(key1v1, object.getObjectId().getIdSnapshot().get(
CompoundPkTestEntity.KEY1_PK_COLUMN));
assertEquals(key2v1, object.getObjectId().getIdSnapshot().get(
CompoundPkTestEntity.KEY2_PK_COLUMN));
ObjectIdQuery refetch = new ObjectIdQuery(
object.getObjectId(),
false,
ObjectIdQuery.CACHE_REFRESH);
refreshedObject = (CompoundPkTestEntity) Cayenne.objectForQuery(
context,
refetch);
assertEquals(object.getObjectId(), refreshedObject.getObjectId());
object.setKey1(key1v2);
object.setKey2(key2v2);
context.commitChanges();
assertEquals(key1v2, object.getObjectId().getIdSnapshot().get(
CompoundPkTestEntity.KEY1_PK_COLUMN));
assertEquals(key2v2, object.getObjectId().getIdSnapshot().get(
CompoundPkTestEntity.KEY2_PK_COLUMN));
ObjectIdQuery refetch1 = new ObjectIdQuery(
object.getObjectId(),
false,
ObjectIdQuery.CACHE_REFRESH);
refreshedObject = (CompoundPkTestEntity) Cayenne.objectForQuery(
context,
refetch1);
assertEquals(object.getObjectId(), refreshedObject.getObjectId());
object.setKey1(key1v3);
object.setKey2(key2v3);
context.commitChanges();
assertEquals(key1v3, object.getObjectId().getIdSnapshot().get(
CompoundPkTestEntity.KEY1_PK_COLUMN));
assertEquals(key2v3, object.getObjectId().getIdSnapshot().get(
CompoundPkTestEntity.KEY2_PK_COLUMN));