I've run into problems with my mappings and a mapping from one class to another class (which is mapped using a joined-subclass).
Mapping for class A:
Code:
<?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>
<class
name="ClassA"
dynamic-update="false"
dynamic-insert="false"
mutable="true"
>
<id name="id" column="ClassAId" type="java.lang.String">
<generator class="uuid.hex">
</generator>
</id>
<version name="hbmVersion" type="long" column="hbmVersion" access="field" />
<one-to-one
access="field"
cascade="all"
class="ClassB"
name="classB"
property-ref="classA"
/>
</class>
</hibernate-mapping>
Mapping for ClassB
Code:
<?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>
<joined-subclass
name="ClassB"
extends="ParentOfB"
dynamic-update="false"
dynamic-insert="false"
>
<key column="ParentOfBId" />
<many-to-one
class="ClassA"
unique="true"
access="property"
cascade="all"
property-ref="classB"
name="ClassA"
/>
</joined-subclass>
</hibernate-mapping>
The mappingsfile compiles until it reaches the processing of one-to-one relations:
Code:
12:00:51,390 INFO [Configuration] processing one-to-one association property references
12:00:51,390 INFO [Configuration] processing foreign key constraints
The error is:
Code:
Caused by: net.sf.hibernate.MappingException: property mapping has wrong number of columns: ClassB.classA type: ClassA
at net.sf.hibernate.mapping.PersistentClass.validate(PersistentClass.java:269)
at net.sf.hibernate.mapping.Subclass.validate(Subclass.java:141)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:576)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:733)
Any ideas would be welcome.
-------------------
Hibernate: 2.1.2
Java: 1.4.2_03