Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] inheritance mapping - cannot alter default strategy
[Teneo] inheritance mapping - cannot alter default strategy [message #1220582] Thu, 12 December 2013 15:52 Go to next message
Nikt Zupelnie is currently offline Nikt ZupelnieFriend
Messages: 7
Registered: October 2013
Junior Member
Hello.

I've read http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Inheritance_Mapping but somehow suggested solutions don't work for me at all.

Simplified model: I have base abstract interface and implementing class (AbstractBaseClass + AbstractBaseClassImpl), then another abstract interface + class extending it (AbstractExtendedAbstractBaseClass + AbstractExtendedAbstractBaseClassImpl) and three concrete interfaces+classes inheriting from AbstractExtendedAbstractBaseClass: classA+classAImpl, classB+classBImpl and classC+classCImpl.

Problem: Teneo ignores all my attempts to use other that default SINGLE_TABLE strategy and everytime creates single table per whole hierarchy with varchar class type column. What I would like to have are separate tables classA, classB and classC for concrete classes and no tables for abstract classes - so similar to what TABLE_PER_CLASS talks about

What I tried to alter default behaviour:

1. Setting JOINED property like this (just to see if this can be altered by property)
final Properties props = new Properties();
props.setProperty("org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING", 
                    "TABLE_PER_CLASS");
(...)
hibernateDataStore.setDataStoreProperties(props);
hibernateDataStore.initialize();


This is not working - Teneo creates the same tables hierarchy - one table AbstractBaseClass shared by whole class hierarchy

2. Not touching "org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING" property and adding @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) to every _generated_ concrete class and its interface (so ClassA + ClassAImpl etc) and adding @MappedSuperclass to _generated_ AbstractBaseClass, AbstractBaseClassImpl, AbstractExtendedAbstractBaseClass, AbstractExtendedAbstractBaseClassImpl.

This is not working - schema look exactly the same as default. I run out of ideas what's happening.

Questions

1. Do I set the "org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING" property correctly - if so, why it's not working for JOINED

2. Why @Inheritance and @MappedSuperclass is ignored? Does Teneo ignore generated classes' annotations and instead should I put it into .ecore files or, better, external mapping file?

3. What I'm doing wrong? What is the correct way to have table-per-concrete-class schema generated by Teneo/Hibernate?











Re: [Teneo] inheritance mapping - cannot alter default strategy [message #1220611 is a reply to message #1220582] Thu, 12 December 2013 17:05 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Nikt,
Teneo expects something else in both cases:
- the option should not be the stringified java identifier, it should be the value of the option:
so not:
props.setProperty("org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING","TABLE_PER_CLASS");
but:
props.setProperty(org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING,"TABLE_PER_CLASS");
note that table per class has its limitations, I like the combination of joined and MappedSuperclass myself
- you should not set annotations in the generated code, you should set them in the model/ecore/xsd:
http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Annotations_Format

Btw the texo project might be interesting for you to. It supports EMF but in a more standard JPA way:
http://wiki.eclipse.org/Texo

gr. Martin

On 12/12/2013 04:52 PM, Nikt Zupelnie wrote:
> Hello.
>
> I've read http://wiki.eclipse.org/Teneo/Hibernate/ModelRelational/Inheritance_Mapping but somehow suggested solutions
> don't work for me at all.
>
> Simplified model: I have base abstract interface and implementing class (AbstractBaseClass + AbstractBaseClassImpl),
> then another abstract interface + class extending it (AbstractExtendedAbstractBaseClass +
> AbstractExtendedAbstractBaseClassImpl) and three concrete interfaces+classes inheriting from
> AbstractExtendedAbstractBaseClass: classA+classAImpl, classB+classBImpl and classC+classCImpl.
>
> Problem: Teneo ignores all my attempts to use other that default SINGLE_TABLE strategy and everytime creates single
> table per whole hierarchy with varchar class type column. What I would like to have are separate tables classA, classB
> and classC for concrete classes and no tables for abstract classes - so similar to what TABLE_PER_CLASS talks about
>
> What I tried to alter default behaviour:
>
> 1. Setting JOINED property like this (just to see if this can be altered by property)
>
> final Properties props = new Properties();
> props.setProperty("org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING",
> "TABLE_PER_CLASS");
> (...)
> hibernateDataStore.setDataStoreProperties(props);
> hibernateDataStore.initialize();
>
>
> This is not working - Teneo creates the same tables hierarchy - one table AbstractBaseClass shared by whole class hierarchy
>
> 2. Not touching "org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING" property and adding
> @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) to every _generated_ concrete class and its interface (so ClassA
> + ClassAImpl etc) and adding @MappedSuperclass to _generated_ AbstractBaseClass, AbstractBaseClassImpl,
> AbstractExtendedAbstractBaseClass, AbstractExtendedAbstractBaseClassImpl.
>
> This is not working - schema look exactly the same as default. I run out of ideas what's happening.
>
> Questions
>
> 1. Do I set the "org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING" property correctly - if so,
> why it's not working for JOINED
>
> 2. Why @Inheritance and @MappedSuperclass is ignored? Does Teneo ignore generated classes' annotations and instead
> should I put it into .ecore files or, better, external mapping file?
>
> 3. What I'm doing wrong? What is the correct way to have table-per-concrete-class schema generated by Teneo/Hibernate?
>
>
>
>
>
>
>
>
>
>
>
>


--

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] inheritance mapping - cannot alter default strategy [message #1220719 is a reply to message #1220611] Fri, 13 December 2013 09:34 Go to previous messageGo to next message
Nikt Zupelnie is currently offline Nikt ZupelnieFriend
Messages: 7
Registered: October 2013
Junior Member
Thank you so much for your quick answer.

Martin Taal wrote on Thu, 12 December 2013 12:05

props.setProperty("org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING","TABLE_PER_CLASS");
but:
props.setProperty(org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING,"TABLE_PER_CLASS");


Now I recall why I thought this is a string literal instead of a constant field of a class... Im worried to sound dumb here, but there is no org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING constant in Teneo codebase which I have on my classpath, so

props.setProperty(org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING,"TABLE_PER_CLASS");


results in a compilation problem ("org.eclipse.emf.teneo.mapper cannot be resolved to a variable").

Is it possible that there is a mistake in the name of the option? I tried to find something similar but without results...

My Teneo-related classpath looks quite complete:

commons-logging-1.1.3.jar
org.eclipse.emf.common_2.9.0.v20130528-0742.jar
org.eclipse.emf.ecore_2.9.0.v20130528-0742.jar
org.eclipse.emf.ecore.xmi_2.9.0.v20130528-0742.jar
org.eclipse.emf.teneo-2.0.1-v201302282249.jar
org.eclipse.emf.teneo.annotations-2.0.1-v201302282249.jar
org.eclipse.emf.teneo.hibernate-2.0.1-v201302282249.jar
org.eclipse.emf.teneo.hibernate.mapper-2.0.1-v201302282249.jar

in addition to this I have jars for Hibernate and pgsql.


Re: [Teneo] inheritance mapping - cannot alter default strategy [message #1220990 is a reply to message #1220719] Mon, 16 December 2013 14:32 Go to previous messageGo to next message
Nikt Zupelnie is currently offline Nikt ZupelnieFriend
Messages: 7
Registered: October 2013
Junior Member
Anybody has any idea why I cannot find the "org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING" const on my classpath, as described above?
Re: [Teneo] inheritance mapping - cannot alter default strategy [message #1220993 is a reply to message #1220990] Mon, 16 December 2013 14:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Because that class does not exist, you need to get this one:
org.eclipse.emf.teneo.PersistenceOptions

As an extra general eclipse tip, the 'open type' eclipse popup is great, do shft-ctrl-t and then type part of class
names and wildcards, for example this one would have found you the above class:
Persistence*Options

gr. Martin

On 12/16/2013 03:32 PM, Nikt Zupelnie wrote:
> Anybody has any idea why I cannot find the "org.eclipse.emf.teneo.mapper.PersistenceMappingOptions.INHERITANCEMAPPING"
> const on my classpath, as described above?


--

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] inheritance mapping - cannot alter default strategy [message #1221000 is a reply to message #1220993] Mon, 16 December 2013 15:39 Go to previous message
Nikt Zupelnie is currently offline Nikt ZupelnieFriend
Messages: 7
Registered: October 2013
Junior Member
Martin Taal wrote on Mon, 16 December 2013 09:46
Because that class does not exist, you need to get this one:
org.eclipse.emf.teneo.PersistenceOptions

As an extra general eclipse tip (...)


Thank you, this is the correct class name (FYI wiki page still contains incorrect name) and it solved my problem. Yes I know about "Open Type" Smile

Best regards,

[Updated on: Mon, 16 December 2013 15:41]

Report message to a moderator

Previous Topic:Validating EMF Models
Next Topic:TENEO - ID is coming as null
Goto Forum:
  


Current Time: Wed Apr 24 15:07:02 GMT 2024

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

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

Back to the top