I have a association table for a many to many relation. This table contains extra fields.
So I have the following tables / objects:
Person
id
name
PersonLanguage
personId
languageId
speaked
written
updateCount
Language
id
code
The mapping, from the Person.hbm.xml file, looks like this:
Code:
<set name="languages" table="Person_Language">
<key column="Version_Id"/>
<composite-element class="PersonLanguage">
<property name="guiOnly" column="speaked" type="boolean"/>
<property name="guiDefault" column="written" type="boolean"/>
<many-to-one name="language" class="Language" column="Language_Id" outer-join="false"/>
</composite-element>
</set>
The problem is that I'm using optimistic locking with a version property. In our current (and established) database schema, we have a version column for the association table
Person_Language
update_count
However, I can't specify a <version> tag in a <composite-element> tag.
How can I map a version property for optimistic locking residing in an association table?