| [news.eclipse.tools.emf] Re: Simple newbie question: Backreferences? |
Michael,
Comments below.
What was broken?I need the following: I want a class A that has references to class B. B in turn has a reference to class A.
I made a km3-file:
package somepackage { class A { attribute aName : String; reference bspReferences [*] container : B oppositeOf refDestination; reference backDestination [0-1] : B oppositeOf backReference; } class B { attribute bName : String; reference refDestination [0-1] : A oppositeOf bspReferences; reference backReference container : A oppositeOf backDestination; } } package PrimitiveTypes { datatype String; }
Then I transformed it into an ecore file, fixed it, made a genmodel and
then an editor.
When I used the editor to make a model for this I noticed that I can'tVia which of the two references?
reference from B back to A.
I have to create a completely new A that is a child of the B.Generally we don't show container references in the properties view since they are implicit in the tree structure of the tree. But you can modified the corresponding GenFeature's Property Type to make it Editable. I'm not familiar with the syntax so I'm not actually sure which which references are containments. In Ecore we call the opposite of a containment reference a container references (it points up to the container) but given that a container references can't be multiplicity many (you can only have one container in a tree structure) I have the feeling that container means the opposite of what I would expect...
This really isn't what I wanted.It's definitely possible. Just have a look at the library model from the tutorial with links between books and writers.
Is there no way to create a "true" reference, so that, for example, one class instance is referenced by more than one other class instance?
It's definitely possible, but I'm slightly confused by what the syntax above maps to in Ecore so I have a bit of trouble giving better details. Just keep in mind that the opposite of a containment reference must be multiplicity one because adding an object to a containment reference will always remove it from it's existing container and set it to the new one.If this isn't possible I will have a big problem in the project that I am working on. :(