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 |
Nikt Zupelnie 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 |
Martin Taal 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 #1220993 is a reply to message #1220990] |
Mon, 16 December 2013 14:46 |
Martin Taal 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
|
|
| |
Goto Forum:
Current Time: Wed Apr 24 15:07:02 GMT 2024
Powered by FUDForum. Page generated in 0.03316 seconds
|