An easy one for most:
I have the following mapping files:
The parent is called Instance.hbm.xml
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ctlm.persistence.hibernatemapping"> <class name="com.blah.blah.instance.Instance" table="in_instance">
<id name="MIdentifier" column="instanceid#"> <generator class="assigned"/> </id>
<property name="_mState" column="STATE"></property> <one-to-one name="_theCreditHolder" class="com.blah.blah.instance.Person"/> </class>
</hibernate-mapping>
and a child called Person.hbm.xml:
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.blah.persistence.hibernatemapping">
<class name="com.blah.blah.instance.Person" table="IN_PERSON" check="id in ('1', '2', '3')"> <composite-id mapped="true"> <key-property name="_instanceId" column="INSTANCEID#"/> <key-property name="id" column="PERSONID#"/> </composite-id> <property name="_mAcademicTitle" column="P_ACADEMICTITLE" type="java.lang.String"/> <property name="_mBirthDate" column="P_BIRTHDATE" type="Date" /> <property name="_mBirthLand" column="P_BIRTHLAND" type="java.lang.String"/> </class> </hibernate-mapping>
I have had the Instance file working, taking data in and out of the database, but when I add the Person one-to-one property it fails with an error: Caused by: org.hibernate.MappingException: invalid join columns for association
I figure it has something to do with the way I am mapping the id. Basically (I am working with both a legacy application and database), I have a primary key in the Instance table of instanceid# and a composite key in the Person table of instanceid# and personid#.
Can anyone help?
|