Andrus Adamchik closed CAY-1045.
--------------------------------
Resolution: Won't Fix
I added null context validation to throw a better worded exception, but that doesn't change the fact that on delete an object is disassociated from its ObjectContext and therefore you can't fault its relationships... I guess any other behavior would be counterintuitive, as the object in question is already deleted from the DB, so reading its related object from DB wouldn't make logical sense.
One possible way to deal with that is to cache all objects that you need in post-remove in an object transient variable.
> postRemove lifecycle callback not NPE safe
> ------------------------------------------
>
> Key: CAY-1045
> URL: https://issues.apache.org/cayenne/browse/CAY-1045
> Project: Cayenne
> Issue Type: Bug
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Environment: 3.0M3 (svn 642725)
> Reporter: Marcin Skladaniec
> Assignee: Andrus Adamchik
>
> Standard one to many relationship: User -< Preference, cascade rule from User to Preference. NPE is thrown when using postRemove callback on Preference record and if the getUser() method is invoked.
> Stack trace :
> [java] org.apache.cayenne.CayenneRuntimeException: [v.3.0-SNAPSHOT Mar 30 2008 12:39:13] Remote error. URL - http://10.29.64.41:8181/angel-server-cayenne; CAUSE - java.lang.NullPointerException
> [java] at org.apache.cayenne.access.ToOneFault.doResolveFault(ToOneFault.java:73)
> [java] at org.apache.cayenne.access.ToOneFault.resolveFault(ToOneFault.java:46)
> [java] at org.apache.cayenne.CayenneDataObject.readProperty(CayenneDataObject.java:208)
> [java] at ish.oncourse.server.cayenne.glue._Preference.getUser(_Preference.java:97)
> [java] at ish.oncourse.server.cayenne.Preference.getAllowsReplicationQueueing(Preference.java:28)
> [java] at ish.oncourse.server.soap.willow.SOAPUtils.createQueuedRecord(SOAPUtils.java:1033)
> [java] at ish.oncourse.server.cayenne.glue.CayenneDataObject.addRecordToReplicationQueue(CayenneDataObject.java:340)
> [java] at ish.oncourse.server.cayenne.glue.CayenneDataObject.postRemove(CayenneDataObject.java:318
> I believe that preserving the relationship on record deletion might be a bit hard, but at least the NPE should be avoided.
-- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
This archive was generated by hypermail 2.0.0 : Sat May 03 2008 - 09:12:00 EDT