Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Correct way to update transient crossrefs?
Correct way to update transient crossrefs? [message #1228436] Tue, 07 January 2014 08:28 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
Hi,

I have the following problem:

A have two objects, A and B. A has a single-valued reference to B which is non-transient and proxy resolving is set to false. This is needed because A and B are serialized via Xtext. B has a many-valued reference to A which is transient and proxy resolving is set to true. The reference from B to A is the EOpposite of the one from A to B.

Now, when I create an A and a B and do myA.setB(myB) the back-reference is updated correctly. When I save both objects, the reference A.b is persisted correctly, the B.a is not persisted because it is transient. So far, so good.

Now, I need to load B and get the A's which reference my B (myB.getA()). When I only load B, this list is empty (correct, as the reference is transient). I now have to load all relevant files to the same resource set with which I loaded B, then, all references are set-up correctly (the order is not important for me).

Now, I have the following problem:
- I create a new A and B with no references to each other
- I load B into an Xtext editor (which uses its own resource set I cannot influence)
- I load A into another editor (so this A is in another resource set)
- In this editor, I tell the A to reference B.
- Now, I edit the B in the other editor. This must trigger changes to the referenced A. But because the B is in another resource set, it does not know that the A on disk has a new reference to it.

My first naive approach would be to re-scan all A's after saving B, and loading them to the resource set the B resides in. But this sounds like a brute-force approach.

Is there a better way of doing this?
Re: Correct way to update transient crossrefs? [message #1228512 is a reply to message #1228436] Tue, 07 January 2014 11:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30688
Registered: July 2009
Senior Member
Jens,

Comments below.

On 07/01/2014 9:28 AM, Jens Rabe wrote:
> Hi,
>
> I have the following problem:
>
> A have two objects, A and B. A has a single-valued reference to B
> which is non-transient and proxy resolving is set to false. This is
> needed because A and B are serialized via Xtext. B has a many-valued
> reference to A which is transient and proxy resolving is set to true.
It will never typically never contain a proxy given you're not
serializing it...
> The reference from B to A is the EOpposite of the one from A to B.
>
> Now, when I create an A and a B and do myA.setB(myB) the
> back-reference is updated correctly. When I save both objects, the
> reference A.b is persisted correctly, the B.a is not persisted because
> it is transient. So far, so good.
>
> Now, I need to load B and get the A's which reference my B
> (myB.getA()). When I only load B, this list is empty (correct, as the
> reference is transient). I now have to load all relevant files to the
> same resource set with which I loaded B, then, all references are
> set-up correctly (the order is not important for me).
Given you need to load the other resources anyway, there's no so much
value in such a bidirectional reference is there?
>
> Now, I have the following problem:
> - I create a new A and B with no references to each other
> - I load B into an Xtext editor (which uses its own resource set I
> cannot influence)
> - I load A into another editor (so this A is in another resource set)
> - In this editor, I tell the A to reference B.
> - Now, I edit the B in the other editor. This must trigger changes to
> the referenced A. But because the B is in another resource set, it
> does not know that the A on disk has a new reference to it.
No, each resource set has it's own representations of the objects.
>
> My first naive approach would be to re-scan all A's after saving B,
> and loading them to the resource set the B resides in. But this sounds
> like a brute-force approach.
In the end, you can only solve this type of problem by indexing. Xtext
has a good indexer and you could use it to index any resource, not just
Xtext resources. E.g., we index *.ecore and *.genmodel so we can use
them in *.xcore.
>
> Is there a better way of doing this?
Xtext generally deals with this type of issue by indexing the resources
in the workspace. That's likely the best possible approach.
Re: Correct way to update transient crossrefs? [message #1228577 is a reply to message #1228512] Tue, 07 January 2014 14:27 Go to previous messageGo to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
Hello Ed,

thanks for the reply. Could you give me some hints on how to get started with indexing and how to use the indexer?

[Updated on: Tue, 07 January 2014 14:27]

Report message to a moderator

Re: Correct way to update transient crossrefs? [message #1228631 is a reply to message #1228577] Tue, 07 January 2014 16:58 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30688
Registered: July 2009
Senior Member
Jens,

Please direct that question to the Xtext newsgroup.

On 07/01/2014 3:27 PM, Jens Rabe wrote:
> Hello Ed,
>
> thanks for the reply. Could you give me some hints on how to get
> started with indexing and how to use the indexer??
Previous Topic:[CDO] loading resources and package registration.
Next Topic:Design application with EMF and EclipseLink
Goto Forum:
  


Current Time: Wed Dec 11 00:54:53 GMT 2019

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

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

Back to the top