I'm using a legacy database schema with composite keys. I have an entity with two relationships and one of the join columns is shared.
For example, Let's say i have a Student entity with two relationships Department and Course. Department uses dept_code column while Course uses dept_code and course_code colum. The domain model is such that a student might belong to a department and not opted for a course yet or the student might have chosen both department and course. This is how the hibernate mapping looks like:
<many-to-one class="Department" name="department">
<column name="dept_code"/>
</many-to-one>
<many-to-one class="Course" name="course>
<column name="dept_code"/>
<column name="course_code"/>
</many-to-one>
The problem is Hibernate does not allow this mapping unless one of the relationships is marked readonly using insert=false and update=false.
Is there a way to have both relationships writable?