cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lon Varscsak <lon.varsc...@gmail.com>
Subject Bug when serializing/deserializing objects
Date Tue, 26 Feb 2019 17:54:09 GMT
Hey all,

A few weeks ago I posted an email about a bug when serializing, and I never
really looked much more in to it.  However, I've now encountered a
different issue if I'm using Map based data objects.  If I have a data
object, access a relationship, then serialize the object (and it's
DataContext) then deserialize the object and then try to access the
relationship again, I get this exception:

java.lang.NullPointerException

at org.apache.cayenne.util.RelationshipFault.isTransientParent(
RelationshipFault.java:69)

at org.apache.cayenne.util.PersistentObjectList.isFault(
PersistentObjectList.java:76)

at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
PersistentObjectList.java:318)

at org.apache.cayenne.util.PersistentObjectList.iterator(
PersistentObjectList.java:221)

at com.smarthealth.cayennetest.App.main(App.java:53)


It appears that the relationshipOwner variable on the ToManyList object is
null (which is an invalid state).  If I switch to field based objects, I
have no exception and things work as expected.  Also if I don't access the
relationship before serialization, then there is no error on
deserialization.

You can download a test application here:
https://ds.varscsak.com:5001/d/f/473447192107950173

If you want to flip between Map based and Field based, you can update the
pom.xml file (you'll see that commented out in the build section) and
trigger a build which should trigger the cgen task (doesn't always work for
me, so sometimes I just delete the _ files and that's enough to trigger a
rebuild).

I'm pretty comfortable switching to field based objects, but feel like this
should be addressed (or at least understood).

Thanks for your time,

Lon

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message