Package org.hibernate
Class LockMode
java.lang.Object
org.hibernate.LockMode
- All Implemented Interfaces:
Serializable
Instances represent a lock mode for a row of a relational
database table. It is not intended that users spend much
time worrying about locking since Hibernate usually
obtains exactly the right lock level automatically.
Some "advanced" users may wish to explicitly specify lock
levels.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LockModeDeprecated.instead use PESSIMISTIC_FORCE_INCREMENTstatic final LockModeNo lock required.static final LockModeOptimisticly assume that transaction will not experience contention for entities.static final LockModeOptimisticly assume that transaction will not experience contention for entities.static final LockModeTransaction will immediately increment the entity version.static final LockModeImplemented as PESSIMISTIC_WRITE.static final LockModeTransaction will obtain a database lock immediately.static final LockModeA shared lock.static final LockModeDeprecated.instead use PESSIMISTIC_WRITEstatic final LockModeAttempt to obtain an upgrade lock, using an Oracle-style select for update nowait.static final LockModeA WRITE lock is obtained when an object is updated or inserted. -
Method Summary
-
Field Details
-
NONE
No lock required. If an object is requested with this lock mode, a READ lock will be obtained if it is necessary to actually read the state from the database, rather than pull it from a cache.
This is the "default" lock mode. -
READ
A shared lock. Objects in this lock mode were read from the database in the current transaction, rather than being pulled from a cache. -
UPGRADE
Deprecated.instead use PESSIMISTIC_WRITEAn upgrade lock. Objects loaded in this lock mode are materialized using an SQL select ... for update. -
UPGRADE_NOWAIT
Attempt to obtain an upgrade lock, using an Oracle-style select for update nowait. The semantics of this lock mode, once obtained, are the same as UPGRADE. -
WRITE
A WRITE lock is obtained when an object is updated or inserted. This lock mode is for internal use only and is not a valid mode for load() or lock() (both of which throw exceptions if WRITE is specified). -
FORCE
Deprecated.instead use PESSIMISTIC_FORCE_INCREMENTSimiliar toUPGRADEexcept that, for versioned entities, it results in a forced version increment. -
OPTIMISTIC
Optimisticly assume that transaction will not experience contention for entities. The entity version will be verified near the transaction end. -
OPTIMISTIC_FORCE_INCREMENT
Optimisticly assume that transaction will not experience contention for entities. The entity version will be verified and incremented near the transaction end. -
PESSIMISTIC_READ
Implemented as PESSIMISTIC_WRITE. TODO: introduce separate support for PESSIMISTIC_READ -
PESSIMISTIC_WRITE
Transaction will obtain a database lock immediately. TODO: add PESSIMISTIC_WRITE_NOWAIT -
PESSIMISTIC_FORCE_INCREMENT
Transaction will immediately increment the entity version.
-
-
Method Details
-
toString
-
greaterThan
Check if this lock mode is more restrictive than the given lock mode.- Parameters:
mode- LockMode to check- Returns:
- true if this lock mode is more restrictive than given lock mode
-
lessThan
Check if this lock mode is less restrictive than the given lock mode.- Parameters:
mode- LockMode to check- Returns:
- true if this lock mode is less restrictive than given lock mode
-
parse
-