Hibernate version: 3.1.2
I'm trying to use entity-name to map a series of objects to two different tables, but I get the following error on startup:
Code:
Caused by: org.hibernate.MappingException: persistent class not known: uk.co.formfill.dfcommon.domain.dfwv.NoteHeader
at org.hibernate.cfg.Configuration$1.getIdentifierType(Configuration.java:1917)
at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:226)
at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:236)
at org.hibernate.type.ManyToOneType.getColumnSpan(ManyToOneType.java:41)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.ToOne.isValid(ToOne.java:82)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:395)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
... 193 more
This appears to relate to the following extracts from mapping files:
Code:
<hibernate-mapping package="uk.co.formfill.dfcommon.domain.dfwv">
<class name="uk.co.formfill.dfcommon.domain.dfwv.NoteDetail"
table="NOTE_DETAILS"
entity-name="FlowNoteDetail">
....
<many-to-one name="noteHeader"
entity-name="FlowNoteHeader"
foreign-key="NOTE_HEADERS_FK" index="HEADER_IDX">
<meta attribute="use-in-tostring">true</meta>
<column name="NOTE_HEADERS_ID" not-null="true" />
</many-to-one>
Code:
<hibernate-mapping package="uk.co.formfill.dfcommon.domain.dfwv">
<class name="uk.co.formfill.dfcommon.domain.dfwv.NoteHeader"
table="NOTE_HEADERS"
entity-name="FlowNoteHeader">
...
<set name="details" inverse="true" lazy="false" cascade="all" order-by="DATE_CREATED desc">
<meta attribute="use-in-tostring">false</meta>
<key column="NOTE_HEADERS_ID" />
<one-to-many class="uk.co.formfill.dfcommon.domain.dfwv.NoteDetail"
entity-name="FlowNoteDetail" />
</set>
This seems to be because the code in question is trying to find the object in the classes map using the full class name as a key, whereas they are stored under the key of the entity name.
Is this a bug or have I made a mistake in the mappings?
I would be very grateful for any help as I am almost at the stage of having to give up on trying to get the entity-name feature to work is I cannot resolve this issue.