Hibernate在多对多关联的两侧增加版本

时间:2015-06-10 21:40:17

标签: java hibernate concurrency locking optimistic-locking

我不确定这是一个错误还是一个功能。我有一个类Training的以下映射,其中包含一个包含" 要求"的集合:

<!-- 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> 

当我将一个未更改且持久的Requirement实例(从数据库中新鲜出现)添加到此集合时,两个实例的版本( Training Requirement < / em>)增加。虽然 - 从技术上讲 - 只有Training实例是脏的。这通常吗?

0 个答案:

没有答案