Hibernate version: 3
Hi
I use polymorphism "Table per concrete class" and if I define in union-subclass a many-to-one mapping then I have to do that in other union-subclass too, otherwise an exception is thrown. I've spent a long time to found that bug/feature.
Code:
<hibernate-mapping>
<class name="com.kovine.kfe.dao.WidgetType" abstract="true">
<id name="id" column="WIDGET_ID">
<generator class="foreign">
<param name="property">widget</param>
</generator>
</id>
<one-to-one name="widget" class="com.kovine.kfe.dao.Widget" constrained="true" />
<union-subclass name="com.kovine.kfe.dao.WidgetTypeSeparationLine" table="KFE_WIDGET_TYPE_SEPLINE">
<!-- mapping 1 -->
<many-to-one unique="true" name="tableColumn" class="com.kovine.kfe.dao.TableColumn" cascade="all" column="TABLE_COLUMN_ID" not-null="true" />
</union-subclass>
<union-subclass name="com.kovine.kfe.dao.WidgetTypeText" table="KFE_WIDGET_TYPE_INPUTTEXT">
<!-- mapping 2 -->
<many-to-one unique="true" name="tableColumn" class="com.kovine.kfe.dao.TableColumn" cascade="all" column="TABLE_COLUMN_ID" not-null="true" />
<property name="width" column="WIDTH"></property>
<property name="deletable" column="DELETABLE" not-null="true" />
</union-subclass>
<hibernate-mapping>
Using this mapping it is not possible to omit "mapping 1" xor "mapping 2" otherwise after the Hibernate initialization following exception is thrown (short version):
Code:
INFO SessionFactoryImpl - building session factory
ERROR HibernateUtil - Initial SessionFactory creation failed.
org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
...
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
Caused by: java.lang.ExceptionInInitializerError
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:34)
at com.kovine.kfe.beans.BusinessCaseList.getList(BusinessCaseList.java:64)
... 80 more
Caused by: org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
... 81 more
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
Caused by: javax.faces.el.EvaluationException: Bean: com.kovine.kfe.beans.BusinessCaseList, property: list
at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:423)
at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:104)
at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:555)
at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:441)
... 71 more
Caused by: java.lang.reflect.InvocationTargetException
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:324)
at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:419)
... 75 more
Caused by: java.lang.ExceptionInInitializerError
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:34)
at com.kovine.kfe.beans.BusinessCaseList.getList(BusinessCaseList.java:64)
... 80 more
Caused by: org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
... 81 more
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
Caused by: org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
... 81 more
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
java.lang.reflect.InvocationTargetException
Caused by: java.lang.ExceptionInInitializerError
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:34)
at com.kovine.kfe.beans.BusinessCaseList.getList(BusinessCaseList.java:64)
... 80 more
Caused by: org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
... 81 more
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
java.lang.ExceptionInInitializerError
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:34)
...
Caused by: org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
... 81 more
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
org.hibernate.MappingException: Could not determine type for column TABLE_COLUMN_ID of type org.hibernate.type.ManyToOneType: org.hibernate.MappingException
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:131)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
...
Caused by: org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
... 87 more
org.hibernate.MappingException: Unknown entity: com.kovine.kfe.dao.TableColumn
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:489)
at org.hibernate.impl.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:563)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:216)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:226)
at org.hibernate.type.ManyToOneType.sqlTypes(ManyToOneType.java:29)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:124)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.generateSubquery(UnionSubclassEntityPersister.java:320)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:135)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at com.kovine.kfe.HibernateUtil.<clinit>(HibernateUtil.java:30)
...
Please help me to solve this issue
Thanks in advance
Martin