Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem introduced when setting 'Resolve Proxies' to true
Problem introduced when setting 'Resolve Proxies' to true [message #1732592] Wed, 18 May 2016 05:08 Go to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
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
Re: Problem introduced when setting 'Resolve Proxies' to true [message #1732593 is a reply to message #1732592] Wed, 18 May 2016 12:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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 #1732618 is a reply to message #1732593] Wed, 18 May 2016 14:35 Go to previous messageGo to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
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. 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).

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?

Cheers,
Vlad
Re: Problem introduced when setting 'Resolve Proxies' to true [message #1732623 is a reply to message #1732618] Wed, 18 May 2016 14:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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/
Re: Problem introduced when setting 'Resolve Proxies' to true [message #1732691 is a reply to message #1732623] Thu, 19 May 2016 09:14 Go to previous message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
Hi Ed,

Thank you for the answer. You pointed me in the right direction, and I realized that ResB was not yet created when ResA was saved. Only its contents were created at that point in time.

Saving the resources only after they have all been created fixed the problem.

Cheers,
Vlad
Previous Topic:[CDO] Export Repository -> XMI
Next Topic:[papyrus/CDO] error when using profiles structured in package
Goto Forum:
  


Current Time: Fri Apr 26 10:02:50 GMT 2024

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

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

Back to the top