-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: AssertionFailure: Table not found when using discriminator
PostPosted: Tue Jun 03, 2008 5:34 pm 
Newbie

Joined: Tue Jun 03, 2008 3:19 pm
Posts: 2
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" />
                ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.