LifecycleEvent.POST_LOAD,
Artist.class,
listener,
"publicCallback");
Artist a1 = context.newObject(Artist.class);
a1.setArtistName("XX");
context.commitChanges();
assertEquals(0, a1.getPostLoaded());
assertNull(listener.getPublicCalledbackEntity());
SelectQuery q = new SelectQuery(Artist.class);
context.performQuery(q);
assertEquals(1, a1.getPostLoaded());
assertSame(a1, listener.getPublicCalledbackEntity());
a1.resetCallbackFlags();
listener.reset();
// post load must be called on rollback...
a1.resetCallbackFlags();
listener.reset();
context.rollbackChanges();
assertEquals(0, a1.getPostLoaded());
assertNull(listener.getPublicCalledbackEntity());
// now change and rollback the artist - postLoad must be called
a1.setArtistName("YY");
context.rollbackChanges();
assertEquals(1, a1.getPostLoaded());
assertSame(a1, listener.getPublicCalledbackEntity());
// test invalidated
a1.resetCallbackFlags();
listener.reset();
assertEquals(0, a1.getPostLoaded());
assertNull(listener.getPublicCalledbackEntity());
context.performQuery(new RefreshQuery(a1));
assertEquals(0, a1.getPostLoaded());
assertNull(listener.getPublicCalledbackEntity());
a1.getArtistName();
assertEquals(1, a1.getPostLoaded());
assertSame(a1, listener.getPublicCalledbackEntity());
}