Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Query]Query on multiple models.
[EMF Query]Query on multiple models. [message #430731] Fri, 05 June 2009 13:27 Go to next message
Bastien is currently offline BastienFriend
Messages: 1
Registered: July 2009
Junior Member
Hello,

I try to compose a query on two models, I want to know which elements of
a model A (sourceModelElement) are in a second model B (trace). This
second model just references A elements.

This is the query :
SELECT statement = new SELECT(
new FROM(sourceModelElement),
new WHERE(new IN(trace.getAllSources())));

This request returns an empty set, though it shouldn't.
For exemple, both contain this element (this is the sysout output):
in sourceModelElement :
org.eclipse.emf.ecore.impl.EClassImpl@153c375 (name: B) ...
in trace :
org.eclipse.emf.ecore.impl.EClassImpl@12a55aa (name: B) ...

They are not the same "memory address", but EcoreUtil.equals() return
true with this two objects.

Maybe the IN operator use a reference equality instead of a "structure
and value" equality.

Have you any idea to deal with this issue ?
Thanks !

Bastien.
Re: [EMF Query]Query on multiple models. [message #430744 is a reply to message #430731] Sun, 07 June 2009 12:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Bastien,

Yes, EMF will generally use == when dealing with EObjects, especially
given that clients are advised not to override hashCode or equals on
their EObject implementations.


bastien wrote:
> Hello,
>
> I try to compose a query on two models, I want to know which elements
> of a model A (sourceModelElement) are in a second model B (trace).
> This second model just references A elements.
>
> This is the query :
> SELECT statement = new SELECT(
> new FROM(sourceModelElement),
> new WHERE(new IN(trace.getAllSources())));
>
> This request returns an empty set, though it shouldn't.
> For exemple, both contain this element (this is the sysout output):
> in sourceModelElement :
> org.eclipse.emf.ecore.impl.EClassImpl@153c375 (name: B) ...
> in trace :
> org.eclipse.emf.ecore.impl.EClassImpl@12a55aa (name: B) ...
>
> They are not the same "memory address", but EcoreUtil.equals() return
> true with this two objects.
>
> Maybe the IN operator use a reference equality instead of a "structure
> and value" equality.
>
> Have you any idea to deal with this issue ?
> Thanks !
>
> Bastien.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Postgres DB adapter not in included with net4j 2.0.0?
Next Topic:[CDO] Resource Hierarchies
Goto Forum:
  


Current Time: Thu Apr 25 20:54:15 GMT 2024

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

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

Back to the top