-->
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.  [ 2 posts ] 
Author Message
 Post subject: subclass of subclass
PostPosted: Fri Apr 08, 2011 11:06 am 
Newbie

Joined: Fri Apr 08, 2011 10:54 am
Posts: 2
I have a 3 level heirarchy that is basically a Parent Class, a Child Class (which adds additional variables to the Parent), and a Grandchild (which is really more of a sibling, but the code extends from the Child...it is just a special version of the Child, does not add any variables).

I created the parent class, and then used the <joined-subclass> to create a child class. Now I am trying to create a subclass of that and I can't figure out how. I know that hibernate does not support the mixing of subclass and joined-subclass, but I can not even create a joined-subclass grandchild. Is there another way of doing this? Here are my hbm.xml files:

Parent:
Code:
<hibernate-mapping>
    <class name="com.xxxxx.model.Entity" table="tbl_entity" catalog="mydb">
        <id name="objectID" type="string">
            <column name="objectid" />
            <generator class="assigned" />
        </id>
        <discriminator column="class_type" type="string"/>
        <property name="objectURI" type="string">
            <column name="uri" length="1024" />
        </property>
        <property name="parentURI" formula="( SELECT DISTINCT e.uri FROM tbl_entity e WHERE e.objectid = parent_id )"/>
        <property name="copy" type="string">
            <column name="copy" length="45" />
        </property>
        <property name="move" type="string">
            <column name="move" length="45" />
        </property>
        <property name="completionStatus" type="string">
            <column name="completionStatus" length="45" />
        </property>
        <property name="percentComplete" type="java.lang.Integer">
            <column name="percentComplete" />
        </property>
    </class>
</hibernate-mapping>


Child:
Code:
<hibernate-mapping>
   <joined-subclass name="com.xxxxx.model.Container" table="tbl_container" extends="com.xxxxx.model.Entity">
      <key column="objectid"/>
   <property name="containerSnapshot" type="string">
             <column name="snapshot" length="45" />
        </property>
   </joined-subclass>
</hibernate-mapping>


Grandchild:
Code:
<hibernate-mapping>
   <joined-subclass name="com.xxxxx.model.RootContainer" table="tbl_rootcontainer" extends="com.xxxxx.model.Container">
      <key column="objectid"/>
   </joined-subclass>
</hibernate-mapping>


I believe my problem is extends="com.xxxxx.model.Container" because I can change the Grandchild to extend Entity, but then I don't get my Container fields...


Top
 Profile  
 
 Post subject: Re: subclass of subclass
PostPosted: Fri Apr 08, 2011 11:09 am 
Newbie

Joined: Fri Apr 08, 2011 10:54 am
Posts: 2
Also, this is the error I get:

Code:
2011-04-08 11:07:57,464 ERROR [main] org.hibernate.util.JDBCExceptionReporter: Cannot add or update a child row: a foreign key constraint fails (`mydb`.`tbl_container`, CONSTRAINT `FK649DF140BFE7F01F` FOREIGN KEY (`objectid`) REFERENCES `tbl_container` (`objectid`) ON UPDATE CASCADE)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException


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

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.