You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2010/11/06 17:54:08 UTC
[jira] Created: (CAY-1503) POST_LOAD is not called on prefetched
objects
POST_LOAD is not called on prefetched objects
---------------------------------------------
Key: CAY-1503
URL: https://issues.apache.org/jira/browse/CAY-1503
Project: Cayenne
Issue Type: Bug
Components: Core Library
Affects Versions: 3.0.1, 3.1M1
Reporter: Andrus Adamchik
Assignee: Andrus Adamchik
Noticed that POST_LOAD is not invoked when an object was prefetched with another object. Here is a test case:
+ public void testPostLoad_Prefetch() throws Exception {
+ LifecycleCallbackRegistry registry = getDomain()
+ .getEntityResolver()
+ .getCallbackRegistry();
+
+ ObjectContext context = createDataContext();
+
+ registry.addListener(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+ MockCallingBackListener listener = new MockCallingBackListener();
+ registry.addListener(
+ LifecycleEvent.POST_LOAD,
+ Artist.class,
+ listener,
+ "publicCallback");
+
+ Artist a1 = context.newObject(Artist.class);
+ a1.setArtistName("XX");
+ Painting p1 = context.newObject(Painting.class);
+ p1.setToArtist(a1);
+ p1.setPaintingTitle("XXX");
+ context.commitChanges();
+
+ // reset context and read related object
+ context = createDataContext();
+
+ SelectQuery q = new SelectQuery(Painting.class);
+ q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
+ p1 = (Painting) context.performQuery(q).get(0);
+
+ // artist is prefetched here, and a callback must have been invoked
+ a1 = p1.getToArtist();
+ assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
+ assertEquals(1, a1.getPostLoaded());
+ assertSame(a1, listener.getPublicCalledbackEntity());
+ }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (CAY-1503) POST_LOAD is not called on prefetched
objects
Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAY-1503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrus Adamchik closed CAY-1503.
--------------------------------
Resolution: Fixed
Fix Version/s: 3.1M1
3.0.2
> POST_LOAD is not called on prefetched objects
> ---------------------------------------------
>
> Key: CAY-1503
> URL: https://issues.apache.org/jira/browse/CAY-1503
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Affects Versions: 3.0.1, 3.1M1
> Reporter: Andrus Adamchik
> Assignee: Andrus Adamchik
> Fix For: 3.0.2, 3.1M1
>
>
> Noticed that POST_LOAD is not invoked when an object was prefetched with another object. Here is a test case:
> + public void testPostLoad_Prefetch() throws Exception {
> + LifecycleCallbackRegistry registry = getDomain()
> + .getEntityResolver()
> + .getCallbackRegistry();
> +
> + ObjectContext context = createDataContext();
> +
> + registry.addListener(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
> + MockCallingBackListener listener = new MockCallingBackListener();
> + registry.addListener(
> + LifecycleEvent.POST_LOAD,
> + Artist.class,
> + listener,
> + "publicCallback");
> +
> + Artist a1 = context.newObject(Artist.class);
> + a1.setArtistName("XX");
> + Painting p1 = context.newObject(Painting.class);
> + p1.setToArtist(a1);
> + p1.setPaintingTitle("XXX");
> + context.commitChanges();
> +
> + // reset context and read related object
> + context = createDataContext();
> +
> + SelectQuery q = new SelectQuery(Painting.class);
> + q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
> + p1 = (Painting) context.performQuery(q).get(0);
> +
> + // artist is prefetched here, and a callback must have been invoked
> + a1 = p1.getToArtist();
> + assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
> + assertEquals(1, a1.getPostLoaded());
> + assertSame(a1, listener.getPublicCalledbackEntity());
> + }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.