Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE
[TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881378] Mon, 04 June 2012 12:40 Go to next message
Eclipse UserFriend
Hello,

given the following situation...

1) Global inheritence strategy is SINGLE_TABLE, i.e. classes are by
default merged into one table row

2) Two classes A, B which have a common super class S that is a
@MappedSuperclass. This results in A, B getting their own table
row and id.

3) A, B also (multiply) inherit from another class/interface I
containing references to class C

.... I face this problem:

Teneo/Hibernate creates only one index C->I. This index is ambiguous
and seems to only refer to one of A, B (perhaps just whichever comes
first in the mapping definition?).

As possible solutions I can think of these:

1) Have two indexes C->A and C->B
--> how to do this?

2) Let A, B live in a single table row inserting a non-MappedSuperclass
between A,B and S
--> seems kind of awkward, but it's what I'm going for now

3) Actuall in my case the I->C reference is a containment, so the
table holding the C object already has an e_container pointing
to the object in question, IMHO there is no need for an extra
index.
--> Prefer this, but how to do this?

4) Don't use multiple inheritance
--> less ideal because it really helps to make my models
and subsequent QVT model transformations much more maintainable.

I'm quite new to this technology and may have well overlooked or
misunderstood some of its concepts. Any insight will be greatly appreciated!

Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881390 is a reply to message #881378] Mon, 04 June 2012 12:58 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Marius,
Yes you encountered the main issue with using separate tables for subtypes.. If there is only one specific case then you
can try the AssociationOverride annotation, I attached an example model which shows how this looks like. You can find
more info on the association override annotation in the jpa 2.0 spec.

If there are many of these cases and associationoverride is a lot of work you can consider using the joined table
inheritance mapping.

gr. Martin

On 06/04/2012 02:40 PM, Marius Gröger wrote:
> Hello,
>
> given the following situation...
>
> 1) Global inheritence strategy is SINGLE_TABLE, i.e. classes are by
> default merged into one table row
>
> 2) Two classes A, B which have a common super class S that is a
> @MappedSuperclass. This results in A, B getting their own table
> row and id.
>
> 3) A, B also (multiply) inherit from another class/interface I
> containing references to class C
>
> .... I face this problem:
>
> Teneo/Hibernate creates only one index C->I. This index is ambiguous
> and seems to only refer to one of A, B (perhaps just whichever comes
> first in the mapping definition?).
>
> As possible solutions I can think of these:
>
> 1) Have two indexes C->A and C->B
> --> how to do this?
>
> 2) Let A, B live in a single table row inserting a non-MappedSuperclass
> between A,B and S
> --> seems kind of awkward, but it's what I'm going for now
>
> 3) Actuall in my case the I->C reference is a containment, so the
> table holding the C object already has an e_container pointing
> to the object in question, IMHO there is no need for an extra
> index.
> --> Prefer this, but how to do this?
>
> 4) Don't use multiple inheritance
> --> less ideal because it really helps to make my models
> and subsequent QVT model transformations much more maintainable.
>
> I'm quite new to this technology and may have well overlooked or
> misunderstood some of its concepts. Any insight will be greatly appreciated!
>
> Marius


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881436 is a reply to message #881390] Mon, 04 June 2012 14:54 Go to previous messageGo to next message
Eclipse UserFriend
Hi Martin,

On 04.06.2012 14:58, Martin Taal wrote:
> Yes you encountered the main issue with using separate tables for
> subtypes.. If there is only one specific case then you can try the
> AssociationOverride annotation, I attached an example model which shows
> how this looks like. You can find more info on the association override
> annotation in the jpa 2.0 spec.

Thanks for the quick response and the example. I'm not quite getting it
though. Looking at the .ecore, you specify the AssociationOverride
annotation only for the Employee class, but not for the Student. Why is
that? Next, what does the name="address" in the annotation refer to? In
the ecore model there is no such field, only the class Address which has
a capital first letter. Lastly: what do I chose as the
@JoinColumn(name=...)? Is that to be my own invention to resolve the
name clash?

Sorry if my questions are being dumb, as I said, I'm rather new to all
of this...

Regards
Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881441 is a reply to message #881436] Mon, 04 June 2012 15:06 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Marius,
No dumb questions at all, some replies:
- I only specify the association override for the employee, as just renaming one of the two (in Employee or in Student)
solves the name collision problems, I could have 'overridden' also the student side.
- the name "address" refers to the feature name in the parent type (Person.address), Student and Employee both inherit
from Person
- you can choose your own name in the JoinColumn(name=...) just anything to prevent the name collision.

Let me know if you have other questions/remarks.

gr. Martin

On 06/04/2012 04:54 PM, Marius Gröger wrote:
> Hi Martin,
>
> On 04.06.2012 14:58, Martin Taal wrote:
>> Yes you encountered the main issue with using separate tables for
>> subtypes.. If there is only one specific case then you can try the
>> AssociationOverride annotation, I attached an example model which shows
>> how this looks like. You can find more info on the association override
>> annotation in the jpa 2.0 spec.
>
> Thanks for the quick response and the example. I'm not quite getting it
> though. Looking at the .ecore, you specify the AssociationOverride
> annotation only for the Employee class, but not for the Student. Why is
> that? Next, what does the name="address" in the annotation refer to? In
> the ecore model there is no such field, only the class Address which has
> a capital first letter. Lastly: what do I chose as the
> @JoinColumn(name=...)? Is that to be my own invention to resolve the
> name clash?
>
> Sorry if my questions are being dumb, as I said, I'm rather new to all
> of this...
>
> Regards
> Marius
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881731 is a reply to message #881441] Tue, 05 June 2012 07:02 Go to previous messageGo to next message
Eclipse UserFriend
On 04.06.2012 17:06, Martin Taal wrote:
< [ some more great help ]

Thanks!

> Let me know if you have other questions/remarks.

I'm getting the following error:

No efeature joinTable for eclass AssociationOverride. I traced
HbEAnnotationParserImporter.getEStructuralFeature() and looked into the
Pannotation model and could indeed not find this feature. Do I perhaps
need a newer version of Teneo for this? Currently I'm using
1.2.0.v201204090637.

Regards
Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881741 is a reply to message #881731] Tue, 05 June 2012 07:19 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ha yes, you need the latest version, this blog post can be of interest:
http://martintaal.wordpress.com/2012/05/21/emf-teneo-2-0-jpa-2-0-and-hibernate-4/

gr. Martin

On 06/05/2012 09:02 AM, Marius Gröger wrote:
> On 04.06.2012 17:06, Martin Taal wrote:
> < [ some more great help ]
>
> Thanks!
>
>> Let me know if you have other questions/remarks.
>
> I'm getting the following error:
>
> No efeature joinTable for eclass AssociationOverride. I traced
> HbEAnnotationParserImporter.getEStructuralFeature() and looked into the
> Pannotation model and could indeed not find this feature. Do I perhaps
> need a newer version of Teneo for this? Currently I'm using
> 1.2.0.v201204090637.
>
> Regards
> Marius


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881765 is a reply to message #881741] Tue, 05 June 2012 08:07 Go to previous messageGo to next message
Eclipse UserFriend
On 05.06.2012 09:19, Martin Taal wrote:
> Ha yes, you need the latest version, this blog post can be of interest:
> http://martintaal.wordpress.com/2012/05/21/emf-teneo-2-0-jpa-2-0-and-hibernate-4/

Bummer, at this point in time we're not able to move to a new version of
Hibernate. So I think I will have to work around the issue by using as
dummy non-MappedSuperclass from which all classes inherit which will
receive the the multiple inheritance. Hopefully we can do a batch
upgrade at a later point.

Thanks for you valuable help Martin!

Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881773 is a reply to message #881765] Tue, 05 June 2012 08:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ho stop :-)! The latest version of Teneo 1.2.0 works on hibernate 3.6.0 *and* supports JPA 2.0 annotations, see the blog
post.

Currently the only difference between Teneo 1.2.0 and 2.0.0 is the hibernate version.

gr. Martin

On 06/05/2012 10:07 AM, Marius Gröger wrote:
> On 05.06.2012 09:19, Martin Taal wrote:
>> Ha yes, you need the latest version, this blog post can be of interest:
>> http://martintaal.wordpress.com/2012/05/21/emf-teneo-2-0-jpa-2-0-and-hibernate-4/
>
> Bummer, at this point in time we're not able to move to a new version of
> Hibernate. So I think I will have to work around the issue by using as
> dummy non-MappedSuperclass from which all classes inherit which will
> receive the the multiple inheritance. Hopefully we can do a batch
> upgrade at a later point.
>
> Thanks for you valuable help Martin!
>
> Marius


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881775 is a reply to message #881773] Tue, 05 June 2012 08:30 Go to previous messageGo to next message
Eclipse UserFriend
On 05.06.2012 10:26, Martin Taal wrote:
> Ho stop :-)! The latest version of Teneo 1.2.0 works on hibernate 3.6.0
> *and* supports JPA 2.0 annotations, see the blog post.

Yes I read it but since you said "Ha yes.." I thought somehow our
version is not sufficient. So again, I'm using 1.2.0.v201204090637, but
still get this error?!

*Confused*
Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881781 is a reply to message #881775] Tue, 05 June 2012 08:40 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Sorry for the confusion, with latest version I mean latest build. You are using the 1.2.0 version from the 9th of april
2012. The latest build is from end of May.

I will change the blog post.

gr. Martin

On 06/05/2012 10:30 AM, Marius Gröger wrote:
> On 05.06.2012 10:26, Martin Taal wrote:
>> Ho stop :-)! The latest version of Teneo 1.2.0 works on hibernate 3.6.0
>> *and* supports JPA 2.0 annotations, see the blog post.
>
> Yes I read it but since you said "Ha yes.." I thought somehow our
> version is not sufficient. So again, I'm using 1.2.0.v201204090637, but
> still get this error?!
>
> *Confused*
> Marius
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881782 is a reply to message #881775] Tue, 05 June 2012 08:41 Go to previous messageGo to next message
Eclipse UserFriend
On 05.06.2012 10:30, Marius Gröger wrote:
> On 05.06.2012 10:26, Martin Taal wrote:
>> Ho stop :-)! The latest version of Teneo 1.2.0 works on hibernate 3.6.0
>> *and* supports JPA 2.0 annotations, see the blog post.
>
> Yes I read it but since you said "Ha yes.." I thought somehow our
> version is not sufficient. So again, I'm using 1.2.0.v201204090637, but
> still get this error?!

Ok got it, apparently there is an even newer version of 1.2.0 than this
one available which does have the joinTable feature. I will try it...

Regards
Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881785 is a reply to message #881782] Tue, 05 June 2012 08:43 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes I do new builds every month or so (whenever I fix issues), this new build only changes the build number (the
datastamp after the 1.2.0.v) and not the version number...

gr. Martin

On 06/05/2012 10:41 AM, Marius Gröger wrote:
> On 05.06.2012 10:30, Marius Gröger wrote:
>> On 05.06.2012 10:26, Martin Taal wrote:
>>> Ho stop :-)! The latest version of Teneo 1.2.0 works on hibernate 3.6.0
>>> *and* supports JPA 2.0 annotations, see the blog post.
>>
>> Yes I read it but since you said "Ha yes.." I thought somehow our
>> version is not sufficient. So again, I'm using 1.2.0.v201204090637, but
>> still get this error?!
>
> Ok got it, apparently there is an even newer version of 1.2.0 than this
> one available which does have the joinTable feature. I will try it...
>
> Regards
> Marius
>
>


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881873 is a reply to message #881741] Tue, 05 June 2012 12:04 Go to previous messageGo to next message
Eclipse UserFriend
On 05.06.2012 09:19, Martin Taal wrote:
> Ha yes, you need the latest version, this blog post can be of interest:
> http://martintaal.wordpress.com/2012/05/21/emf-teneo-2-0-jpa-2-0-and-hibernate-4/

Ok, now it's half working :-)

In a simple test case everything seems ok. But in the real model I get
this error:

java.sql.BatchUpdateException: Duplicate entry '10' for key 'elt'

What is this elt thing anyway? It is created with the helper table, but
I never specified it.

I'm using such an inheritance scheme:

P <- A
Q <- B, C, D

with P, B, C, D implementing interface X and
A, B, C, D implementing interface Y.

X and Y each contain references to other objects, X even contains two
such reference lists.

Any clue?
Marius
Re: [TENEO] Multiple inheritance, MappedSuperclass+SINGLE_TABLE [message #881880 is a reply to message #881873] Tue, 05 June 2012 12:13 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Marius,
I guess there must still be some table/column collision in there, so I think you need to check/analyze if you need an
additional association override, the elt is probably the foreign key from a join table to the element in that join table.

gr. Martin

On 06/05/2012 02:04 PM, Marius Gröger wrote:
> On 05.06.2012 09:19, Martin Taal wrote:
>> Ha yes, you need the latest version, this blog post can be of interest:
>> http://martintaal.wordpress.com/2012/05/21/emf-teneo-2-0-jpa-2-0-and-hibernate-4/
>
> Ok, now it's half working :-)
>
> In a simple test case everything seems ok. But in the real model I get
> this error:
>
> java.sql.BatchUpdateException: Duplicate entry '10' for key 'elt'
>
> What is this elt thing anyway? It is created with the helper table, but
> I never specified it.
>
> I'm using such an inheritance scheme:
>
> P<- A
> Q<- B, C, D
>
> with P, B, C, D implementing interface X and
> A, B, C, D implementing interface Y.
>
> X and Y each contain references to other objects, X even contains two
> such reference lists.
>
> Any clue?
> Marius


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:[CDO/Hibernate/Teneo] org.hibernate.MappingException: Unknown entity: org.eclipse.emf.cdo.internal.c
Next Topic:suppress documentation
Goto Forum:
  


Current Time: Wed Apr 24 16:20:02 GMT 2024

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

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

Back to the top