Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [TENEO] EMF, Association, Update and Resources
[TENEO] EMF, Association, Update and Resources [message #430828] Thu, 11 June 2009 13:37 Go to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
I have a problem. The following:

A list of persons saved in a database table.
This list of persons are viewed in a listViewer

Now I have leiter and a leiter is a Person.
You can see it here:
Person p = Modelpackage.eInstance.createPerson;
Leiter l = Modelpackage.eInstance.createLeiter;
l.setPerson(p);

If i assosiate this two things I execute the command:
(1 Gruppe : N Leiter)

Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
le.setPerson(person);
Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
ZlvpPackage.Literals.GRUPPEN__LEITER, le);
if (cmd.canExecute()) {
p.getEditingDomain().getCommandStack().execute(cmd);


All works fine, but in the database a Person is added and not updated.

A list of persons I got on this way:
SessionController.registerSessionController("testsc", sc);
String uriStr2 = "hibernate://?" +
HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Person";
final URI uri2 = URI.createURI(uriStr2);
resPerson = getResourceSet().createResource(uri2);
resPerson.load(Collections.EMPTY_MAP);

In my opinion no data of a person should be change, and if they change,
its ok but dont add someone.
Re: [TENEO] EMF, Association, Update and Resources [message #430830 is a reply to message #430828] Thu, 11 June 2009 14:11 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
How is the id or version of the Person type mapped to hibernate? (call dataStore.getMappingXML() to get to the mapping xml).

Hibernate will typically create a new record/instance in the database if the id or version of the object is not set.
Only if the id is set it can detect/query for an existing object in the database and update it. Your example code below
does not show how the id is set so I wonder if the issue may be related to that.

gr. Martin

Waldi Waldemar wrote:
> I have a problem. The following:
>
> A list of persons saved in a database table.
> This list of persons are viewed in a listViewer
>
> Now I have leiter and a leiter is a Person.
> You can see it here:
> Person p = Modelpackage.eInstance.createPerson;
> Leiter l = Modelpackage.eInstance.createLeiter;
> l.setPerson(p);
>
> If i assosiate this two things I execute the command:
> (1 Gruppe : N Leiter)
>
> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
> le.setPerson(person);
> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
> if (cmd.canExecute()) {
> p.getEditingDomain().getCommandStack().execute(cmd);
>
>
> All works fine, but in the database a Person is added and not updated.
>
> A list of persons I got on this way:
> SessionController.registerSessionController("testsc", sc);
> String uriStr2 = "hibernate://?" +
> HibernateResource.SESSION_CONTROLLER_PARAM + "="
> + "testsc&query1=FROM Person";
> final URI uri2 = URI.createURI(uriStr2);
> resPerson = getResourceSet().createResource(uri2);
> resPerson.load(Collections.EMPTY_MAP);
>
> In my opinion no data of a person should be change, and if they change,
> its ok but dont add someone.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] EMF, Association, Update and Resources [message #430832 is a reply to message #430830] Thu, 11 June 2009 14:36 Go to previous messageGo to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------040106070709090007090203
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Martin,

if i inspect the Person object in the debug mode, the id is set. The
version I don't see. Is the Version important in this case? I can
implement it in the Model. My guess is that the AddCommand always create
a new Object.

The mapping is attached.

If I have a look on the table a Person who i create on this way
Person p2 = ZlvpFactory.eINSTANCE.createPerson();
p2.setVorname("TestN");
p2.setNachname("TestV");
Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
a2.setName("Herr");
Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
ge2.setName("M
Re: [TENEO] EMF, Association, Update and Resources [message #430833 is a reply to message #430832] Thu, 11 June 2009 15:02 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
Before looking at version first lets be sure that not something else is in the way.

I am sorry but as there are different code snippets I don't know what is done is in which order. What is p1 in the last
example?

I assume what you mean is after you do this:
leiter.setPerson(p);
session.save(leiter);

that p is present twice in the db. Is the value of p.id set when p is added to the leiter (and it has the correct value?)?

gr. Martin

Waldi Waldemar wrote:
> Hi Martin,
>
> if i inspect the Person object in the debug mode, the id is set. The
> version I don't see. Is the Version important in this case? I can
> implement it in the Model. My guess is that the AddCommand always create
> a new Object.
>
> The mapping is attached.
>
> If I have a look on the table a Person who i create on this way
> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
> p2.setVorname("TestN");
> p2.setNachname("TestV");
> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
> a2.setName("Herr");
> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
> ge2.setName("Männlich");
> p2.setAnrede(a2);
> p2.setGeschlecht(ge2);
>
> tx.begin();
> session.save(p1);
> session.save(p2);
> tx.commit();
> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>
> After the association it is:
> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>
>
> Martin Taal schrieb:
>> Hi Waldi,
>> How is the id or version of the Person type mapped to hibernate? (call
>> dataStore.getMappingXML() to get to the mapping xml).
>>
>> Hibernate will typically create a new record/instance in the database
>> if the id or version of the object is not set. Only if the id is set
>> it can detect/query for an existing object in the database and update
>> it. Your example code below does not show how the id is set so I
>> wonder if the issue may be related to that.
>>
>> gr. Martin
>>
>> Waldi Waldemar wrote:
>>> I have a problem. The following:
>>>
>>> A list of persons saved in a database table.
>>> This list of persons are viewed in a listViewer
>>>
>>> Now I have leiter and a leiter is a Person.
>>> You can see it here:
>>> Person p = Modelpackage.eInstance.createPerson;
>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>> l.setPerson(p);
>>>
>>> If i assosiate this two things I execute the command:
>>> (1 Gruppe : N Leiter)
>>>
>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>> le.setPerson(person);
>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>> if (cmd.canExecute()) {
>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>
>>>
>>> All works fine, but in the database a Person is added and not updated.
>>>
>>> A list of persons I got on this way:
>>> SessionController.registerSessionController("testsc", sc);
>>> String uriStr2 = "hibernate://?" +
>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>> + "testsc&query1=FROM Person";
>>> final URI uri2 = URI.createURI(uriStr2);
>>> resPerson = getResourceSet().createResource(uri2);
>>> resPerson.load(Collections.EMPTY_MAP);
>>>
>>> In my opinion no data of a person should be change, and if they
>>> change, its ok but dont add someone.
>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] EMF, Association, Update and Resources [message #430835 is a reply to message #430833] Thu, 11 June 2009 16:18 Go to previous messageGo to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
Ok, sorry for this a little bit strange things. In order I do:
1. Create some example data's - all is ok
2. Load all Persons from the Table - like: - all is ok
SessionController.registerSessionController("testsc", sc);
String uriStr2 = "hibernate://?" +
HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Person";
final URI uri2 = URI.createURI(uriStr2);
resPerson = getResourceSet().createResource(uri2);
resPerson.load(Collections.EMPTY_MAP);

3. Then I take the selecten of the ListViewer and add the selected
person to the model on this way:
Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
le.setPerson(person);
Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
ZlvpPackage.Literals.GRUPPEN__LEITER, le);
if (cmd.canExecute()) {
p.getEditingDomain().getCommandStack().execute(cmd);

4. And now in my Database are two same persons. The difference is:
11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";"" -
Create Person on the normal way like in you qick start example
5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
- This Person is created by the AddCommand.....

I delete the database and recreate it. When I have a look on the
variables.... All ID's are setted and correct: The Gruppe ID is 3, The
Leiter ID is null (because its new) the Person ID in the Leiter is 8 and
the Person id is 8

Hope this helps



Martin Taal schrieb:
> Hi Waldi,
> Before looking at version first lets be sure that not something else is
> in the way.
>
> I am sorry but as there are different code snippets I don't know what is
> done is in which order. What is p1 in the last example?
>
> I assume what you mean is after you do this:
> leiter.setPerson(p);
> session.save(leiter);
>
> that p is present twice in the db. Is the value of p.id set when p is
> added to the leiter (and it has the correct value?)?
>
> gr. Martin
>
> Waldi Waldemar wrote:
>> Hi Martin,
>>
>> if i inspect the Person object in the debug mode, the id is set. The
>> version I don't see. Is the Version important in this case? I can
>> implement it in the Model. My guess is that the AddCommand always
>> create a new Object.
>>
>> The mapping is attached.
>>
>> If I have a look on the table a Person who i create on this way
>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>> p2.setVorname("TestN");
>> p2.setNachname("TestV");
>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>> a2.setName("Herr");
>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>> ge2.setName("Männlich");
>> p2.setAnrede(a2);
>> p2.setGeschlecht(ge2);
>> tx.begin();
>> session.save(p1);
>> session.save(p2);
>> tx.commit();
>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>
>> After the association it is:
>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>
>>
>> Martin Taal schrieb:
>>> Hi Waldi,
>>> How is the id or version of the Person type mapped to hibernate?
>>> (call dataStore.getMappingXML() to get to the mapping xml).
>>>
>>> Hibernate will typically create a new record/instance in the database
>>> if the id or version of the object is not set. Only if the id is set
>>> it can detect/query for an existing object in the database and update
>>> it. Your example code below does not show how the id is set so I
>>> wonder if the issue may be related to that.
>>>
>>> gr. Martin
>>>
>>> Waldi Waldemar wrote:
>>>> I have a problem. The following:
>>>>
>>>> A list of persons saved in a database table.
>>>> This list of persons are viewed in a listViewer
>>>>
>>>> Now I have leiter and a leiter is a Person.
>>>> You can see it here:
>>>> Person p = Modelpackage.eInstance.createPerson;
>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>> l.setPerson(p);
>>>>
>>>> If i assosiate this two things I execute the command:
>>>> (1 Gruppe : N Leiter)
>>>>
>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>> le.setPerson(person);
>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>> if (cmd.canExecute()) {
>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>
>>>>
>>>> All works fine, but in the database a Person is added and not updated.
>>>>
>>>> A list of persons I got on this way:
>>>> SessionController.registerSessionController("testsc", sc);
>>>> String uriStr2 = "hibernate://?" +
>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>> + "testsc&query1=FROM Person";
>>>> final URI uri2 = URI.createURI(uriStr2);
>>>> resPerson = getResourceSet().createResource(uri2);
>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>
>>>> In my opinion no data of a person should be change, and if they
>>>> change, its ok but dont add someone.
>>>
>>>
>>
>
>
Re: [TENEO] EMF, Association, Update and Resources [message #430836 is a reply to message #430835] Thu, 11 June 2009 16:29 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
Okay, is the person instance you load from the database the exact same object instance which is set in leiter (can you
check after the save has been done)? I ask because in your hibernate mapping you have a so-called 'synthetic version',
this is done by Teneo if there is no explicit version eattribute present. However, this version eattribute works only
with object instance equality.
I am not sure either what the AddCommand exactly performs, at what point does the actual save occur?

gr. Martin

Waldi Waldemar wrote:
> Ok, sorry for this a little bit strange things. In order I do:
> 1. Create some example data's - all is ok
> 2. Load all Persons from the Table - like: - all is ok
> SessionController.registerSessionController("testsc", sc);
> String uriStr2 = "hibernate://?" +
> HibernateResource.SESSION_CONTROLLER_PARAM + "="
> + "testsc&query1=FROM Person";
> final URI uri2 = URI.createURI(uriStr2);
> resPerson = getResourceSet().createResource(uri2);
> resPerson.load(Collections.EMPTY_MAP);
>
> 3. Then I take the selecten of the ListViewer and add the selected
> person to the model on this way:
> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
> le.setPerson(person);
> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
> if (cmd.canExecute()) {
> p.getEditingDomain().getCommandStack().execute(cmd);
>
> 4. And now in my Database are two same persons. The difference is:
> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";"" -
> Create Person on the normal way like in you qick start example
> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
> - This Person is created by the AddCommand.....
>
> I delete the database and recreate it. When I have a look on the
> variables.... All ID's are setted and correct: The Gruppe ID is 3, The
> Leiter ID is null (because its new) the Person ID in the Leiter is 8 and
> the Person id is 8
>
> Hope this helps
>
>
>
> Martin Taal schrieb:
>> Hi Waldi,
>> Before looking at version first lets be sure that not something else
>> is in the way.
>>
>> I am sorry but as there are different code snippets I don't know what
>> is done is in which order. What is p1 in the last example?
>>
>> I assume what you mean is after you do this:
>> leiter.setPerson(p);
>> session.save(leiter);
>>
>> that p is present twice in the db. Is the value of p.id set when p is
>> added to the leiter (and it has the correct value?)?
>>
>> gr. Martin
>>
>> Waldi Waldemar wrote:
>>> Hi Martin,
>>>
>>> if i inspect the Person object in the debug mode, the id is set. The
>>> version I don't see. Is the Version important in this case? I can
>>> implement it in the Model. My guess is that the AddCommand always
>>> create a new Object.
>>>
>>> The mapping is attached.
>>>
>>> If I have a look on the table a Person who i create on this way
>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>> p2.setVorname("TestN");
>>> p2.setNachname("TestV");
>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>> a2.setName("Herr");
>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>> ge2.setName("Männlich");
>>> p2.setAnrede(a2);
>>> p2.setGeschlecht(ge2);
>>> tx.begin();
>>> session.save(p1);
>>> session.save(p2);
>>> tx.commit();
>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>
>>> After the association it is:
>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>
>>>
>>> Martin Taal schrieb:
>>>> Hi Waldi,
>>>> How is the id or version of the Person type mapped to hibernate?
>>>> (call dataStore.getMappingXML() to get to the mapping xml).
>>>>
>>>> Hibernate will typically create a new record/instance in the
>>>> database if the id or version of the object is not set. Only if the
>>>> id is set it can detect/query for an existing object in the database
>>>> and update it. Your example code below does not show how the id is
>>>> set so I wonder if the issue may be related to that.
>>>>
>>>> gr. Martin
>>>>
>>>> Waldi Waldemar wrote:
>>>>> I have a problem. The following:
>>>>>
>>>>> A list of persons saved in a database table.
>>>>> This list of persons are viewed in a listViewer
>>>>>
>>>>> Now I have leiter and a leiter is a Person.
>>>>> You can see it here:
>>>>> Person p = Modelpackage.eInstance.createPerson;
>>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>>> l.setPerson(p);
>>>>>
>>>>> If i assosiate this two things I execute the command:
>>>>> (1 Gruppe : N Leiter)
>>>>>
>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>> le.setPerson(person);
>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>> if (cmd.canExecute()) {
>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>
>>>>>
>>>>> All works fine, but in the database a Person is added and not updated.
>>>>>
>>>>> A list of persons I got on this way:
>>>>> SessionController.registerSessionController("testsc", sc);
>>>>> String uriStr2 = "hibernate://?" +
>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>> + "testsc&query1=FROM Person";
>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>
>>>>> In my opinion no data of a person should be change, and if they
>>>>> change, its ok but dont add someone.
>>>>
>>>>
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] EMF, Association, Update and Resources [message #430837 is a reply to message #430836] Thu, 11 June 2009 16:55 Go to previous messageGo to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
answers below
Martin Taal schrieb:
> Hi Waldi,
> Okay, is the person instance you load from the database the exact same
> object instance which is set in leiter (can you check after the save has
> been done)?
Yes it's the same object instance.
No, I can't check. I can check it till Command cmd =
AddCommand.create(p.getEditingDomain(), gruppe,
ZlvpPackage.Literals.GRUPPEN__LEITER, le);
Till this all attributes are the same as in the database.

> I ask because in your hibernate mapping you have a so-called
> 'synthetic version', this is done by Teneo if there is no explicit
> version eattribute present.
Ok that can be the failure. Now i should model a version attribute and
add a annotation on it that i can see on the runtime the actual version
of the object?

> However, this version eattribute works only
> with object instance equality.
What mean it exactly?

> I am not sure either what the AddCommand exactly performs, at what point
> does the actual save occur?
I don't understand this question. The save is done with Strg+S and it
execute resource.save - this save all what is in the command stack.


> gr. Martin
>
> Waldi Waldemar wrote:
>> Ok, sorry for this a little bit strange things. In order I do:
>> 1. Create some example data's - all is ok
>> 2. Load all Persons from the Table - like: - all is ok
>> SessionController.registerSessionController("testsc", sc);
>> String uriStr2 = "hibernate://?" +
>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>> + "testsc&query1=FROM Person";
>> final URI uri2 = URI.createURI(uriStr2);
>> resPerson = getResourceSet().createResource(uri2);
>> resPerson.load(Collections.EMPTY_MAP);
>>
>> 3. Then I take the selecten of the ListViewer and add the selected
>> person to the model on this way:
>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>> le.setPerson(person);
>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>> if (cmd.canExecute()) {
>> p.getEditingDomain().getCommandStack().execute(cmd);
>>
>> 4. And now in my Database are two same persons. The difference is:
>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>> - Create Person on the normal way like in you qick start example
>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>> - This Person is created by the AddCommand.....
>>
>> I delete the database and recreate it. When I have a look on the
>> variables.... All ID's are setted and correct: The Gruppe ID is 3, The
>> Leiter ID is null (because its new) the Person ID in the Leiter is 8
>> and the Person id is 8
>>
>> Hope this helps
>>
>>
>>
>> Martin Taal schrieb:
>>> Hi Waldi,
>>> Before looking at version first lets be sure that not something else
>>> is in the way.
>>>
>>> I am sorry but as there are different code snippets I don't know what
>>> is done is in which order. What is p1 in the last example?
>>>
>>> I assume what you mean is after you do this:
>>> leiter.setPerson(p);
>>> session.save(leiter);
>>>
>>> that p is present twice in the db. Is the value of p.id set when p is
>>> added to the leiter (and it has the correct value?)?
>>>
>>> gr. Martin
>>>
>>> Waldi Waldemar wrote:
>>>> Hi Martin,
>>>>
>>>> if i inspect the Person object in the debug mode, the id is set. The
>>>> version I don't see. Is the Version important in this case? I can
>>>> implement it in the Model. My guess is that the AddCommand always
>>>> create a new Object.
>>>>
>>>> The mapping is attached.
>>>>
>>>> If I have a look on the table a Person who i create on this way
>>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>>> p2.setVorname("TestN");
>>>> p2.setNachname("TestV");
>>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>>> a2.setName("Herr");
>>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>>> ge2.setName("Männlich");
>>>> p2.setAnrede(a2);
>>>> p2.setGeschlecht(ge2);
>>>> tx.begin();
>>>> session.save(p1);
>>>> session.save(p2);
>>>> tx.commit();
>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>
>>>> After the association it is:
>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>
>>>>
>>>> Martin Taal schrieb:
>>>>> Hi Waldi,
>>>>> How is the id or version of the Person type mapped to hibernate?
>>>>> (call dataStore.getMappingXML() to get to the mapping xml).
>>>>>
>>>>> Hibernate will typically create a new record/instance in the
>>>>> database if the id or version of the object is not set. Only if the
>>>>> id is set it can detect/query for an existing object in the
>>>>> database and update it. Your example code below does not show how
>>>>> the id is set so I wonder if the issue may be related to that.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Waldi Waldemar wrote:
>>>>>> I have a problem. The following:
>>>>>>
>>>>>> A list of persons saved in a database table.
>>>>>> This list of persons are viewed in a listViewer
>>>>>>
>>>>>> Now I have leiter and a leiter is a Person.
>>>>>> You can see it here:
>>>>>> Person p = Modelpackage.eInstance.createPerson;
>>>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>>>> l.setPerson(p);
>>>>>>
>>>>>> If i assosiate this two things I execute the command:
>>>>>> (1 Gruppe : N Leiter)
>>>>>>
>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>> le.setPerson(person);
>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>> if (cmd.canExecute()) {
>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>
>>>>>>
>>>>>> All works fine, but in the database a Person is added and not
>>>>>> updated.
>>>>>>
>>>>>> A list of persons I got on this way:
>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>> String uriStr2 = "hibernate://?" +
>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>> + "testsc&query1=FROM Person";
>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>
>>>>>> In my opinion no data of a person should be change, and if they
>>>>>> change, its ok but dont add someone.
>>>>>
>>>>>
>>>>
>>>
>>>
>
>
Re: [TENEO] EMF, Association, Update and Resources [message #430838 is a reply to message #430837] Thu, 11 June 2009 17:08 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
Reaction inline, marked with MT>>

So after saving the resource, the id of the person has changed (in-memory)?

Yes it is best to have a version eattribute anyway, so if you can model that and annotate it with @Version.
Then let me know if the problem is still there (or not...hopefully).

gr. Martin

Waldi Waldemar wrote:
> answers below
> Martin Taal schrieb:
>> Hi Waldi,
>> Okay, is the person instance you load from the database the exact same
>> object instance which is set in leiter (can you check after the save
>> has been done)?
> Yes it's the same object instance.
> No, I can't check. I can check it till Command cmd =
> AddCommand.create(p.getEditingDomain(), gruppe,
> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
> Till this all attributes are the same as in the database.
>
>> I ask because in your hibernate mapping you have a so-called
>> 'synthetic version', this is done by Teneo if there is no explicit
>> version eattribute present.
> Ok that can be the failure. Now i should model a version attribute and
> add a annotation on it that i can see on the runtime the actual version
> of the object?
>
>> However, this version eattribute works only with object instance
>> equality.
> What mean it exactly?
MT>> The synthetic version logic is implemented in the IdentifierCacheHandler. That handler compares objects like this:
o1 == o2 to find the version of an eobject.

>
>> I am not sure either what the AddCommand exactly performs, at what
>> point does the actual save occur?
> I don't understand this question. The save is done with Strg+S and it
> execute resource.save - this save all what is in the command stack.
MT>> Okay when the resource is saved

>
>
>> gr. Martin
>>
>> Waldi Waldemar wrote:
>>> Ok, sorry for this a little bit strange things. In order I do:
>>> 1. Create some example data's - all is ok
>>> 2. Load all Persons from the Table - like: - all is ok
>>> SessionController.registerSessionController("testsc", sc);
>>> String uriStr2 = "hibernate://?" +
>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>> + "testsc&query1=FROM Person";
>>> final URI uri2 = URI.createURI(uriStr2);
>>> resPerson = getResourceSet().createResource(uri2);
>>> resPerson.load(Collections.EMPTY_MAP);
>>>
>>> 3. Then I take the selecten of the ListViewer and add the selected
>>> person to the model on this way:
>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>> le.setPerson(person);
>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>> if (cmd.canExecute()) {
>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>
>>> 4. And now in my Database are two same persons. The difference is:
>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>> - Create Person on the normal way like in you qick start example
>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>> - This Person is created by the AddCommand.....
>>>
>>> I delete the database and recreate it. When I have a look on the
>>> variables.... All ID's are setted and correct: The Gruppe ID is 3,
>>> The Leiter ID is null (because its new) the Person ID in the Leiter
>>> is 8 and the Person id is 8
>>>
>>> Hope this helps
>>>
>>>
>>>
>>> Martin Taal schrieb:
>>>> Hi Waldi,
>>>> Before looking at version first lets be sure that not something else
>>>> is in the way.
>>>>
>>>> I am sorry but as there are different code snippets I don't know
>>>> what is done is in which order. What is p1 in the last example?
>>>>
>>>> I assume what you mean is after you do this:
>>>> leiter.setPerson(p);
>>>> session.save(leiter);
>>>>
>>>> that p is present twice in the db. Is the value of p.id set when p
>>>> is added to the leiter (and it has the correct value?)?
>>>>
>>>> gr. Martin
>>>>
>>>> Waldi Waldemar wrote:
>>>>> Hi Martin,
>>>>>
>>>>> if i inspect the Person object in the debug mode, the id is set.
>>>>> The version I don't see. Is the Version important in this case? I
>>>>> can implement it in the Model. My guess is that the AddCommand
>>>>> always create a new Object.
>>>>>
>>>>> The mapping is attached.
>>>>>
>>>>> If I have a look on the table a Person who i create on this way
>>>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>>>> p2.setVorname("TestN");
>>>>> p2.setNachname("TestV");
>>>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>>>> a2.setName("Herr");
>>>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>>>> ge2.setName("Männlich");
>>>>> p2.setAnrede(a2);
>>>>> p2.setGeschlecht(ge2);
>>>>> tx.begin();
>>>>> session.save(p1);
>>>>> session.save(p2);
>>>>> tx.commit();
>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>>
>>>>> After the association it is:
>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>>
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Waldi,
>>>>>> How is the id or version of the Person type mapped to hibernate?
>>>>>> (call dataStore.getMappingXML() to get to the mapping xml).
>>>>>>
>>>>>> Hibernate will typically create a new record/instance in the
>>>>>> database if the id or version of the object is not set. Only if
>>>>>> the id is set it can detect/query for an existing object in the
>>>>>> database and update it. Your example code below does not show how
>>>>>> the id is set so I wonder if the issue may be related to that.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Waldi Waldemar wrote:
>>>>>>> I have a problem. The following:
>>>>>>>
>>>>>>> A list of persons saved in a database table.
>>>>>>> This list of persons are viewed in a listViewer
>>>>>>>
>>>>>>> Now I have leiter and a leiter is a Person.
>>>>>>> You can see it here:
>>>>>>> Person p = Modelpackage.eInstance.createPerson;
>>>>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>>>>> l.setPerson(p);
>>>>>>>
>>>>>>> If i assosiate this two things I execute the command:
>>>>>>> (1 Gruppe : N Leiter)
>>>>>>>
>>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>>> le.setPerson(person);
>>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>>> if (cmd.canExecute()) {
>>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>>
>>>>>>>
>>>>>>> All works fine, but in the database a Person is added and not
>>>>>>> updated.
>>>>>>>
>>>>>>> A list of persons I got on this way:
>>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>>> String uriStr2 = "hibernate://?" +
>>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>>> + "testsc&query1=FROM Person";
>>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>>
>>>>>>> In my opinion no data of a person should be change, and if they
>>>>>>> change, its ok but dont add someone.
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] EMF, Association, Update and Resources [message #430840 is a reply to message #430838] Thu, 11 June 2009 18:45 Go to previous messageGo to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------060302050205040805040905
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

ok, i've attach a snapshot. You can see the values... The problem is the
same. Hmm what can I do now? That you can understand the complete thing
I've attach the *.ecore. I think you can understand german ;-)

Martin Taal schrieb:
> Hi Waldi,
> Reaction inline, marked with MT>>
>
> So after saving the resource, the id of the person has changed (in-memory)?
>
> Yes it is best to have a version eattribute anyway, so if you can model
> that and annotate it with @Version.
> Then let me know if the problem is still there (or not...hopefully).
>
> gr. Martin
>
> Waldi Waldemar wrote:
>> answers below
>> Martin Taal schrieb:
>>> Hi Waldi,
>>> Okay, is the person instance you load from the database the exact
>>> same object instance which is set in leiter (can you check after the
>>> save has been done)?
>> Yes it's the same object instance.
>> No, I can't check. I can check it till Command cmd =
>> AddCommand.create(p.getEditingDomain(), gruppe,
>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>> Till this all attributes are the same as in the database.
>>
>>> I ask because in your hibernate mapping you have a so-called
>>> 'synthetic version', this is done by Teneo if there is no explicit
>>> version eattribute present.
>> Ok that can be the failure. Now i should model a version attribute and
>> add a annotation on it that i can see on the runtime the actual
>> version of the object?
>>
>>> However, this version eattribute works only with object instance
>>> equality.
>> What mean it exactly?
> MT>> The synthetic version logic is implemented in the
> IdentifierCacheHandler. That handler compares objects like this: o1 ==
> o2 to find the version of an eobject.
>
>>
>>> I am not sure either what the AddCommand exactly performs, at what
>>> point does the actual save occur?
>> I don't understand this question. The save is done with Strg+S and it
>> execute resource.save - this save all what is in the command stack.
> MT>> Okay when the resource is saved
>
>>
>>
>>> gr. Martin
>>>
>>> Waldi Waldemar wrote:
>>>> Ok, sorry for this a little bit strange things. In order I do:
>>>> 1. Create some example data's - all is ok
>>>> 2. Load all Persons from the Table - like: - all is ok
>>>> SessionController.registerSessionController("testsc", sc);
>>>> String uriStr2 = "hibernate://?" +
>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>> + "testsc&query1=FROM Person";
>>>> final URI uri2 = URI.createURI(uriStr2);
>>>> resPerson = getResourceSet().createResource(uri2);
>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>
>>>> 3. Then I take the selecten of the ListViewer and add the selected
>>>> person to the model on this way:
>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>> le.setPerson(person);
>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>> if (cmd.canExecute()) {
>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>
>>>> 4. And now in my Database are two same persons. The difference is:
>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>> - Create Person on the normal way like in you qick start example
>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>> - This Person is created by the AddCommand.....
>>>>
>>>> I delete the database and recreate it. When I have a look on the
>>>> variables.... All ID's are setted and correct: The Gruppe ID is 3,
>>>> The Leiter ID is null (because its new) the Person ID in the Leiter
>>>> is 8 and the Person id is 8
>>>>
>>>> Hope this helps
>>>>
>>>>
>>>>
>>>> Martin Taal schrieb:
>>>>> Hi Waldi,
>>>>> Before looking at version first lets be sure that not something
>>>>> else is in the way.
>>>>>
>>>>> I am sorry but as there are different code snippets I don't know
>>>>> what is done is in which order. What is p1 in the last example?
>>>>>
>>>>> I assume what you mean is after you do this:
>>>>> leiter.setPerson(p);
>>>>> session.save(leiter);
>>>>>
>>>>> that p is present twice in the db. Is the value of p.id set when p
>>>>> is added to the leiter (and it has the correct value?)?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Waldi Waldemar wrote:
>>>>>> Hi Martin,
>>>>>>
>>>>>> if i inspect the Person object in the debug mode, the id is set.
>>>>>> The version I don't see. Is the Version important in this case? I
>>>>>> can implement it in the Model. My guess is that the AddCommand
>>>>>> always create a new Object.
>>>>>>
>>>>>> The mapping is attached.
>>>>>>
>>>>>> If I have a look on the table a Person who i create on this way
>>>>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>>>>> p2.setVorname("TestN");
>>>>>> p2.setNachname("TestV");
>>>>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>>>>> a2.setName("Herr");
>>>>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>>>>> ge2.setName("M
Re: [TENEO] EMF, Association, Update and Resources [message #430841 is a reply to message #430840] Thu, 11 June 2009 18:50 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes I can read German no problem :-).

Can you replicate the issue without resources or using AddCommand but just doing plain hibernate session.save etc.? If
you can then send me the test program then I can try it out myself. The ecore you attached is complete (I don't need
other ecores)?

gr. Martin

Waldi Waldemar wrote:
> ok, i've attach a snapshot. You can see the values... The problem is the
> same. Hmm what can I do now? That you can understand the complete thing
> I've attach the *.ecore. I think you can understand german ;-)
>
> Martin Taal schrieb:
>> Hi Waldi,
>> Reaction inline, marked with MT>>
>>
>> So after saving the resource, the id of the person has changed
>> (in-memory)?
>>
>> Yes it is best to have a version eattribute anyway, so if you can
>> model that and annotate it with @Version.
>> Then let me know if the problem is still there (or not...hopefully).
>>
>> gr. Martin
>>
>> Waldi Waldemar wrote:
>>> answers below
>>> Martin Taal schrieb:
>>>> Hi Waldi,
>>>> Okay, is the person instance you load from the database the exact
>>>> same object instance which is set in leiter (can you check after the
>>>> save has been done)?
>>> Yes it's the same object instance.
>>> No, I can't check. I can check it till Command cmd =
>>> AddCommand.create(p.getEditingDomain(), gruppe,
>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>> Till this all attributes are the same as in the database.
>>>
>>>> I ask because in your hibernate mapping you have a so-called
>>>> 'synthetic version', this is done by Teneo if there is no explicit
>>>> version eattribute present.
>>> Ok that can be the failure. Now i should model a version attribute
>>> and add a annotation on it that i can see on the runtime the actual
>>> version of the object?
>>>
>>>> However, this version eattribute works only with object instance
>>>> equality.
>>> What mean it exactly?
>> MT>> The synthetic version logic is implemented in the
>> IdentifierCacheHandler. That handler compares objects like this: o1 ==
>> o2 to find the version of an eobject.
>>
>>>
>>>> I am not sure either what the AddCommand exactly performs, at what
>>>> point does the actual save occur?
>>> I don't understand this question. The save is done with Strg+S and it
>>> execute resource.save - this save all what is in the command stack.
>> MT>> Okay when the resource is saved
>>
>>>
>>>
>>>> gr. Martin
>>>>
>>>> Waldi Waldemar wrote:
>>>>> Ok, sorry for this a little bit strange things. In order I do:
>>>>> 1. Create some example data's - all is ok
>>>>> 2. Load all Persons from the Table - like: - all is ok
>>>>> SessionController.registerSessionController("testsc", sc);
>>>>> String uriStr2 = "hibernate://?" +
>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>> + "testsc&query1=FROM Person";
>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>
>>>>> 3. Then I take the selecten of the ListViewer and add the selected
>>>>> person to the model on this way:
>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>> le.setPerson(person);
>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>> if (cmd.canExecute()) {
>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>
>>>>> 4. And now in my Database are two same persons. The difference is:
>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>> - Create Person on the normal way like in you qick start example
>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>> - This Person is created by the AddCommand.....
>>>>>
>>>>> I delete the database and recreate it. When I have a look on the
>>>>> variables.... All ID's are setted and correct: The Gruppe ID is 3,
>>>>> The Leiter ID is null (because its new) the Person ID in the Leiter
>>>>> is 8 and the Person id is 8
>>>>>
>>>>> Hope this helps
>>>>>
>>>>>
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Waldi,
>>>>>> Before looking at version first lets be sure that not something
>>>>>> else is in the way.
>>>>>>
>>>>>> I am sorry but as there are different code snippets I don't know
>>>>>> what is done is in which order. What is p1 in the last example?
>>>>>>
>>>>>> I assume what you mean is after you do this:
>>>>>> leiter.setPerson(p);
>>>>>> session.save(leiter);
>>>>>>
>>>>>> that p is present twice in the db. Is the value of p.id set when p
>>>>>> is added to the leiter (and it has the correct value?)?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Waldi Waldemar wrote:
>>>>>>> Hi Martin,
>>>>>>>
>>>>>>> if i inspect the Person object in the debug mode, the id is set.
>>>>>>> The version I don't see. Is the Version important in this case? I
>>>>>>> can implement it in the Model. My guess is that the AddCommand
>>>>>>> always create a new Object.
>>>>>>>
>>>>>>> The mapping is attached.
>>>>>>>
>>>>>>> If I have a look on the table a Person who i create on this way
>>>>>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>>>>>> p2.setVorname("TestN");
>>>>>>> p2.setNachname("TestV");
>>>>>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>>>>>> a2.setName("Herr");
>>>>>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>>>>>> ge2.setName("Männlich");
>>>>>>> p2.setAnrede(a2);
>>>>>>> p2.setGeschlecht(ge2);
>>>>>>> tx.begin();
>>>>>>> session.save(p1);
>>>>>>> session.save(p2);
>>>>>>> tx.commit();
>>>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>>>>
>>>>>>>
>>>>>>> After the association it is:
>>>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>>>>
>>>>>>>
>>>>>>> Martin Taal schrieb:
>>>>>>>> Hi Waldi,
>>>>>>>> How is the id or version of the Person type mapped to hibernate?
>>>>>>>> (call dataStore.getMappingXML() to get to the mapping xml).
>>>>>>>>
>>>>>>>> Hibernate will typically create a new record/instance in the
>>>>>>>> database if the id or version of the object is not set. Only if
>>>>>>>> the id is set it can detect/query for an existing object in the
>>>>>>>> database and update it. Your example code below does not show
>>>>>>>> how the id is set so I wonder if the issue may be related to that.
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Waldi Waldemar wrote:
>>>>>>>>> I have a problem. The following:
>>>>>>>>>
>>>>>>>>> A list of persons saved in a database table.
>>>>>>>>> This list of persons are viewed in a listViewer
>>>>>>>>>
>>>>>>>>> Now I have leiter and a leiter is a Person.
>>>>>>>>> You can see it here:
>>>>>>>>> Person p = Modelpackage.eInstance.createPerson;
>>>>>>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>>>>>>> l.setPerson(p);
>>>>>>>>>
>>>>>>>>> If i assosiate this two things I execute the command:
>>>>>>>>> (1 Gruppe : N Leiter)
>>>>>>>>>
>>>>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>>>>> le.setPerson(person);
>>>>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>>>>> if (cmd.canExecute()) {
>>>>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> All works fine, but in the database a Person is added and not
>>>>>>>>> updated.
>>>>>>>>>
>>>>>>>>> A list of persons I got on this way:
>>>>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>>>>> String uriStr2 = "hibernate://?" +
>>>>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>>>>> + "testsc&query1=FROM Person";
>>>>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>>>>
>>>>>>>>> In my opinion no data of a person should be change, and if they
>>>>>>>>> change, its ok but dont add someone.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] EMF, Association, Update and Resources [message #430842 is a reply to message #430841] Thu, 11 June 2009 19:06 Go to previous messageGo to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
Yes its complete, you don't need more. For the example program I give
you a response on the next week. On this week I haven't time. The
Problem is that the complete program is a RCP EMF programm based on the
databinding example from Tom Schindl (Library example).... I will look
what i can do...
Can you set up a postgres DB? In this case i can send you the complete
program. Then you can change the login informations... But I think its a
lot of work...

Martin Taal schrieb:
> Yes I can read German no problem :-).
>
> Can you replicate the issue without resources or using AddCommand but
> just doing plain hibernate session.save etc.? If you can then send me
> the test program then I can try it out myself. The ecore you attached is
> complete (I don't need other ecores)?
>
> gr. Martin
>
> Waldi Waldemar wrote:
>> ok, i've attach a snapshot. You can see the values... The problem is
>> the same. Hmm what can I do now? That you can understand the complete
>> thing I've attach the *.ecore. I think you can understand german ;-)
>>
>> Martin Taal schrieb:
>>> Hi Waldi,
>>> Reaction inline, marked with MT>>
>>>
>>> So after saving the resource, the id of the person has changed
>>> (in-memory)?
>>>
>>> Yes it is best to have a version eattribute anyway, so if you can
>>> model that and annotate it with @Version.
>>> Then let me know if the problem is still there (or not...hopefully).
>>>
>>> gr. Martin
>>>
>>> Waldi Waldemar wrote:
>>>> answers below
>>>> Martin Taal schrieb:
>>>>> Hi Waldi,
>>>>> Okay, is the person instance you load from the database the exact
>>>>> same object instance which is set in leiter (can you check after
>>>>> the save has been done)?
>>>> Yes it's the same object instance.
>>>> No, I can't check. I can check it till Command cmd =
>>>> AddCommand.create(p.getEditingDomain(), gruppe,
>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>> Till this all attributes are the same as in the database.
>>>>
>>>>> I ask because in your hibernate mapping you have a so-called
>>>>> 'synthetic version', this is done by Teneo if there is no explicit
>>>>> version eattribute present.
>>>> Ok that can be the failure. Now i should model a version attribute
>>>> and add a annotation on it that i can see on the runtime the actual
>>>> version of the object?
>>>>
>>>>> However, this version eattribute works only with object instance
>>>>> equality.
>>>> What mean it exactly?
>>> MT>> The synthetic version logic is implemented in the
>>> IdentifierCacheHandler. That handler compares objects like this: o1
>>> == o2 to find the version of an eobject.
>>>
>>>>
>>>>> I am not sure either what the AddCommand exactly performs, at what
>>>>> point does the actual save occur?
>>>> I don't understand this question. The save is done with Strg+S and
>>>> it execute resource.save - this save all what is in the command stack.
>>> MT>> Okay when the resource is saved
>>>
>>>>
>>>>
>>>>> gr. Martin
>>>>>
>>>>> Waldi Waldemar wrote:
>>>>>> Ok, sorry for this a little bit strange things. In order I do:
>>>>>> 1. Create some example data's - all is ok
>>>>>> 2. Load all Persons from the Table - like: - all is ok
>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>> String uriStr2 = "hibernate://?" +
>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>> + "testsc&query1=FROM Person";
>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>
>>>>>> 3. Then I take the selecten of the ListViewer and add the selected
>>>>>> person to the model on this way:
>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>> le.setPerson(person);
>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>> if (cmd.canExecute()) {
>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>
>>>>>> 4. And now in my Database are two same persons. The difference is:
>>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>>> - Create Person on the normal way like in you qick start example
>>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>>> - This Person is created by the AddCommand.....
>>>>>>
>>>>>> I delete the database and recreate it. When I have a look on the
>>>>>> variables.... All ID's are setted and correct: The Gruppe ID is 3,
>>>>>> The Leiter ID is null (because its new) the Person ID in the
>>>>>> Leiter is 8 and the Person id is 8
>>>>>>
>>>>>> Hope this helps
>>>>>>
>>>>>>
>>>>>>
>>>>>> Martin Taal schrieb:
>>>>>>> Hi Waldi,
>>>>>>> Before looking at version first lets be sure that not something
>>>>>>> else is in the way.
>>>>>>>
>>>>>>> I am sorry but as there are different code snippets I don't know
>>>>>>> what is done is in which order. What is p1 in the last example?
>>>>>>>
>>>>>>> I assume what you mean is after you do this:
>>>>>>> leiter.setPerson(p);
>>>>>>> session.save(leiter);
>>>>>>>
>>>>>>> that p is present twice in the db. Is the value of p.id set when
>>>>>>> p is added to the leiter (and it has the correct value?)?
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Waldi Waldemar wrote:
>>>>>>>> Hi Martin,
>>>>>>>>
>>>>>>>> if i inspect the Person object in the debug mode, the id is set.
>>>>>>>> The version I don't see. Is the Version important in this case?
>>>>>>>> I can implement it in the Model. My guess is that the AddCommand
>>>>>>>> always create a new Object.
>>>>>>>>
>>>>>>>> The mapping is attached.
>>>>>>>>
>>>>>>>> If I have a look on the table a Person who i create on this way
>>>>>>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>>>>>>> p2.setVorname("TestN");
>>>>>>>> p2.setNachname("TestV");
>>>>>>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>>>>>>> a2.setName("Herr");
>>>>>>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>>>>>>> ge2.setName("Männlich");
>>>>>>>> p2.setAnrede(a2);
>>>>>>>> p2.setGeschlecht(ge2);
>>>>>>>> tx.begin();
>>>>>>>> session.save(p1);
>>>>>>>> session.save(p2);
>>>>>>>> tx.commit();
>>>>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>>>>>
>>>>>>>>
>>>>>>>> After the association it is:
>>>>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>>>>>
>>>>>>>>
>>>>>>>> Martin Taal schrieb:
>>>>>>>>> Hi Waldi,
>>>>>>>>> How is the id or version of the Person type mapped to
>>>>>>>>> hibernate? (call dataStore.getMappingXML() to get to the
>>>>>>>>> mapping xml).
>>>>>>>>>
>>>>>>>>> Hibernate will typically create a new record/instance in the
>>>>>>>>> database if the id or version of the object is not set. Only if
>>>>>>>>> the id is set it can detect/query for an existing object in the
>>>>>>>>> database and update it. Your example code below does not show
>>>>>>>>> how the id is set so I wonder if the issue may be related to that.
>>>>>>>>>
>>>>>>>>> gr. Martin
>>>>>>>>>
>>>>>>>>> Waldi Waldemar wrote:
>>>>>>>>>> I have a problem. The following:
>>>>>>>>>>
>>>>>>>>>> A list of persons saved in a database table.
>>>>>>>>>> This list of persons are viewed in a listViewer
>>>>>>>>>>
>>>>>>>>>> Now I have leiter and a leiter is a Person.
>>>>>>>>>> You can see it here:
>>>>>>>>>> Person p = Modelpackage.eInstance.createPerson;
>>>>>>>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>>>>>>>> l.setPerson(p);
>>>>>>>>>>
>>>>>>>>>> If i assosiate this two things I execute the command:
>>>>>>>>>> (1 Gruppe : N Leiter)
>>>>>>>>>>
>>>>>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>>>>>> le.setPerson(person);
>>>>>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>>>>>> if (cmd.canExecute()) {
>>>>>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> All works fine, but in the database a Person is added and not
>>>>>>>>>> updated.
>>>>>>>>>>
>>>>>>>>>> A list of persons I got on this way:
>>>>>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>>>>>> String uriStr2 = "hibernate://?" +
>>>>>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>>>>>> + "testsc&query1=FROM Person";
>>>>>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>>>>>
>>>>>>>>>> In my opinion no data of a person should be change, and if
>>>>>>>>>> they change, its ok but dont add someone.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>>
>
>
Re: [TENEO] EMF, Association, Update and Resources [message #430843 is a reply to message #430842] Thu, 11 June 2009 21:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
If you want you can enter a bugzilla for this then we have something to track this possible issue. If you can attach the
ecore and any other information you may have that would be helpfull.

gr. Martin

Waldi Waldemar wrote:
> Yes its complete, you don't need more. For the example program I give
> you a response on the next week. On this week I haven't time. The
> Problem is that the complete program is a RCP EMF programm based on the
> databinding example from Tom Schindl (Library example).... I will look
> what i can do...
> Can you set up a postgres DB? In this case i can send you the complete
> program. Then you can change the login informations... But I think its a
> lot of work...
>
> Martin Taal schrieb:
>> Yes I can read German no problem :-).
>>
>> Can you replicate the issue without resources or using AddCommand but
>> just doing plain hibernate session.save etc.? If you can then send me
>> the test program then I can try it out myself. The ecore you attached
>> is complete (I don't need other ecores)?
>>
>> gr. Martin
>>
>> Waldi Waldemar wrote:
>>> ok, i've attach a snapshot. You can see the values... The problem is
>>> the same. Hmm what can I do now? That you can understand the complete
>>> thing I've attach the *.ecore. I think you can understand german ;-)
>>>
>>> Martin Taal schrieb:
>>>> Hi Waldi,
>>>> Reaction inline, marked with MT>>
>>>>
>>>> So after saving the resource, the id of the person has changed
>>>> (in-memory)?
>>>>
>>>> Yes it is best to have a version eattribute anyway, so if you can
>>>> model that and annotate it with @Version.
>>>> Then let me know if the problem is still there (or not...hopefully).
>>>>
>>>> gr. Martin
>>>>
>>>> Waldi Waldemar wrote:
>>>>> answers below
>>>>> Martin Taal schrieb:
>>>>>> Hi Waldi,
>>>>>> Okay, is the person instance you load from the database the exact
>>>>>> same object instance which is set in leiter (can you check after
>>>>>> the save has been done)?
>>>>> Yes it's the same object instance.
>>>>> No, I can't check. I can check it till Command cmd =
>>>>> AddCommand.create(p.getEditingDomain(), gruppe,
>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>> Till this all attributes are the same as in the database.
>>>>>
>>>>>> I ask because in your hibernate mapping you have a so-called
>>>>>> 'synthetic version', this is done by Teneo if there is no explicit
>>>>>> version eattribute present.
>>>>> Ok that can be the failure. Now i should model a version attribute
>>>>> and add a annotation on it that i can see on the runtime the actual
>>>>> version of the object?
>>>>>
>>>>>> However, this version eattribute works only with object instance
>>>>>> equality.
>>>>> What mean it exactly?
>>>> MT>> The synthetic version logic is implemented in the
>>>> IdentifierCacheHandler. That handler compares objects like this: o1
>>>> == o2 to find the version of an eobject.
>>>>
>>>>>
>>>>>> I am not sure either what the AddCommand exactly performs, at what
>>>>>> point does the actual save occur?
>>>>> I don't understand this question. The save is done with Strg+S and
>>>>> it execute resource.save - this save all what is in the command stack.
>>>> MT>> Okay when the resource is saved
>>>>
>>>>>
>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Waldi Waldemar wrote:
>>>>>>> Ok, sorry for this a little bit strange things. In order I do:
>>>>>>> 1. Create some example data's - all is ok
>>>>>>> 2. Load all Persons from the Table - like: - all is ok
>>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>>> String uriStr2 = "hibernate://?" +
>>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>>> + "testsc&query1=FROM Person";
>>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>>
>>>>>>> 3. Then I take the selecten of the ListViewer and add the
>>>>>>> selected person to the model on this way:
>>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>>> le.setPerson(person);
>>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>>> if (cmd.canExecute()) {
>>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>>
>>>>>>> 4. And now in my Database are two same persons. The difference is:
>>>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>>>> - Create Person on the normal way like in you qick start example
>>>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>>>> - This Person is created by the AddCommand.....
>>>>>>>
>>>>>>> I delete the database and recreate it. When I have a look on the
>>>>>>> variables.... All ID's are setted and correct: The Gruppe ID is
>>>>>>> 3, The Leiter ID is null (because its new) the Person ID in the
>>>>>>> Leiter is 8 and the Person id is 8
>>>>>>>
>>>>>>> Hope this helps
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Martin Taal schrieb:
>>>>>>>> Hi Waldi,
>>>>>>>> Before looking at version first lets be sure that not something
>>>>>>>> else is in the way.
>>>>>>>>
>>>>>>>> I am sorry but as there are different code snippets I don't know
>>>>>>>> what is done is in which order. What is p1 in the last example?
>>>>>>>>
>>>>>>>> I assume what you mean is after you do this:
>>>>>>>> leiter.setPerson(p);
>>>>>>>> session.save(leiter);
>>>>>>>>
>>>>>>>> that p is present twice in the db. Is the value of p.id set when
>>>>>>>> p is added to the leiter (and it has the correct value?)?
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Waldi Waldemar wrote:
>>>>>>>>> Hi Martin,
>>>>>>>>>
>>>>>>>>> if i inspect the Person object in the debug mode, the id is
>>>>>>>>> set. The version I don't see. Is the Version important in this
>>>>>>>>> case? I can implement it in the Model. My guess is that the
>>>>>>>>> AddCommand always create a new Object.
>>>>>>>>>
>>>>>>>>> The mapping is attached.
>>>>>>>>>
>>>>>>>>> If I have a look on the table a Person who i create on this way
>>>>>>>>> Person p2 = ZlvpFactory.eINSTANCE.createPerson();
>>>>>>>>> p2.setVorname("TestN");
>>>>>>>>> p2.setNachname("TestV");
>>>>>>>>> Anrede a2 = ZlvpFactory.eINSTANCE.createAnrede();
>>>>>>>>> a2.setName("Herr");
>>>>>>>>> Geschlecht ge2 = ZlvpFactory.eINSTANCE.createGeschlecht();
>>>>>>>>> ge2.setName("Männlich");
>>>>>>>>> p2.setAnrede(a2);
>>>>>>>>> p2.setGeschlecht(ge2);
>>>>>>>>> tx.begin();
>>>>>>>>> session.save(p1);
>>>>>>>>> session.save(p2);
>>>>>>>>> tx.commit();
>>>>>>>>> 11;"Person";0;"TestN";"TestV";"";"";"";"";"";""; "";"";12;13;;;"";"";""
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> After the association it is:
>>>>>>>>> 5;"Person";6;"TestN";"TestV";"";"";"";"";"";"";" ";"";6;7;;;"Leiter";"4";"http://zlvp/1.0_;_Leiter_;_http://zlvp/1.0_;_Leiter_;_person"
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Martin Taal schrieb:
>>>>>>>>>> Hi Waldi,
>>>>>>>>>> How is the id or version of the Person type mapped to
>>>>>>>>>> hibernate? (call dataStore.getMappingXML() to get to the
>>>>>>>>>> mapping xml).
>>>>>>>>>>
>>>>>>>>>> Hibernate will typically create a new record/instance in the
>>>>>>>>>> database if the id or version of the object is not set. Only
>>>>>>>>>> if the id is set it can detect/query for an existing object in
>>>>>>>>>> the database and update it. Your example code below does not
>>>>>>>>>> show how the id is set so I wonder if the issue may be related
>>>>>>>>>> to that.
>>>>>>>>>>
>>>>>>>>>> gr. Martin
>>>>>>>>>>
>>>>>>>>>> Waldi Waldemar wrote:
>>>>>>>>>>> I have a problem. The following:
>>>>>>>>>>>
>>>>>>>>>>> A list of persons saved in a database table.
>>>>>>>>>>> This list of persons are viewed in a listViewer
>>>>>>>>>>>
>>>>>>>>>>> Now I have leiter and a leiter is a Person.
>>>>>>>>>>> You can see it here:
>>>>>>>>>>> Person p = Modelpackage.eInstance.createPerson;
>>>>>>>>>>> Leiter l = Modelpackage.eInstance.createLeiter;
>>>>>>>>>>> l.setPerson(p);
>>>>>>>>>>>
>>>>>>>>>>> If i assosiate this two things I execute the command:
>>>>>>>>>>> (1 Gruppe : N Leiter)
>>>>>>>>>>>
>>>>>>>>>>> Leiter le = ZlvpFactory.eINSTANCE.createLeiter();
>>>>>>>>>>> le.setPerson(person);
>>>>>>>>>>> Command cmd = AddCommand.create(p.getEditingDomain(), gruppe,
>>>>>>>>>>> ZlvpPackage.Literals.GRUPPEN__LEITER, le);
>>>>>>>>>>> if (cmd.canExecute()) {
>>>>>>>>>>> p.getEditingDomain().getCommandStack().execute(cmd);
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> All works fine, but in the database a Person is added and not
>>>>>>>>>>> updated.
>>>>>>>>>>>
>>>>>>>>>>> A list of persons I got on this way:
>>>>>>>>>>> SessionController.registerSessionController("testsc", sc);
>>>>>>>>>>> String uriStr2 = "hibernate://?" +
>>>>>>>>>>> HibernateResource.SESSION_CONTROLLER_PARAM + "="
>>>>>>>>>>> + "testsc&query1=FROM Person";
>>>>>>>>>>> final URI uri2 = URI.createURI(uriStr2);
>>>>>>>>>>> resPerson = getResourceSet().createResource(uri2);
>>>>>>>>>>> resPerson.load(Collections.EMPTY_MAP);
>>>>>>>>>>>
>>>>>>>>>>> In my opinion no data of a person should be change, and if
>>>>>>>>>>> they change, its ok but dont add someone.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] EMF, Association, Update and Resources [message #430885 is a reply to message #430843] Tue, 16 June 2009 07:10 Go to previous message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
See @ http://bugs.eclipse.org/280355
Previous Topic:Re: newbie question - linking existing database repository to DSL
Next Topic:[TENEO] Problem persisting models obtained from xsd with wildcards (any)
Goto Forum:
  


Current Time: Fri Apr 26 07:33:34 GMT 2024

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

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

Back to the top