Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] Mapped superclass in a containment relation
[TEXO] Mapped superclass in a containment relation [message #1621102] Tue, 17 February 2015 17:19 Go to next message
Mr Cur is currently offline Mr CurFriend
Messages: 35
Registered: September 2014
Member
Hi,

I have the following classes and relations:

A<*>-----------------(hasS)----B
^
|
----------------------
| | |
C D E

A decomposes into (many) B's, being C, D, and E's.
Therefore, C, D, and E are subclasses of B.

Since many instances of C, D, and E are generated in application, I want to have them in seperate tables. To do so, I defined an MAPPED SUPERCLASS annotation for B. Code generation goes fine.

If I however create an instane of A and C, and try to populatie de decomposition relation between A en C (via B) I get the following error:

(Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class A] uses a non-entity [class B] as target entity in the relationship attribute [field hasS].

If I ommit the MAPPED SUPERCLASS annotation everything is put in a table B (so C, D, and E) and everything works fine.

Thanks for your help.

Cur.

Re: [TEXO] Mapped superclass in a containment relation [message #1621143 is a reply to message #1621102] Tue, 17 February 2015 17:56 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Cur,
If B is mapped as a mapped super class, this means that C, D and E each will be stored in their own respective tables.
This has as a consequence that when loading an instance of A, that the ORM needs to read from three tables and then
somehow consolidate them for the association. The ORM probably does not do that and expects to work with one table for
one association.

You can try by using a join table for the association, this could work or not.. but is worth a try. (I am not sure).

If that doesn't work then I guess mapped super class wont work in this case. You can try to use joined inheritance
strategy, this will give you 4 tables, B, C, D and E, but at least the B table will only have the B-columns.

gr. Martin


On 17-02-15 18:19, Mr Cur wrote:
> Hi,
>
> I have the following classes and relations:
>
> A<*>-----------------(hasS)----B
> ^
> |
> ----------------------
> | | |
> C D E
>
> A decomposes into (many) B's, being C, D, and E's.
> Therefore, C, D, and E are subclasses of B.
>
> Since many instances of C, D, and E are generated in application, I want to have them in seperate tables. To do so, I
> defined an MAPPED SUPERCLASS annotation for B. Code generation goes fine.
>
> If I however create an instane of A and C, and try to populatie de decomposition relation between A en C (via B) I get
> the following error:
>
> (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
> Exception Description: [class A] uses a non-entity [class B] as target entity in the relationship attribute [field hasS].
>
> If I ommit the MAPPED SUPERCLASS annotation everything is put in a table B (so C, D, and E) and everything works fine.
>
> Thanks for your help.
>
> Cur.
>


--

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: [TEXO] Mapped superclass in a containment relation [message #1621346 is a reply to message #1621102] Tue, 17 February 2015 21:09 Go to previous message
Mr Cur is currently offline Mr CurFriend
Messages: 35
Registered: September 2014
Member
Hi Martin,

Joined inheritance worked for me.

Thanks for the fast response.

Cur.
Previous Topic:[Teneo] Partially resolve containment references
Next Topic:[Teneo] Initialize HbEntityDataStory correctly with MetaModel
Goto Forum:
  


Current Time: Sat Apr 20 02:27:42 GMT 2024

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

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

Back to the top