Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Can't persist reference when EOpposite is set.
[Teneo] Can't persist reference when EOpposite is set. [message #125318] Fri, 06 June 2008 21:18 Go to next message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
Hi,

I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have this
issue where the relation between 2 object is not persisted when both
object`s reference to each other has their EOpposite set to each other.

ex:
A Book.author is referring [1] to an Author, with EOpposite set to
Author.book
An Author is referring [1 to *] to Book, and with an EOpposite set to
Book.author

When I set the author of the book, then persist the book (and author
through cascading) and commit, the author and the book are persisted but
the relation between the twos is not.

Any idea why from this brief description?

If not, I will try to provide a sample.

Regards
François
Re: [Teneo] Can't persist reference when EOpposite is set. [message #125636 is a reply to message #125318] Tue, 10 June 2008 17:49 Go to previous messageGo to next message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------020109020602020908070806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Martin,

I was able to reproduce it. The problem is caused by the order in which
the EClass are declared in the genmodel.

In the test case I attached:
Person has 1 Team
Team has 0 to Many Person.

Person eOpposite is team.members.
Team eOpposite is Person.team

In the model description, if Person is declared before Team. The column
"person_team_e_id" from the "person" table is correctly set to an id
from the team.members table.

The problem rise when Team is declared before Person. In this case the
column "person_team_e_id" from "person" table is always set to null.
This cause the person.getTeam() call to always return null.

To go from a working to failing state, simply change the order of the 2
EClass and restart the application.

Is there anyway to fix that issue without changing the order of the
EClass, it maybe impossible to do for me because my EClasses are from
different package.

Fran
Re: [Teneo] Can't persist reference when EOpposite is set. [message #125681 is a reply to message #125636] Wed, 11 June 2008 06:21 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi François,
A special issue for sure. I will probably have time tomorrow to look at this in more detail.

gr. Martin

François M. wrote:
> Hi Martin,
>
> I was able to reproduce it. The problem is caused by the order in which
> the EClass are declared in the genmodel.
>
> In the test case I attached:
> Person has 1 Team
> Team has 0 to Many Person.
>
> Person eOpposite is team.members.
> Team eOpposite is Person.team
>
> In the model description, if Person is declared before Team. The column
> "person_team_e_id" from the "person" table is correctly set to an id
> from the team.members table.
>
> The problem rise when Team is declared before Person. In this case the
> column "person_team_e_id" from "person" table is always set to null.
> This cause the person.getTeam() call to always return null.
>
> To go from a working to failing state, simply change the order of the 2
> EClass and restart the application.
>
> Is there anyway to fix that issue without changing the order of the
> EClass, it maybe impossible to do for me because my EClasses are from
> different package.
>
> François
>
>
>
>
> François M. wrote:
>> Hi,
>>
>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>> this issue where the relation between 2 object is not persisted when
>> both object`s reference to each other has their EOpposite set to each
>> other.
>>
>> ex:
>> A Book.author is referring [1] to an Author, with EOpposite set to
>> Author.book
>> An Author is referring [1 to *] to Book, and with an EOpposite set to
>> Book.author
>>
>> When I set the author of the book, then persist the book (and author
>> through cascading) and commit, the author and the book are persisted
>> but the relation between the twos is not.
>>
>> Any idea why from this brief description?
>>
>> If not, I will try to provide a sample.
>>
>> Regards
>> François
>


--

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] Can't persist reference when EOpposite is set. [message #125960 is a reply to message #125636] Sat, 14 June 2008 22:23 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi François,
I tried your testcase but I could not reproduce the exception. Maybe I misunderstood you, I
exchanged the order of Team and Person several times in the ecore file. Each time I started with an
empty database and all the time the test passed.

Can you try again?

gr. Martin

François M. wrote:
> Hi Martin,
>
> I was able to reproduce it. The problem is caused by the order in which
> the EClass are declared in the genmodel.
>
> In the test case I attached:
> Person has 1 Team
> Team has 0 to Many Person.
>
> Person eOpposite is team.members.
> Team eOpposite is Person.team
>
> In the model description, if Person is declared before Team. The column
> "person_team_e_id" from the "person" table is correctly set to an id
> from the team.members table.
>
> The problem rise when Team is declared before Person. In this case the
> column "person_team_e_id" from "person" table is always set to null.
> This cause the person.getTeam() call to always return null.
>
> To go from a working to failing state, simply change the order of the 2
> EClass and restart the application.
>
> Is there anyway to fix that issue without changing the order of the
> EClass, it maybe impossible to do for me because my EClasses are from
> different package.
>
> François
>
>
>
>
> François M. wrote:
>> Hi,
>>
>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>> this issue where the relation between 2 object is not persisted when
>> both object`s reference to each other has their EOpposite set to each
>> other.
>>
>> ex:
>> A Book.author is referring [1] to an Author, with EOpposite set to
>> Author.book
>> An Author is referring [1 to *] to Book, and with an EOpposite set to
>> Book.author
>>
>> When I set the author of the book, then persist the book (and author
>> through cascading) and commit, the author and the book are persisted
>> but the relation between the twos is not.
>>
>> Any idea why from this brief description?
>>
>> If not, I will try to provide a sample.
>>
>> Regards
>> François
>


--

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] Can't persist reference when EOpposite is set. [message #125973 is a reply to message #125960] Mon, 16 June 2008 12:35 Go to previous messageGo to next message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
I confirm that I get the issue.
After I move the declaration of Team before the declaration of Person in
the ecore, I save the ecore, and reload the genmodel from the ecore,
then I "Generate the model code". I run the same test case and my
person_team_e_id is set to NULL.


When Person is defined first:

mysql> select * from person;
+------+--------+-----------+---------+---------+----------- -------+
| e_id | dtype | e_version | name | section | person_team_e_id |
+------+--------+-----------+---------+---------+----------- -------+
| 1 | Person | 0 | LaPoune | NULL | 1 |
+------+--------+-----------+---------+---------+----------- -------+
1 row in set (0.00 sec)




When Team is defined first:

mysql> select * from person;
+------+--------+-----------+---------+---------+----------- -------+
| e_id | dtype | e_version | name | section | person_team_e_id |
+------+--------+-----------+---------+---------+----------- -------+
| 1 | Person | 0 | LaPoune | NULL | NULL |
+------+--------+-----------+---------+---------+----------- -------+
1 row in set (0.00 sec)


Martin Taal wrote:
> Hi François,
> I tried your testcase but I could not reproduce the exception. Maybe I
> misunderstood you, I exchanged the order of Team and Person several
> times in the ecore file. Each time I started with an empty database and
> all the time the test passed.
>
> Can you try again?
>
> gr. Martin
>
> François M. wrote:
>> Hi Martin,
>>
>> I was able to reproduce it. The problem is caused by the order in
>> which the EClass are declared in the genmodel.
>>
>> In the test case I attached:
>> Person has 1 Team
>> Team has 0 to Many Person.
>>
>> Person eOpposite is team.members.
>> Team eOpposite is Person.team
>>
>> In the model description, if Person is declared before Team. The
>> column "person_team_e_id" from the "person" table is correctly set to
>> an id from the team.members table.
>>
>> The problem rise when Team is declared before Person. In this case the
>> column "person_team_e_id" from "person" table is always set to null.
>> This cause the person.getTeam() call to always return null.
>>
>> To go from a working to failing state, simply change the order of the
>> 2 EClass and restart the application.
>>
>> Is there anyway to fix that issue without changing the order of the
>> EClass, it maybe impossible to do for me because my EClasses are from
>> different package.
>>
>> François
>>
>>
>>
>>
>> François M. wrote:
>>> Hi,
>>>
>>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>>> this issue where the relation between 2 object is not persisted when
>>> both object`s reference to each other has their EOpposite set to each
>>> other.
>>>
>>> ex:
>>> A Book.author is referring [1] to an Author, with EOpposite set to
>>> Author.book
>>> An Author is referring [1 to *] to Book, and with an EOpposite set to
>>> Book.author
>>>
>>> When I set the author of the book, then persist the book (and author
>>> through cascading) and commit, the author and the book are persisted
>>> but the relation between the twos is not.
>>>
>>> Any idea why from this brief description?
>>>
>>> If not, I will try to provide a sample.
>>>
>>> Regards
>>> François
>>
>
>
Re: [Teneo] Can't persist reference when EOpposite is set. [message #125990 is a reply to message #125973] Mon, 16 June 2008 12:49 Go to previous messageGo to next message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------040500090007040406050003
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

I modified the test case so that it actually shows the problem without
requiring you to do a manual query to the database.

When Team is defined first: you should get a null pointer exception
because person.getTeam() return null.




Fran
Re: [Teneo] Can't persist reference when EOpposite is set. [message #126003 is a reply to message #125960] Mon, 16 June 2008 12:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stapounch.hotmail.com

This is a multi-part message in MIME format.
--------------050900090501070003080605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Martin,

When the code runs, no errors are generated. But...

What I did to reproduce the problem, was simply to change the order,
declare Team before Person, reload the genmodel, regenerate the model
code, run my test case and voil
Re: [Teneo] Can't persist reference when EOpposite is set. [message #126017 is a reply to message #126003] Mon, 16 June 2008 21:25 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Luc/Francois,
Yes, I should have looked in the db with your previous testcase...
Using your last testcase I could re-produce this. It showed that bidirectional lists with jointables
do not work well in all cases. In addition Hibernate does not support bi-directional lists.
Therefore Teneo maps them as two independent relations: one-to-many with a join-table and
many-to-one (with a fk) for the other side.

I made some changes in the code to handle this better. This will be in a new build.

As a workaround (for now) you can set a @OneToMany(indexed=false) on the members efeature. Let me
know if this works.

Btw, as Teneo is graduating to 1.0.0 it will move to the main EMF newsgroup. I have cross-posted
there so we can continue the thread there.

gr. Martin

Luc wrote:
> Hi Martin,
>
> When the code runs, no errors are generated. But...
>
> What I did to reproduce the problem, was simply to change the order,
> declare Team before Person, reload the genmodel, regenerate the model
> code, run my test case and voilà, the "person_team_e_id" is gone, see
> below (with attached softball.ecore.bad):
>
> mysql> select e_id, dtype, person_team_e_id from person;
> +------+--------+------------------+
> | e_id | dtype | person_team_e_id |
> +------+--------+------------------+
> | 1 | Person | NULL |
> +------+--------+------------------+
>
>
> mysql> select e_id, dtype from team;
> +------+-------+
> | e_id | dtype |
> +------+-------+
> | 1 | Team |
> +------+-------+
>
> Yet when I declare Person before Team, reload the genmodel, regenerate
> the model code, run my test case, the "person_team_e_id" is set to 1,
> see below (with attached softball.ecore.good):
>
> mysql> select e_id, dtype, person_team_e_id from person;
> +------+--------+------------------+
> | e_id | dtype | person_team_e_id |
> +------+--------+------------------+
> | 1 | Person | 1 |
> +------+--------+------------------+
>
>
> mysql> select e_id, dtype from team;
> +------+-------+
> | e_id | dtype |
> +------+-------+
> | 1 | Team |
> +------+-------+
>
> Thanks for your help!
>
> Luc
>
> Martin Taal wrote:
>> Hi François,
>> I tried your testcase but I could not reproduce the exception. Maybe I
>> misunderstood you, I exchanged the order of Team and Person several
>> times in the ecore file. Each time I started with an empty database
>> and all the time the test passed.
>>
>> Can you try again?
>>
>> gr. Martin
>>
>> François M. wrote:
>>> Hi Martin,
>>>
>>> I was able to reproduce it. The problem is caused by the order in
>>> which the EClass are declared in the genmodel.
>>>
>>> In the test case I attached:
>>> Person has 1 Team
>>> Team has 0 to Many Person.
>>>
>>> Person eOpposite is team.members.
>>> Team eOpposite is Person.team
>>>
>>> In the model description, if Person is declared before Team. The
>>> column "person_team_e_id" from the "person" table is correctly set to
>>> an id from the team.members table.
>>>
>>> The problem rise when Team is declared before Person. In this case
>>> the column "person_team_e_id" from "person" table is always set to
>>> null. This cause the person.getTeam() call to always return null.
>>>
>>> To go from a working to failing state, simply change the order of the
>>> 2 EClass and restart the application.
>>>
>>> Is there anyway to fix that issue without changing the order of the
>>> EClass, it maybe impossible to do for me because my EClasses are from
>>> different package.
>>>
>>> François
>>>
>>>
>>>
>>>
>>> François M. wrote:
>>>> Hi,
>>>>
>>>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>>>> this issue where the relation between 2 object is not persisted when
>>>> both object`s reference to each other has their EOpposite set to
>>>> each other.
>>>>
>>>> ex:
>>>> A Book.author is referring [1] to an Author, with EOpposite set to
>>>> Author.book
>>>> An Author is referring [1 to *] to Book, and with an EOpposite set
>>>> to Book.author
>>>>
>>>> When I set the author of the book, then persist the book (and author
>>>> through cascading) and commit, the author and the book are persisted
>>>> but the relation between the twos is not.
>>>>
>>>> Any idea why from this brief description?
>>>>
>>>> If not, I will try to provide a sample.
>>>>
>>>> Regards
>>>> François
>>>
>>
>>


--

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] Can't persist reference when EOpposite is set. [message #619229 is a reply to message #125318] Tue, 10 June 2008 17:49 Go to previous message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------020109020602020908070806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Martin,

I was able to reproduce it. The problem is caused by the order in which
the EClass are declared in the genmodel.

In the test case I attached:
Person has 1 Team
Team has 0 to Many Person.

Person eOpposite is team.members.
Team eOpposite is Person.team

In the model description, if Person is declared before Team. The column
"person_team_e_id" from the "person" table is correctly set to an id
from the team.members table.

The problem rise when Team is declared before Person. In this case the
column "person_team_e_id" from "person" table is always set to null.
This cause the person.getTeam() call to always return null.

To go from a working to failing state, simply change the order of the 2
EClass and restart the application.

Is there anyway to fix that issue without changing the order of the
EClass, it maybe impossible to do for me because my EClasses are from
different package.

Fran
Re: [Teneo] Can't persist reference when EOpposite is set. [message #619232 is a reply to message #125636] Wed, 11 June 2008 06:21 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi François,
A special issue for sure. I will probably have time tomorrow to look at this in more detail.

gr. Martin

François M. wrote:
> Hi Martin,
>
> I was able to reproduce it. The problem is caused by the order in which
> the EClass are declared in the genmodel.
>
> In the test case I attached:
> Person has 1 Team
> Team has 0 to Many Person.
>
> Person eOpposite is team.members.
> Team eOpposite is Person.team
>
> In the model description, if Person is declared before Team. The column
> "person_team_e_id" from the "person" table is correctly set to an id
> from the team.members table.
>
> The problem rise when Team is declared before Person. In this case the
> column "person_team_e_id" from "person" table is always set to null.
> This cause the person.getTeam() call to always return null.
>
> To go from a working to failing state, simply change the order of the 2
> EClass and restart the application.
>
> Is there anyway to fix that issue without changing the order of the
> EClass, it maybe impossible to do for me because my EClasses are from
> different package.
>
> François
>
>
>
>
> François M. wrote:
>> Hi,
>>
>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>> this issue where the relation between 2 object is not persisted when
>> both object`s reference to each other has their EOpposite set to each
>> other.
>>
>> ex:
>> A Book.author is referring [1] to an Author, with EOpposite set to
>> Author.book
>> An Author is referring [1 to *] to Book, and with an EOpposite set to
>> Book.author
>>
>> When I set the author of the book, then persist the book (and author
>> through cascading) and commit, the author and the book are persisted
>> but the relation between the twos is not.
>>
>> Any idea why from this brief description?
>>
>> If not, I will try to provide a sample.
>>
>> Regards
>> François
>


--

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] Can't persist reference when EOpposite is set. [message #619253 is a reply to message #125636] Sat, 14 June 2008 22:23 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi François,
I tried your testcase but I could not reproduce the exception. Maybe I misunderstood you, I
exchanged the order of Team and Person several times in the ecore file. Each time I started with an
empty database and all the time the test passed.

Can you try again?

gr. Martin

François M. wrote:
> Hi Martin,
>
> I was able to reproduce it. The problem is caused by the order in which
> the EClass are declared in the genmodel.
>
> In the test case I attached:
> Person has 1 Team
> Team has 0 to Many Person.
>
> Person eOpposite is team.members.
> Team eOpposite is Person.team
>
> In the model description, if Person is declared before Team. The column
> "person_team_e_id" from the "person" table is correctly set to an id
> from the team.members table.
>
> The problem rise when Team is declared before Person. In this case the
> column "person_team_e_id" from "person" table is always set to null.
> This cause the person.getTeam() call to always return null.
>
> To go from a working to failing state, simply change the order of the 2
> EClass and restart the application.
>
> Is there anyway to fix that issue without changing the order of the
> EClass, it maybe impossible to do for me because my EClasses are from
> different package.
>
> François
>
>
>
>
> François M. wrote:
>> Hi,
>>
>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>> this issue where the relation between 2 object is not persisted when
>> both object`s reference to each other has their EOpposite set to each
>> other.
>>
>> ex:
>> A Book.author is referring [1] to an Author, with EOpposite set to
>> Author.book
>> An Author is referring [1 to *] to Book, and with an EOpposite set to
>> Book.author
>>
>> When I set the author of the book, then persist the book (and author
>> through cascading) and commit, the author and the book are persisted
>> but the relation between the twos is not.
>>
>> Any idea why from this brief description?
>>
>> If not, I will try to provide a sample.
>>
>> Regards
>> François
>


--

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] Can't persist reference when EOpposite is set. [message #619254 is a reply to message #125960] Mon, 16 June 2008 12:35 Go to previous message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
I confirm that I get the issue.
After I move the declaration of Team before the declaration of Person in
the ecore, I save the ecore, and reload the genmodel from the ecore,
then I "Generate the model code". I run the same test case and my
person_team_e_id is set to NULL.


When Person is defined first:

mysql> select * from person;
+------+--------+-----------+---------+---------+----------- -------+
| e_id | dtype | e_version | name | section | person_team_e_id |
+------+--------+-----------+---------+---------+----------- -------+
| 1 | Person | 0 | LaPoune | NULL | 1 |
+------+--------+-----------+---------+---------+----------- -------+
1 row in set (0.00 sec)




When Team is defined first:

mysql> select * from person;
+------+--------+-----------+---------+---------+----------- -------+
| e_id | dtype | e_version | name | section | person_team_e_id |
+------+--------+-----------+---------+---------+----------- -------+
| 1 | Person | 0 | LaPoune | NULL | NULL |
+------+--------+-----------+---------+---------+----------- -------+
1 row in set (0.00 sec)


Martin Taal wrote:
> Hi François,
> I tried your testcase but I could not reproduce the exception. Maybe I
> misunderstood you, I exchanged the order of Team and Person several
> times in the ecore file. Each time I started with an empty database and
> all the time the test passed.
>
> Can you try again?
>
> gr. Martin
>
> François M. wrote:
>> Hi Martin,
>>
>> I was able to reproduce it. The problem is caused by the order in
>> which the EClass are declared in the genmodel.
>>
>> In the test case I attached:
>> Person has 1 Team
>> Team has 0 to Many Person.
>>
>> Person eOpposite is team.members.
>> Team eOpposite is Person.team
>>
>> In the model description, if Person is declared before Team. The
>> column "person_team_e_id" from the "person" table is correctly set to
>> an id from the team.members table.
>>
>> The problem rise when Team is declared before Person. In this case the
>> column "person_team_e_id" from "person" table is always set to null.
>> This cause the person.getTeam() call to always return null.
>>
>> To go from a working to failing state, simply change the order of the
>> 2 EClass and restart the application.
>>
>> Is there anyway to fix that issue without changing the order of the
>> EClass, it maybe impossible to do for me because my EClasses are from
>> different package.
>>
>> François
>>
>>
>>
>>
>> François M. wrote:
>>> Hi,
>>>
>>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>>> this issue where the relation between 2 object is not persisted when
>>> both object`s reference to each other has their EOpposite set to each
>>> other.
>>>
>>> ex:
>>> A Book.author is referring [1] to an Author, with EOpposite set to
>>> Author.book
>>> An Author is referring [1 to *] to Book, and with an EOpposite set to
>>> Book.author
>>>
>>> When I set the author of the book, then persist the book (and author
>>> through cascading) and commit, the author and the book are persisted
>>> but the relation between the twos is not.
>>>
>>> Any idea why from this brief description?
>>>
>>> If not, I will try to provide a sample.
>>>
>>> Regards
>>> François
>>
>
>
Re: [Teneo] Can't persist reference when EOpposite is set. [message #619255 is a reply to message #125973] Mon, 16 June 2008 12:49 Go to previous message
Francois is currently offline FrancoisFriend
Messages: 17
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------040500090007040406050003
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

I modified the test case so that it actually shows the problem without
requiring you to do a manual query to the database.

When Team is defined first: you should get a null pointer exception
because person.getTeam() return null.




Fran
Re: [Teneo] Can't persist reference when EOpposite is set. [message #619256 is a reply to message #125960] Mon, 16 June 2008 12:57 Go to previous message
Luc is currently offline LucFriend
Messages: 4
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------050900090501070003080605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Martin,

When the code runs, no errors are generated. But...

What I did to reproduce the problem, was simply to change the order,
declare Team before Person, reload the genmodel, regenerate the model
code, run my test case and voil
Re: [Teneo] Can't persist reference when EOpposite is set. [message #619257 is a reply to message #126003] Mon, 16 June 2008 21:25 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Luc/Francois,
Yes, I should have looked in the db with your previous testcase...
Using your last testcase I could re-produce this. It showed that bidirectional lists with jointables
do not work well in all cases. In addition Hibernate does not support bi-directional lists.
Therefore Teneo maps them as two independent relations: one-to-many with a join-table and
many-to-one (with a fk) for the other side.

I made some changes in the code to handle this better. This will be in a new build.

As a workaround (for now) you can set a @OneToMany(indexed=false) on the members efeature. Let me
know if this works.

Btw, as Teneo is graduating to 1.0.0 it will move to the main EMF newsgroup. I have cross-posted
there so we can continue the thread there.

gr. Martin

Luc wrote:
> Hi Martin,
>
> When the code runs, no errors are generated. But...
>
> What I did to reproduce the problem, was simply to change the order,
> declare Team before Person, reload the genmodel, regenerate the model
> code, run my test case and voilà, the "person_team_e_id" is gone, see
> below (with attached softball.ecore.bad):
>
> mysql> select e_id, dtype, person_team_e_id from person;
> +------+--------+------------------+
> | e_id | dtype | person_team_e_id |
> +------+--------+------------------+
> | 1 | Person | NULL |
> +------+--------+------------------+
>
>
> mysql> select e_id, dtype from team;
> +------+-------+
> | e_id | dtype |
> +------+-------+
> | 1 | Team |
> +------+-------+
>
> Yet when I declare Person before Team, reload the genmodel, regenerate
> the model code, run my test case, the "person_team_e_id" is set to 1,
> see below (with attached softball.ecore.good):
>
> mysql> select e_id, dtype, person_team_e_id from person;
> +------+--------+------------------+
> | e_id | dtype | person_team_e_id |
> +------+--------+------------------+
> | 1 | Person | 1 |
> +------+--------+------------------+
>
>
> mysql> select e_id, dtype from team;
> +------+-------+
> | e_id | dtype |
> +------+-------+
> | 1 | Team |
> +------+-------+
>
> Thanks for your help!
>
> Luc
>
> Martin Taal wrote:
>> Hi François,
>> I tried your testcase but I could not reproduce the exception. Maybe I
>> misunderstood you, I exchanged the order of Team and Person several
>> times in the ecore file. Each time I started with an empty database
>> and all the time the test passed.
>>
>> Can you try again?
>>
>> gr. Martin
>>
>> François M. wrote:
>>> Hi Martin,
>>>
>>> I was able to reproduce it. The problem is caused by the order in
>>> which the EClass are declared in the genmodel.
>>>
>>> In the test case I attached:
>>> Person has 1 Team
>>> Team has 0 to Many Person.
>>>
>>> Person eOpposite is team.members.
>>> Team eOpposite is Person.team
>>>
>>> In the model description, if Person is declared before Team. The
>>> column "person_team_e_id" from the "person" table is correctly set to
>>> an id from the team.members table.
>>>
>>> The problem rise when Team is declared before Person. In this case
>>> the column "person_team_e_id" from "person" table is always set to
>>> null. This cause the person.getTeam() call to always return null.
>>>
>>> To go from a working to failing state, simply change the order of the
>>> 2 EClass and restart the application.
>>>
>>> Is there anyway to fix that issue without changing the order of the
>>> EClass, it maybe impossible to do for me because my EClasses are from
>>> different package.
>>>
>>> François
>>>
>>>
>>>
>>>
>>> François M. wrote:
>>>> Hi,
>>>>
>>>> I am using emf 2.4 (dynamic efeatures) and teneo 0.8.0RC1A. We have
>>>> this issue where the relation between 2 object is not persisted when
>>>> both object`s reference to each other has their EOpposite set to
>>>> each other.
>>>>
>>>> ex:
>>>> A Book.author is referring [1] to an Author, with EOpposite set to
>>>> Author.book
>>>> An Author is referring [1 to *] to Book, and with an EOpposite set
>>>> to Book.author
>>>>
>>>> When I set the author of the book, then persist the book (and author
>>>> through cascading) and commit, the author and the book are persisted
>>>> but the relation between the twos is not.
>>>>
>>>> Any idea why from this brief description?
>>>>
>>>> If not, I will try to provide a sample.
>>>>
>>>> Regards
>>>> François
>>>
>>
>>


--

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
Previous Topic:Sparse lists seem to cause havoc in Teneo 0.7.5
Next Topic:[Announce] EMFT COMPARE 0.8.0RC5 is available
Goto Forum:
  


Current Time: Sat Apr 20 04:05:55 GMT 2024

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

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

Back to the top