You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Lon Varscsak <lo...@gmail.com> on 2019/03/07 23:29:11 UTC

Re: Cayenne and Serialization

It also appears that if you use parent/child contexts, even if you
serialize both contexts, the child context doesn't remember that it's
parent channel was another context.

-Lon

On Wed, Feb 27, 2019 at 4:16 PM Lon Varscsak <lo...@gmail.com> wrote:

> There's unfortunately no clean solution for an "unmanaged"
>> (de)serialization of the context-attached auto-expanding object graph. The
>> one we have right now, that requires the context to be the serialization
>> "root", seems like the best choice out of the available options.
>
>
> Can you expand on this a little bit?  What do you mean by the root?  So
> far I find that if I serialize the ObjectContext with the data objects (two
> fields in my web page that's getting serialized as an example) things seem
> to work.  Is this just a coincidence?  What if I serialize them in a
> different order (but both serialized?)
>
> -Lon
>

Re: Cayenne and Serialization

Posted by Andrus Adamchik <an...@objectstyle.org>.
>> What do you mean by the root? 

Sorry, I was not very precise with my definition. I meant a "logical" root. The order of serialization (context first or objects first) shouldn't matter. On deserialization DataContext would reattach all its child objects to itself.

>  It also appears that if you use parent/child contexts, even if you
> serialize both contexts, the child context doesn't remember that it's
> parent channel was another context.

Correct. Part of the reason is that the parent of a context is a DataChannel. I.e. it can be either DataContext (that is serializable) or a DataDomain (that can not and should not be serialized). So we keep the "channel" ivar as transient, leaving it up to the caller to reattach it properly. 

While we can probably force parent serialization when "channel instanceof ObjectContext", I am afraid we may introduce an issue similar to what we expected to happen with DataObjects (i.e. serializing a single seemingly small thing results in serializing your world).

So please remind me, what is the scenario (and desired behavior) for serializing contexts and objects in your case? Maybe we can brainstorm some fresh ideas.

And did I say how much I "love" Java serialization?

Andrus


> On Mar 8, 2019, at 2:29 AM, Lon Varscsak <lo...@gmail.com> wrote:
> 
> It also appears that if you use parent/child contexts, even if you
> serialize both contexts, the child context doesn't remember that it's
> parent channel was another context.
> 
> -Lon
> 
> On Wed, Feb 27, 2019 at 4:16 PM Lon Varscsak <lo...@gmail.com> wrote:
> 
>> There's unfortunately no clean solution for an "unmanaged"
>>> (de)serialization of the context-attached auto-expanding object graph. The
>>> one we have right now, that requires the context to be the serialization
>>> "root", seems like the best choice out of the available options.
>> 
>> 
>> Can you expand on this a little bit?  What do you mean by the root?  So
>> far I find that if I serialize the ObjectContext with the data objects (two
>> fields in my web page that's getting serialized as an example) things seem
>> to work.  Is this just a coincidence?  What if I serialize them in a
>> different order (but both serialized?)
>> 
>> -Lon
>>