|
Re: Problem introduced when setting 'Resolve Proxies' to true [message #1732593 is a reply to message #1732592] |
Wed, 18 May 2016 12:16 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Vlad,
Yes, when a bidirectional crosses resource boundaries (and hence needs
resolve proxies set to true), both ends must be serialized and so both
ends must be non-transient.
On 18.05.2016 07:08, Vlad Acretoaie wrote:
> Hi,
>
> I have an Ecore model containing two classes A and B. Class A has a
> reference rB to class B, and class B has a reference rA to class A. rB
> and rA are opposites, and rA is transient. rA and rB are
> non-containment references.
>
> When I save instances of A and B as part of the same resource,
> everything works as expected. But I am now faced with the requirement
> of saving instances of A and B in different resources (different
> files). So I tried setting 'Resolve Proxies' to true for both rA and
> rB. This leads to the following error on code generation: "The
> opposite of a transient reference must be transient if it is proxy
> resolving".
>
> Since the two classes are part of different resources, I cannot
> disable proxy resolution. I also cannot set both references as
> transient, since I need at least one of them (rB) to be persisted. As
> I see it, my only option is to make both references non-transient. Is
> this correct?
>
> Thanks in advance!
>
> Cheers,
> Vlad
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: Problem introduced when setting 'Resolve Proxies' to true [message #1732623 is a reply to message #1732618] |
Wed, 18 May 2016 14:56 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Vlad,
Comments below.
On 18.05.2016 16:35, Vlad Acretoaie wrote:
> Dear Ed,
>
> Thank you for clarifying this.
>
> There is one other aspect of this scenario that I am confused about. I
> am programmatically saving the two resources ResA and ResB that
> respectively contain instances of classes A and B. If I save ResA
> first, the file which will eventually contain ResB does not yet exist.
That shouldn't be a problem unless you never end up saving ResB. Then
ResA will have an unresolved proxy (that can't be resolved).
> Therefore, reference rB included in class A cannot possibly point to
> this file (I am using XMLResources, so a 'href' XML attribute should
> be created inside the produced <rB> tag).
It's a question of whether these two resource both exist in memory at
the time you save ResA. If both ResA and ResB are in a resource set and
have a bidirectional reference between them and the Resource.getURI() of
ResB will be used to create the proxy while saving ResA.
>
> My current solution is to (1) save ResA, (2) save ResB, (3) save ResA
> again (so that ResB has already been serialized and can be referred to
> in the serialization of ResA).
>
> Is this a reasonable approach, or could I somehow avoid the third save
> operation?
The second save sounds unnecessary unless you've actually modified the
contents of ResA between (1) and (3)...
Do you see something wrong in the serializations if you look at both
after (2) but before (3)?
>
> Cheers,
> Vlad
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04028 seconds