Hibernate increments version on both sides of many to many association

143 views Asked by At

I am not sure if this is a bug or a feature. I have the following mapping for the class Training that has a collection holding "requirements":

<!-- unidirectional many-to-many with requirements -->
<set name="requirements" table="TRAINING_VORAUSSETZUNG"
     lazy="false" cascade="persist,merge,save-update" inverse="false">
  <key>
    <column name="`AUSBILDUNGSGANG_ID`" not-null="true" />
  </key>
  <many-to-many class="de.mlp.cu.pollux.ausbildung.Requirement" unique="false">
    <column name="`REQUIREMENT_ID`"></column>
  </many-to-many>
</set> 

And when I add a non altered and persistent Requirement instance - which comes fresh from the database - to this collection, the version of both instances (Training and Requirement) get incremented. Although - technically - only the Training instance is dirty. Is this usual?

0

There are 0 answers