Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Inheritence mapping annotation on Ecore
[Teneo] Inheritence mapping annotation on Ecore [message #1278800] Thu, 27 March 2014 21:45 Go to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
Hi all,

I am a newbie to Teneo hibernate world and I am trying to use these technologies on my EMF model. I used ecore for editing my models. My class structure is designed based on our application needs and it is not that straightforward to map this structure to OR.

Unfortunately, I couldn't find much documentation to help me with JPA annotations on Ecore for someone with no clue like me. I downloaded the example ecores but none of them have inheritance annotation. I really appreciate if you can help me with these or if you can redirect me to a better (simpler) documentation.

My class model is:

BaseClass

ClassA extends BaseClass 
ClassB extends BaseClass
ClassC Extends BaseClass

ClassSubC1 extends ClassC
ClassSubC2 extends ClassC
...


My first problem is to be bale to do a "TABLE_PER_CLASS" mapping for ClassA, CLassB and ClassC and for ClassC subclasses, I just want to keep the superclass (i.e. ClassC) data in the DB. How can I annotate my ecore model for this?

The other issue that I have, is that my ClassC has a reference to a Base2Class in another package. I want hibernate and teneo to ignore this reference when they are stored in the DB, and I don't want to make any tables for the classes in the referenced epackage. I have some other attributes as well that I'd like to be gnored by hibernate. Is there any annotations to do that?

Thanks very much for your help in advance.
Re: [Teneo] Inheritence mapping annotation on Ecore [message #1279097 is a reply to message #1278800] Fri, 28 March 2014 08:23 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Roza,
Did you look at this page:
https://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Inheritance_Mapping

I personally like @MappedSuperclass a lot, see the JPA spec for its usage. So define a rootclass/type with common
attributes, annotate it with @Mappedsuperclass, then its subclasses will be in their own tables sharing the same attributes.

This page talks about in general how to work with annotations in teneo:
https://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Annotations_Format

In the eclipse emf editor you can right click on a model element (eclass/ereference/edatatype/eattribute) and then add
an eannotation, the source and details settings are described in the page above.

For ignoring references you can set the @Transient annotation in the EClass (that eclass and all ereferences to it will
be ignored).
You can also denote individual ereferences/efeatures to be ignored, set the @Transient annotation on the efeature
directly then.

gr. Martin

On 03/27/2014 10:45 PM, Roza Ghamari wrote:
> Hi all,
>
> I am a newbie to Teneo hibernate world and I am trying to use these technologies on my EMF model. I used ecore for
> editing my models. My class structure is designed based on our application needs and it is not that straightforward to
> map this structure to OR.
>
> Unfortunately, I couldn't find much documentation to help me with JPA annotations on Ecore for someone with no clue like
> me. I downloaded the example ecores but none of them have inheritance annotation. I really appreciate if you can help me
> with these or if you can redirect me to a better (simpler) documentation.
>
> My class model is:
>
> BaseClass
>
> ClassA extends BaseClass ClassB extends BaseClass
> ClassC Extends BaseClass
>
> ClassSubC1 extends ClassC
> ClassSubC2 extends ClassC
> ...
>
> My first problem is to be bale to do a "TABLE_PER_CLASS" mapping for ClassA, CLassB and ClassC and for ClassC
> subclasses, I just want to keep the superclass (i.e. ClassC) data in the DB. How can I annotate my ecore model for this?
>
> The other issue that I have, is that my ClassC has a reference to a Base2Class in another package. I want hibernate and
> teneo to ignore this reference when they are stored in the DB, and I don't want to make any tables for the classes in
> the referenced epackage. I have some other attributes as well that I'd like to be gnored by hibernate. Is there any
> annotations to do that?
>
> Thanks very much for your help in advance.


--

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:ECP Editor not showing Volatile or Transient EAttributes
Next Topic:[Texo] Lazy Loading with Texo
Goto Forum:
  


Current Time: Fri Apr 26 21:26:58 GMT 2024

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

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

Back to the top