以下の確認をお願いします:
public void test() {
SomeEntity se = em.find(SomeEntity.class, 1);
// Do something...
se.setField = "test";
}
ここで、JPAはで楽観的なチェックのみを実行しseます。
次 :
public void test() {
SomeEntity se = em.find(SomeEntity.class, 1);
SomeOtherEntity soe = em.find(SomeOtherEntity.class, 1);
em.lock(soe, LockModeType.OPTIMISTIC);
// Do something...
se.setField = "test";
}
seここで、最後の読み取り以降にORsoeが変更された(データベースでバージョンがインクリメントされた)場合、JPAはOptimisticExceptionをスローします。
本当 ?