I have an EMF diagram that contains 2 classes. Person and Group. I am trying to persist these 2 classes into 2 different XMI files. It has to look a bit like this

Group.xmi

<XMI>
 <Group>
  <Person id="1"/>
  ...
  ...
 </Group>
 ...
</XMI>

Person.xmi

<XMI>
 <Person id="1">
  <Name>
 </Person
<XMI>

I know that it is possible... but I can't recreate it... I can only get XMI with the Persons embedded in the Group.

Any tips/hints/tutorials... on this?

有帮助吗?

解决方案

Found the answer.

First you need to make sure that every instance has it's own unique ID... this can be accomplished by setting the ID in the constructor with EcoreUtil:

setId(EcoreUtil.generateUUID());

After that you need to make sure that the person is first created in the XMI file and then save the Group. Just saving the group without saving the person first will result in containing your person in this group and this group only.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top