As I understand the above, this question:
Quote:
1. Only two levels of inheritance with joined subclass
(i.e. can't declare a joined subclass extending another joined subclass)
was answered with this answer:
Quote:
There is, of course, no limit to the depth of inheritance in Hibernate.
I am trying to create a mapping that has a single base class, a subclass, and a sub-subclass, and I have seemed to encounter the problem that there is no way to map the sub-subclass without getting a MappingException at code-generation time. Say C inherits from B inherits from from A. When code generating C, I get the following error even if B generates successfully:
Code:
net.sf.hibernate.MappingException: Cannot extend unmapped class com.twcaustin.intranet.myforms.model.B
I am using Oracel 9, Hibernate 2.1.6, with the following mapping files:
A.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.twcaustin.intranet.myforms.model">
<class name="com.twcaustin.intranet.myforms.model.A" table="A">
<id
name="id"
type="java.lang.Long"
column="ID"
unsaved-value="null"
access="property">
<generator class="sequence">
<param name="sequence">seq_ID</param>
</generator>
</id>
<version name="name" type="string" column="name" unsaved-value="null" />
</class>
</hibernate-mapping>
B.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.twcaustin.intranet.myforms.model">
<joined-subclass name="com.twcaustin.intranet.myforms.model.B"
extends="com.twcaustin.intranet.myforms.model.A"
table="B" >
<key column="ID" foreign-key="id" />
<property name="title" column="TITLE" type="string" />
</joined-subclass>
</hibernate-mapping>
C.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.twcaustin.intranet.myforms.model">
<joined-subclass name="com.twcaustin.intranet.myforms.model.C"
extends="com.twcaustin.intranet.myforms.model.B"
table="C" >
<key column="ID" foreign-key="id" />
<property name="ln" column="LN" type="string" />
</joined-subclass>
</hibernate-mapping>
I am using an ANT task that looks like this, which I have been using successfully to generate other Hibernate classes for some time:
Code:
<java classname="net.sf.hibernate.tool.hbm2java.CodeGenerator" fork="true">
<classpath refid="hibernate.classpath" />
<classpath location="${hbmdata.jar}" />
<arg value="--output=${gensrc}" />
<arg line="${hbm.files}" />
</java>
here is the complete stack trace for the error given by the generator:
Code:
[java] net.sf.hibernate.MappingException: Cannot extend unmapped class com.twcaustin.intranet.myforms.model.B
[java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.handleClass(CodeGenerator.java:137)
[java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:109)
I have found this error in the bug database, but it says it was fixed 22/Jul/04 05:12 PM, which is before the release of 2.1.6:
http://opensource.atlassian.com/project ... se/HB-1097
Is it fixed, or am I doing something wrong?