Rely on the data default mechanism:
Hibernate's lock modes are:
Ølockmode.none: no lock mechanism.
Ølockmode.write:hibernate automatically when insert and update records
Get.
The ølockmode.read:hibernate is automatically retrieved when the record is read.
These three locking mechanisms are typically used internally by hibernate, such as hibernate to ensure that the update
The object is not modified by the outside world, and a write lock is automatically added to the target object in the Save method implementation.
Ølockmode.upgrade: Use the database's for UPDATE clause to lock.
Ølockmode. Specific implementations of Upgrade_nowait:oracle, using Oracle's for UPDATE NOWAIT clauses for locking
==========================
Pessimistic lock: The SQL statement issued by the for update is different
Criteria.setlockmode
Query.setlockmode
Session.lock
==========================
Optimistic Lock:
Time stamp
Version control
==========================
Hibernate lock mechanism