Hi, first time here so bear with me! I had a working many-to-many relation, that needed changing to two one-to-many relations. I've done this successfully in 2 other parts of my program, but this third is causing me trouble. The problem is that the class is relating to itself.
Setup:
CDDefinition: contains a set of CDReferences
CDReference: contains 2 CDDefinition's with different names
Since CDReference must relate to the primary key of CDDefinition, it ends up with having two many-to-one mappings using the same column, which causes issues.
Hope thats clear enough! Any insight or information would be appreciated.
David
.hbm.xml files
Code:
<hibernate-mapping package="openmath.model">
<class name="CDReference" table="cdreferences">
<id name="id" column="ref_id">
<generator class="increment"/>
</id>
<version name="version" column="version"/>
<many-to-one name="from" column="def_id" insert="false" update="false"/>
<many-to-one name="to" column="def_id" insert="false" update="false"/>
</class>
</hibernate-mapping>
<hibernate-mapping package="openmath.model">
<class name="CDDefinition" table="cddefinitions">
<id name="id" column="def_id">
<generator class="increment"/>
</id>
<version name="version" column="version"/>
...
<set name="references">
<key column="def_id"/>
<one-to-many class="CDReference"/>
</set>
</class>
</hibernate-mapping>