| [CDO HibernateStore] Cannot use identity column key generation with <union-subclass> mapping f [message #911189] |
Tue, 11 September 2012 02:54  |
Eclipse User |
|
|
|
I try to use the CDO Hibernate Store with Teneo. I want to use the TABLE_PER_CLASS inheritance mapping in my cdo-server.xml. This is my configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<cdoServer>
<acceptor type="ssl" listenAddr="0.0.0.0" port="2036"></acceptor>
<repository name="test">
<property name="overrideUUID" value=""/>
<property name="supportingAudits" value="false"/>
<store type="hibernate">
<!-- Settings for Teneo -->
<mappingProvider type="teneo">
<property name="teneo.mapping.cascade_policy_on_non_containment" value="PERSIST,MERGE"/>
<property name="teneo.naming.id_feature_as_primary_key" value="true"/>
<property name="teneo.mapping.inheritance" value="TABLE_PER_CLASS"/>
<property name="teneo.mapping.add_index_for_fk" value="true"/>
</mappingProvider>
<!-- Settings for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.connection.pool_size" value="10"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
<!-- Settings for mysql -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true"/>
<property name="hibernate.connection.username" value="test"/>
<property name="hibernate.connection.password" value="test"/>
</store>
</repository>
</cdoServer>
When I start the CDO Server, I get the following exception:
Sep 11, 2012 8:36:38 AM org.eclipse.emf.teneo.classloader.ClassLoaderResolver setClassLoaderStrategy
INFO: Class loader strategy set to: org.eclipse.emf.teneo.classloader.ContextClassLoaderStrategy
[ERROR] Cannot use identity column key generation with <union-subclass> mapping for: Annotation
org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for: Annotation
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:384)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore.getHibernateSessionFactory(HibernateStore.java:260)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.beginHibernateSession(HibernateStoreAccessor.java:194)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.getHibernateSession(HibernateStoreAccessor.java:268)
at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.queryResources(HibernateStoreAccessor.java:495)
at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.readResourceID(StoreAccessorBase.java:212)
at org.eclipse.emf.cdo.internal.server.Repository.readRootResource(Repository.java:1769)
at org.eclipse.emf.cdo.internal.server.Repository.doActivate(Repository.java:1869)
at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:76)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:114)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:104)
at org.eclipse.emf.cdo.server.CDOServerUtil.addRepository(CDOServerUtil.java:208)
at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:111)
at org.eclipse.emf.cdo.internal.server.bundle.CDOServerApplication.doStart(CDOServerApplication.java:61)
at org.eclipse.net4j.util.om.OSGiApplication.start(OSGiApplication.java:63)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
It works fine when I try to use a different inheritance mapping like SINGLE_TABLE or JOINED. But for my model (a rather big one with a lot of abstract classes and inheritance) I need the TABLE_PER_CLASS mapping to prevent other errors. (If I use JOINED, I get an error that MySQL only supports 63 joins, just when I edit one object and try to commit the transaction. If I use SINGLE_TABLE, I have only one table in the database representing my whole data model which includes 200 attributes and relations. This scenario causes then other Hibernate exceptions)
I also tested the scenario above with a very small example model (just 3 classes) and I get the same exception.
Does CDO Hibernate Store not support the TABLE_PER_CLASS mapping? (I did not find a hint so far)
Is there anything misconfigured so that I get the error message?
Thanks for help!
Stephan
|
|
|
| Re: [CDO HibernateStore] Cannot use identity column key generation with <union-subclass&g [message #911763 is a reply to message #911189] |
Wed, 12 September 2012 05:19  |
Eclipse User |
|
|
|
Hi Stephan,
For table per class the only solution I can think of is to change the id generation:
http://stackoverflow.com/questions/916169/cannot-use-identity-column-key-generation-with-union-subclass-table-per-clas
You can do this using JPA annotations in the model. The teneo wiki has several pages on documentation on doing this.
Instead of table per class you can also try another approach: use MappedSuperclass with single table. It is similar to
table-per-class but does not go that far. You can use mapped super class to prevent all classes to be stored in one
table. See the jpa documentation and the internet for more information on what Mappedsuperclass does.
You can annotate an eclass with the @MappedSuperclass annotation to control this.
gr. Martin
On 09/11/2012 08:54 AM, Stephan Krusche wrote:
> I try to use the CDO Hibernate Store with Teneo. I want to use the TABLE_PER_CLASS inheritance mapping in my
> cdo-server.xml. This is my configuration file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cdoServer>
>
> <acceptor type="ssl" listenAddr="0.0.0.0" port="2036"></acceptor>
>
> <repository name="test">
> <property name="overrideUUID" value=""/>
> <property name="supportingAudits" value="false"/>
>
> <store type="hibernate">
> <!-- Settings for Teneo -->
> <mappingProvider type="teneo">
> <property name="teneo.mapping.cascade_policy_on_non_containment" value="PERSIST,MERGE"/>
> <property name="teneo.naming.id_feature_as_primary_key" value="true"/>
> <property name="teneo.mapping.inheritance" value="TABLE_PER_CLASS"/>
> <property name="teneo.mapping.add_index_for_fk" value="true"/> </mappingProvider>
>
> <!-- Settings for Hibernate -->
> <property name="hibernate.hbm2ddl.auto" value="update"/>
> <property name="hibernate.show_sql" value="true"/>
> <property name="hibernate.max_fetch_depth" value="3"/>
> <property name="hibernate.connection.pool_size" value="10"/>
> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
>
> <!-- Settings for mysql -->
> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
> <property name="hibernate.connection.url"
> value="jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true"/>
> <property name="hibernate.connection.username" value="test"/>
> <property name="hibernate.connection.password" value="test"/>
> </store>
> </repository>
>
> </cdoServer>
>
>
> When I start the CDO Server, I get the following exception:
>
> Sep 11, 2012 8:36:38 AM org.eclipse.emf.teneo.classloader.ClassLoaderResolver setClassLoaderStrategy
> INFO: Class loader strategy set to: org.eclipse.emf.teneo.classloader.ContextClassLoaderStrategy
> [ERROR] Cannot use identity column key generation with <union-subclass> mapping for: Annotation
> org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for: Annotation
> at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:93)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)
> at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)
> at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:384)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)
> at org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore.getHibernateSessionFactory(HibernateStore.java:260)
> at
> org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.beginHibernateSession(HibernateStoreAccessor.java:194)
> at
> org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.getHibernateSession(HibernateStoreAccessor.java:268)
> at
> org.eclipse.emf.cdo.server.internal.hibernate.HibernateStoreAccessor.queryResources(HibernateStoreAccessor.java:495)
> at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.readResourceID(StoreAccessorBase.java:212)
> at org.eclipse.emf.cdo.internal.server.Repository.readRootResource(Repository.java:1769)
> at org.eclipse.emf.cdo.internal.server.Repository.doActivate(Repository.java:1869)
> at org.eclipse.net4j.util.lifecycle.Lifecycle.activate(Lifecycle.java:76)
> at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:114)
> at org.eclipse.net4j.util.lifecycle.LifecycleUtil.activate(LifecycleUtil.java:104)
> at org.eclipse.emf.cdo.server.CDOServerUtil.addRepository(CDOServerUtil.java:208)
> at org.eclipse.emf.cdo.spi.server.RepositoryConfigurator.configure(RepositoryConfigurator.java:111)
> at org.eclipse.emf.cdo.internal.server.bundle.CDOServerApplication.doStart(CDOServerApplication.java:61)
> at org.eclipse.net4j.util.om.OSGiApplication.start(OSGiApplication.java:63)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
>
>
> It works fine when I try to use a different inheritance mapping like SINGLE_TABLE or JOINED. But for my model (a rather
> big one with a lot of abstract classes and inheritance) I need the TABLE_PER_CLASS mapping to prevent other errors. (If
> I use JOINED, I get an error that MySQL only supports 63 joins, just when I edit one object and try to commit the
> transaction. If I use SINGLE_TABLE, I have only one table in the database representing my whole data model which
> includes 200 attributes and relations. This scenario causes then other Hibernate exceptions)
>
> I also tested the scenario above with a very small example model (just 3 classes) and I get the same exception.
>
> Does CDO Hibernate Store not support the TABLE_PER_CLASS mapping? (I did not find a hint so far)
>
> Is there anything misconfigured so that I get the error message?
>
> Thanks for help!
>
> Stephan
--
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
|
|
|
Powered by
FUDForum. Page generated in 0.06347 seconds