JPA and default locking mode

前端 未结 3 2126
無奈伤痛
無奈伤痛 2020-12-14 02:18

With JPA, we can use manually OPTIMISTIC or PESSIMISTIC locking to handle entity changes in transactions.

I wonder how JPA handles locking

3条回答
  •  不思量自难忘°
    2020-12-14 02:33

    In the specification persistence_2.0, page 89:

    If a versioned object is otherwise updated or removed, then the implementation must ensure that the requirements of LockModeType.OPTIMISTIC_FORCE_INCREMENT are met, even if no explicit call to EntityManager.lock was made.

提交回复
热议问题