Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo]Failure to persist a reference (to subclass)
[Teneo]Failure to persist a reference (to subclass) [message #82336] Mon, 07 May 2007 19:24 Go to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hello,
Attached is a plugin demonstrating the problem with a simple model.
There are model objects for Book and Author.
A ScifiBook (subclass of book) has 0 or more Authors (non-containment
reference) associated with it.

In the TestSaveref JUnit test, I create two ScifiBooks and one ForeignAuthor
(subclass of Author). I associate the ForeignAuthor with both of the
ScifiBooks. When I retry to reload the model, one of the ScifiBooks fails to
retrieve its reference. Test output looks like:

junit.framework.AssertionFailedError: Book "The Name of the Rose" has
incorrect number of authors. expected:<1> but was:<0>

Any ideas why? Any workarounds (potential model changes ok)?

Thanks,
-mike


Re: [Teneo]Failure to persist a reference (to subclass) [message #82378 is a reply to message #82336] Mon, 07 May 2007 20:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
The ScifiBook.authors ereference is a one-to-many. So one book can have multiple authors but an
author can only write one book. In the test case the one author is added to both book1 and book2,
setting the second book2 will overwrite the reference to the first book (as the fk column is present
in the author table).
By adding the following annotation to the authors ereference:
@OneToMany(unique=false)
the relation is made a unidirectional many-to-many resulting in a join table. In this case the test
case passes fine.

gr. martin

Michael Kanaley wrote:
> Hello,
> Attached is a plugin demonstrating the problem with a simple model.
> There are model objects for Book and Author.
> A ScifiBook (subclass of book) has 0 or more Authors (non-containment
> reference) associated with it.
>
> In the TestSaveref JUnit test, I create two ScifiBooks and one ForeignAuthor
> (subclass of Author). I associate the ForeignAuthor with both of the
> ScifiBooks. When I retry to reload the model, one of the ScifiBooks fails to
> retrieve its reference. Test output looks like:
>
> junit.framework.AssertionFailedError: Book "The Name of the Rose" has
> incorrect number of authors. expected:<1> but was:<0>
>
> Any ideas why? Any workarounds (potential model changes ok)?
>
> Thanks,
> -mike
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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]Failure to persist a reference (to subclass) [message #82454 is a reply to message #82378] Mon, 07 May 2007 21:45 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
Thanks - that was the problem with my model.
Actually, instead of the annotation, I just set the "Unique" property to
false in the Book's authors EReference.

-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:f1o0um$irb$1@build.eclipse.org...
> Hi Mike,
> The ScifiBook.authors ereference is a one-to-many. So one book can have
> multiple authors but an author can only write one book. In the test case
> the one author is added to both book1 and book2, setting the second book2
> will overwrite the reference to the first book (as the fk column is
> present in the author table).
> By adding the following annotation to the authors ereference:
> @OneToMany(unique=false)
> the relation is made a unidirectional many-to-many resulting in a join
> table. In this case the test case passes fine.
>
> gr. martin
>
> Michael Kanaley wrote:
>> Hello,
>> Attached is a plugin demonstrating the problem with a simple model.
>> There are model objects for Book and Author.
>> A ScifiBook (subclass of book) has 0 or more Authors (non-containment
>> reference) associated with it.
>>
>> In the TestSaveref JUnit test, I create two ScifiBooks and one
>> ForeignAuthor (subclass of Author). I associate the ForeignAuthor with
>> both of the ScifiBooks. When I retry to reload the model, one of the
>> ScifiBooks fails to retrieve its reference. Test output looks like:
>>
>> junit.framework.AssertionFailedError: Book "The Name of the Rose" has
>> incorrect number of authors. expected:<1> but was:<0>
>>
>> Any ideas why? Any workarounds (potential model changes ok)?
>>
>> Thanks,
>> -mike
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> 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]Failure to persist a reference (to subclass) [message #605355 is a reply to message #82336] Mon, 07 May 2007 20:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
The ScifiBook.authors ereference is a one-to-many. So one book can have multiple authors but an
author can only write one book. In the test case the one author is added to both book1 and book2,
setting the second book2 will overwrite the reference to the first book (as the fk column is present
in the author table).
By adding the following annotation to the authors ereference:
@OneToMany(unique=false)
the relation is made a unidirectional many-to-many resulting in a join table. In this case the test
case passes fine.

gr. martin

Michael Kanaley wrote:
> Hello,
> Attached is a plugin demonstrating the problem with a simple model.
> There are model objects for Book and Author.
> A ScifiBook (subclass of book) has 0 or more Authors (non-containment
> reference) associated with it.
>
> In the TestSaveref JUnit test, I create two ScifiBooks and one ForeignAuthor
> (subclass of Author). I associate the ForeignAuthor with both of the
> ScifiBooks. When I retry to reload the model, one of the ScifiBooks fails to
> retrieve its reference. Test output looks like:
>
> junit.framework.AssertionFailedError: Book "The Name of the Rose" has
> incorrect number of authors. expected:<1> but was:<0>
>
> Any ideas why? Any workarounds (potential model changes ok)?
>
> Thanks,
> -mike
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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]Failure to persist a reference (to subclass) [message #605380 is a reply to message #82378] Mon, 07 May 2007 21:45 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
Thanks - that was the problem with my model.
Actually, instead of the annotation, I just set the "Unique" property to
false in the Book's authors EReference.

-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:f1o0um$irb$1@build.eclipse.org...
> Hi Mike,
> The ScifiBook.authors ereference is a one-to-many. So one book can have
> multiple authors but an author can only write one book. In the test case
> the one author is added to both book1 and book2, setting the second book2
> will overwrite the reference to the first book (as the fk column is
> present in the author table).
> By adding the following annotation to the authors ereference:
> @OneToMany(unique=false)
> the relation is made a unidirectional many-to-many resulting in a join
> table. In this case the test case passes fine.
>
> gr. martin
>
> Michael Kanaley wrote:
>> Hello,
>> Attached is a plugin demonstrating the problem with a simple model.
>> There are model objects for Book and Author.
>> A ScifiBook (subclass of book) has 0 or more Authors (non-containment
>> reference) associated with it.
>>
>> In the TestSaveref JUnit test, I create two ScifiBooks and one
>> ForeignAuthor (subclass of Author). I associate the ForeignAuthor with
>> both of the ScifiBooks. When I retry to reload the model, one of the
>> ScifiBooks fails to retrieve its reference. Test output looks like:
>>
>> junit.framework.AssertionFailedError: Book "The Name of the Rose" has
>> incorrect number of authors. expected:<1> but was:<0>
>>
>> Any ideas why? Any workarounds (potential model changes ok)?
>>
>> Thanks,
>> -mike
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> 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:[Teneo]Failure to persist a reference (to subclass)
Next Topic:how to paging big model and still reserve EMF.Edit command framework?
Goto Forum:
  


Current Time: Tue Jan 19 22:54:16 GMT 2021

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

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

Back to the top