Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » bidirectional cross references
bidirectional cross references [message #516104] Mon, 22 February 2010 13:50 Go to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi,

I modeled the following EClass (pseudo syntax):

eclass MyType {
ref MyType extends; // containment
ref transient MyType[] subClasses;
attr String name;
}

I created two dynamic instances (again pseudo syntax):
resource a.xmi:
MyType A

resource b.xmi:
MyType B extends A

I faced two surprising things:
1) When loading both resources into the same editor the transient
MyType.subClasses in A was empty. I had expected that it would contain
B, after the proxy in B's extends relationship had been resolved.

2) When setting the A.subClasses reference I get the following error
message: "The opposite of a transient reference must transient if it is
proxy resolving"

In Xtext I would like to allow bidirectional references where one end is
transient and gets set as soon as the proxy set on the non transient
opposite is resolved.

Is that somehow supported by EMF?

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: bidirectional cross references [message #516105 is a reply to message #516104] Mon, 22 February 2010 13:50 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
> eclass MyType {
> ref MyType extends; // containment

I meant of course "// *no* containment".

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: bidirectional cross references [message #516106 is a reply to message #516104] Mon, 22 February 2010 13:58 Go to previous messageGo to next message
Ed Merks is currently online Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Sven,

Comments below.


Sven Efftinge wrote:
> Hi,
>
> I modeled the following EClass (pseudo syntax):
>
> eclass MyType {
> ref MyType extends; // containment
> ref transient MyType[] subClasses;
> attr String name;
> }
>
> I created two dynamic instances (again pseudo syntax):
> resource a.xmi:
> MyType A
>
> resource b.xmi:
> MyType B extends A
>
> I faced two surprising things:
> 1) When loading both resources into the same editor the transient
> MyType.subClasses in A was empty. I had expected that it would contain
> B, after the proxy in B's extends relationship had been resolved.
No, proxies only operate on one end so both ends need proxies.
>
> 2) When setting the A.subClasses reference I get the following error
> message: "The opposite of a transient reference must transient if it
> is proxy resolving"
Yes, because each end needs it's own proxy.
>
> In Xtext I would like to allow bidirectional references where one end
> is transient and gets set as soon as the proxy set on the non
> transient opposite is resolved.
The problem is that the modification of such a value can't be
distinguished from literally altering the object. It also produces
surprising results, i.e., seeing different results depending on what you
traverse first, and having differently ordered results depending on
traversal ordering.
>
>
> Is that somehow supported by EMF?
No.
>
> Sven
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: bidirectional cross references [message #516121 is a reply to message #516106] Mon, 22 February 2010 14:36 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Ed Merks schrieb:
>> In Xtext I would like to allow bidirectional references where one end
>> is transient and gets set as soon as the proxy set on the non
>> transient opposite is resolved.
> The problem is that the modification of such a value can't be
> distinguished from literally altering the object. It also produces
> surprising results, i.e., seeing different results depending on what you
> traverse first, and having differently ordered results depending on
> traversal ordering.

It's not that I personally would want to use it. :-) I'm just looking
for a story for people who do.

For Xtext the story then seems to be, that bidirectional references are
only supported if both sides are persisted in the concrete syntax.

>> Is that somehow supported by EMF?
> No.

Great, that makes things much simpler :-)

Thanks,
Sven


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: bidirectional cross references [message #516133 is a reply to message #516121] Mon, 22 February 2010 15:02 Go to previous message
Ed Merks is currently online Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Sven,

Comments below.

Sven Efftinge wrote:
> Ed Merks schrieb:
>>> In Xtext I would like to allow bidirectional references where one
>>> end is transient and gets set as soon as the proxy set on the non
>>> transient opposite is resolved.
>> The problem is that the modification of such a value can't be
>> distinguished from literally altering the object. It also produces
>> surprising results, i.e., seeing different results depending on what
>> you traverse first, and having differently ordered results depending
>> on traversal ordering.
>
> It's not that I personally would want to use it. :-) I'm just looking
> for a story for people who do.
>
> For Xtext the story then seems to be, that bidirectional references
> are only supported if both sides are persisted in the concrete syntax.
Yes. If you think about the example you were using, it's misleading to
model a reference that in reality is unbounded. Knowing all the
subclasses of a given class depends on knowing all classes that exist
and of course that's only possible in a bounded or closed space. So
it's best that folks realize that determining such a thing is an
expensive computation or query, not something that's modeled data.
>
>>> Is that somehow supported by EMF?
>> No.
>
> Great, that makes things much simpler :-)
It's good to be unequivocal sometimes. :-)
>
> Thanks,
> Sven
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] CDO Model Corruption
Next Topic:[CDO] custom EDataTypes
Goto Forum:
  


Current Time: Thu Apr 25 15:10:09 GMT 2024

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

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

Back to the top