Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problems with serializing/deserializing eOpposites
Problems with serializing/deserializing eOpposites [message #1016145] Tue, 05 March 2013 09:14 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Hi all/Ed,
I have the following serialized model objects:

  <myNS:P id="0ae41484-cdc8-497e-99aa-ee594be6a7cc" />
  <myNS:PG id="fe50804f-d464-4b97-b3bd-e6a63d5427a0">
    <pg href="0ae41484-cdc8-497e-99aa-ee594be6a7cc"/>
  </myNS:PG>


Model:

EClass P:
- id : EString (id = true)
- pg : PG 0..1 (eOpposite)

EClass PG
- id : EString (id = true)
- p : P 0..* (containment = false, eOpposite)

If I deserialize the XMI, the P instance has no reference to PG, i.e. its eOpposite reference P.pg is null. But, PG.p's EList contains a reference to P.

Shouldn't the eOpposite be set automatically when the Resource is loaded? Or do I have to make sure the eOpposite is serialized on both sides in the XMI?
Re: Problems with serializing/deserializing eOpposites [message #1016166 is a reply to message #1016145] Tue, 05 March 2013 10:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Erdal,

Comments below.

On 05/03/2013 10:14 AM, Erdal Karaca wrote:
> Hi all/Ed,
> I have the following serialized model objects:
>
>
> <myNS:P id="0ae41484-cdc8-497e-99aa-ee594be6a7cc" />
> <myNS:PG id="fe50804f-d464-4b97-b3bd-e6a63d5427a0">
> <pg href="0ae41484-cdc8-497e-99aa-ee594be6a7cc"/>
> </myNS:PG>
>
>
> Model:
>
> EClass P:
> - id : EString (id = true)
> - pg : PG 0..1 (eOpposite)
>
> EClass PG
> - id : EString (id = true)
> - p : P 0..* (containment = false, eOpposite)
>
> If I deserialize the XMI, the P instance has no reference to PG, i.e.
> its eOpposite reference P.pg is null. But, PG.p's EList contains a
> reference to P.
Are both the sides proxy resolving and non-transient? I don't see the
serialized reference from P to PG which suggests that side (pg) has been
marked transient. That's only valid if p is non-proxy resolving, i.e.,
doesn't support cross document references. But if that's the case, it
wouldn't be populated with a proxy and it wouldn't be possible for pg
not to be set.
>
> Shouldn't the eOpposite be set automatically when the Resource is loaded?
Yes and no. If they're populated with proxies, they're set separately
and must both be serialized. If they're populated directly, they'd
definitely both end up being set because the model always does that
under the covers.
> Or do I have to make sure the eOpposite is serialized on both sides in
> the XMI?
Yes if they can in general be cross document references (then both sides
must be non-transient), no if p is non-proxy resolving (and is never a
cross document reference).

Does your model validate?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problems with serializing/deserializing eOpposites [message #1016179 is a reply to message #1016166] Tue, 05 March 2013 11:22 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Hi Ed,
For both (eOpposite) refs "Resolve Proxies" is set to true and "Transient" is set to false.
The model validates.

Thanks!

Ed Merks wrote on Tue, 05 March 2013 11:24
Erdal,

Comments below.

On 05/03/2013 10:14 AM, Erdal Karaca wrote:
> Hi all/Ed,
> I have the following serialized model objects:
>
>
> <myNS:P id="0ae41484-cdc8-497e-99aa-ee594be6a7cc" />
> <myNS:PG id="fe50804f-d464-4b97-b3bd-e6a63d5427a0">
> <pg href="0ae41484-cdc8-497e-99aa-ee594be6a7cc"/>
> </myNS:PG>
>
>
> Model:
>
> EClass P:
> - id : EString (id = true)
> - pg : PG 0..1 (eOpposite)
>
> EClass PG
> - id : EString (id = true)
> - p : P 0..* (containment = false, eOpposite)
>
> If I deserialize the XMI, the P instance has no reference to PG, i.e.
> its eOpposite reference P.pg is null. But, PG.p's EList contains a
> reference to P.
Are both the sides proxy resolving and non-transient? I don't see the
serialized reference from P to PG which suggests that side (pg) has been
marked transient. That's only valid if p is non-proxy resolving, i.e.,
doesn't support cross document references. But if that's the case, it
wouldn't be populated with a proxy and it wouldn't be possible for pg
not to be set.
>
> Shouldn't the eOpposite be set automatically when the Resource is loaded?
Yes and no. If they're populated with proxies, they're set separately
and must both be serialized. If they're populated directly, they'd
definitely both end up being set because the model always does that
under the covers.
> Or do I have to make sure the eOpposite is serialized on both sides in
> the XMI?
Yes if they can in general be cross document references (then both sides
must be non-transient), no if p is non-proxy resolving (and is never a
cross document reference).

Does your model validate?

[Updated on: Tue, 05 March 2013 11:23]

Report message to a moderator

Re: Problems with serializing/deserializing eOpposites [message #1016180 is a reply to message #1016179] Tue, 05 March 2013 11:24 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Hi Ed,
For both (eOpposite) refs "Resolve Proxies" is set to true and "Transient" is set to false.
The model validates.

Thanks!

Ed Merks wrote on Tue, 05 March 2013 11:24
Erdal,

Comments below.

On 05/03/2013 10:14 AM, Erdal Karaca wrote:
> Hi all/Ed,
> I have the following serialized model objects:
>
>
> <myNS:P id="0ae41484-cdc8-497e-99aa-ee594be6a7cc" />
> <myNS:PG id="fe50804f-d464-4b97-b3bd-e6a63d5427a0">
> <pg href="0ae41484-cdc8-497e-99aa-ee594be6a7cc"/>
> </myNS:PG>
>
>
> Model:
>
> EClass P:
> - id : EString (id = true)
> - pg : PG 0..1 (eOpposite)
>
> EClass PG
> - id : EString (id = true)
> - p : P 0..* (containment = false, eOpposite)
>
> If I deserialize the XMI, the P instance has no reference to PG, i.e.
> its eOpposite reference P.pg is null. But, PG.p's EList contains a
> reference to P.
Are both the sides proxy resolving and non-transient? I don't see the
serialized reference from P to PG which suggests that side (pg) has been
marked transient. That's only valid if p is non-proxy resolving, i.e.,
doesn't support cross document references. But if that's the case, it
wouldn't be populated with a proxy and it wouldn't be possible for pg
not to be set.
>
> Shouldn't the eOpposite be set automatically when the Resource is loaded?
Yes and no. If they're populated with proxies, they're set separately
and must both be serialized. If they're populated directly, they'd
definitely both end up being set because the model always does that
under the covers.
> Or do I have to make sure the eOpposite is serialized on both sides in
> the XMI?
Yes if they can in general be cross document references (then both sides
must be non-transient), no if p is non-proxy resolving (and is never a
cross document reference).

Does your model validate?

Re: Problems with serializing/deserializing eOpposites [message #1016183 is a reply to message #1016180] Tue, 05 March 2013 11:47 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
BTW: I am copying/serializing the objects from a CDOResource.
Previous Topic:[CDO] Reference old revisions
Next Topic:unsettable incorrect after XSD to EMF transformation
Goto Forum:
  


Current Time: Tue Mar 19 08:20:38 GMT 2024

Powered by FUDForum. Page generated in 0.05885 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top