Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo]Failure to persist a reference (to subclass)
|
Re: [Teneo]Failure to persist a reference (to subclass) [message #82378 is a reply to message #82336] |
Mon, 07 May 2007 20:07 |
Martin Taal 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 |
Michael Kanaley 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 |
Martin Taal 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 |
Michael Kanaley 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
|
|
|
Goto Forum:
Current Time: Fri Apr 26 17:31:38 GMT 2024
Powered by FUDForum. Page generated in 0.03640 seconds
|