Using 3.2.6 GA on Tomcat 5.5 with MySql 5.
We are modifying an existing Hibernate implemention to use "Table per subclass, using a discriminator" as described
here
Seems simple enough, but we keep getting Table not found errors. I have searched this topic, and it seems to occur when using Annotations, not XML files.
Here are some minimal files:
Code:
<hibernate-mapping>
<class name="mydomain.Content" table="Content" batch-size="10" abstract="true">
<id name="id" column="Id" type="int">
<generator class="native" />
</id>
<discriminator column="CONTENT_TYPE" type="string"/>
<version name="version" type="int" column="Version" />
<many-to-one name="createdBy" class="mydomain.User" column="CreatedBy" not-null="true" />
<property name="createdDate" column="CreatedDate" type="imm_timestamp" not-null="true" />
<many-to-one name="lastModifiedBy" class="mydomain.User" column="LastModifiedBy" not-null="true" />
<property name="lastModifiedDate" column="LastModifiedDate" type="imm_timestamp" not-null="true" />
<many-to-one name="lockOwner" column="LockOwnerId" class="mydomain.User" />
<many-to-one name="process" column="ProcessId" cascade="all" />
<many-to-one name="primaryCategory" column="PrimaryCategoryId" class="mydomain.Category" />
<property name="lastScheduledDate" column="LastScheduledDate" type="imm_timestamp" />
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<subclass name="mydomain.Article" extends="mydomain.Content"
discriminator-value="ARTICLE">
<join table="Article">
<key column="ArticleId" />
<property name="title" column="Subtitle" type="string" not-null="true" />
<property name="author" column="Author" type="string" not-null="true" />
</join>
</subclass>
</hibernate-mapping>
If I add the properties to the joined Article table, I get:
Code:
Caused by:
org.hibernate.AssertionFailure: Table Article not found
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:458)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:237)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
If I simply use
Code:
<join table="Article">
<key column="ArticleId" />
</join>
then things start up properly.
We are moving from joined-subclasses, which work fine:
Code:
<joined-subclass name="mydomain.Article" table="Article" extends="mydomain.Content">
<key column="ArticleId" />
...