Hi Lon, Thanks for example. This turned out to be a bug introduced in 4.1. Old Map based CayenneDataObject incorrectly serialized/deserialized HashMap with it's values. And that explains why you saw those values in your other case. I've pushed fix for this to 4.1 branch and tested it with your test application. Everything looks good now.
On Thu, Feb 28, 2019 at 2:17 AM Lon Varscsak <lon.varsc...@gmail.com> wrote: > > Also wondering, would this be a more appropriate post for the "dev" list is > or the "user" list appropriate/acceptable? > > -Lon > > On Wed, Feb 27, 2019 at 2:02 PM Andrus Adamchik <and...@objectstyle.org> > wrote: > > > Hi Lon, > > > > We'll need to review this. All this used to worked before. > > > > Andrus > > > > > On Feb 26, 2019, at 1:00 PM, Lon Varscsak <lon.varsc...@gmail.com> > > wrote: > > > > > > I always forget this part, I'm working off of 4.1.M3-SNAPSHOT > > > > > > On Tue, Feb 26, 2019 at 10:54 AM Lon Varscsak <lon.varsc...@gmail.com> > > > wrote: > > > > > >> 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 > > >> > > > > -- Best regards, Nikita Timofeev