In fact I did some deeper investigations and my problem is a little bit more tricky.
My bar class have two many-to-one associations with two classes with composite-keys and they share one column. Here is the sample code :
Bar.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="Bar" table="BAR">
<id name="id">
<generator class="increment" />
</id>
<many-to-one name="foo" class="Foo" update="false" insert="false">
<column name="FOO_ID1" />
<column name="FOO_ID2" />
</many-to-one>
<many-to-one name="other" class="Other" update="false" insert="false">
<column name="FOO_ID1" />
<column name="FOO_ID3" />
</many-to-one>
<property name="text"/>
</class>
</hibernate-mapping>
Foo.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="Foo" table="FOO">
<composite-id>
<key-property name="id1"/>
<key-property name="id2"/>
</composite-id>
<property name="text"/>
</class>
</hibernate-mapping>
Other.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="Other" table="OTHER">
<composite-id>
<key-property name="id1"/>
<key-property name="id3"/>
</composite-id>
<property name="text"/>
</class>
</hibernate-mapping>
I have a Bar instance associated with a Other instance (in my business logic, one bar instance could be associated with a Other instance OR a Foo instance). If I try to load it I have an UnresolvableObjectException.
Is there any solution to this problem ?
Thanx
Seb