This enumeration of lock modes competes with the JPA-defined
LockModeType, but offers additional options, including
UPGRADE_NOWAIT and UPGRADE_SKIPLOCKED.
Session#lock(Object, LockMode), LockModeType, LockOptions, org.hibernate.annotations.OptimisticLocking
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final int | |
| public static final LockMode | NONE
No lock required. |
| public static final LockMode | OPTIMISTIC
A shared optimistic lock. |
| public static final LockMode | OPTIMISTIC_FORCE_INCREMENT
A kind of exclusive optimistic lock. |
| public static final LockMode | PESSIMISTIC_FORCE_INCREMENT
A pessimistic write lock which immediately increments the version of the locked object. |
| public static final LockMode | PESSIMISTIC_READ
A pessimistic shared lock, which prevents concurrent transactions from writing the locked object. |
| public static final LockMode | PESSIMISTIC_WRITE
A pessimistic upgrade lock, which prevents concurrent transactions from reading or writing the locked object. |
| public static final LockMode | READ
A shared lock. |
| public static final LockMode | UPGRADE_NOWAIT
A pessimistic upgrade lock, obtained using an Oracle-style
|
| public static final LockMode | UPGRADE_SKIPLOCKED
A pessimistic upgrade lock, obtained using an Oracle-style
|
| public static final LockMode | WRITE
An exclusive write lock. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static LockMode | |
| public static LockMode | |
| public boolean | Returns: true if this lock mode is more restrictive than given lock modeLockMode to check mode)Check if this lock mode is more restrictive than the given lock mode. |
| public boolean | |
| public String | |
| public static LockModeType | |
| public LockModeType | |
| public LockOptions | Returns: an instance ofLockOptions with this lock mode, and
all other settings defaulted.
|
| public static LockMode | |
| public static LockMode[] |
| externalForm | back to summary |
|---|---|
| private final String externalForm | |
| level | back to summary |
|---|---|
| private final int level | |
| NONE | back to summary |
|---|---|
| public static final LockMode NONE No lock required. If an object is requested with this lock
mode, a
This is the "default" lock mode, the mode requested by calling
| |
| OPTIMISTIC | back to summary |
|---|---|
| public static final LockMode OPTIMISTIC A shared optimistic lock. Assumes that the current transaction will not experience contention for the state of an entity. The version will be checked near the end of the transaction, to verify that this was indeed the case.
Note that, despite the similar names this lock mode is not the
same as the JPA-defined mode | |
| OPTIMISTIC_FORCE_INCREMENT | back to summary |
|---|---|
| public static final LockMode OPTIMISTIC_FORCE_INCREMENT A kind of exclusive optimistic lock. Assumes that the current transaction will not experience contention for the state of an entity. The version will be checked and incremented near the end of the transaction, to verify that this was indeed the case, and to signal to concurrent optimistic readers that their optimistic locks have failed. | |
| PESSIMISTIC_FORCE_INCREMENT | back to summary |
|---|---|
| public static final LockMode PESSIMISTIC_FORCE_INCREMENT A pessimistic write lock which immediately increments
the version of the locked object. Obtained by immediate
execution of an | |
| PESSIMISTIC_READ | back to summary |
|---|---|
| public static final LockMode PESSIMISTIC_READ A pessimistic shared lock, which prevents concurrent
transactions from writing the locked object. Obtained via
a
On databases which do not support
| |
| PESSIMISTIC_WRITE | back to summary |
|---|---|
| public static final LockMode PESSIMISTIC_WRITE A pessimistic upgrade lock, which prevents concurrent
transactions from reading or writing the locked object.
Obtained via a
| |
| READ | back to summary |
|---|---|
| public static final LockMode 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.
Note that this lock mode is the same as the JPA-defined modes
| |
| UPGRADE_NOWAIT | back to summary |
|---|---|
| public static final LockMode UPGRADE_NOWAIT A pessimistic upgrade lock, obtained using an Oracle-style
| |
| UPGRADE_SKIPLOCKED | back to summary |
|---|---|
| public static final LockMode UPGRADE_SKIPLOCKED A pessimistic upgrade lock, obtained using an Oracle-style
| |
| WRITE | back to summary |
|---|---|
| public static final LockMode WRITE An exclusive write lock. Objects in this lock mode were updated or inserted in the database in the current transaction.
This lock mode is for internal use only and is not a legal
argument to
Note that, despite the similar names, this lock mode is not
the same as the JPA-defined mode | |
| LockMode | back to summary |
|---|---|
| private LockMode(int level, String externalForm) | |
| fromExternalForm | back to summary |
|---|---|
| public static LockMode fromExternalForm(String externalForm) | |
| fromJpaLockMode | back to summary |
|---|---|
| public static LockMode fromJpaLockMode(LockModeType lockMode) | |
| greaterThan | back to summary |
|---|---|
| public boolean greaterThan(LockMode mode) Check if this lock mode is more restrictive than the given lock mode.
| |
| lessThan | back to summary |
|---|---|
| public boolean lessThan(LockMode mode) Check if this lock mode is less restrictive than the given lock mode.
| |
| toExternalForm | back to summary |
|---|---|
| public String toExternalForm() | |
| toJpaLockMode | back to summary |
|---|---|
| public static LockModeType toJpaLockMode(LockMode lockMode) | |
| toJpaLockMode | back to summary |
|---|---|
| public LockModeType toJpaLockMode() | |
| toLockOptions | back to summary |
|---|---|
public LockOptions toLockOptions()
| |
| valueOf | back to summary |
|---|---|
| public static LockMode valueOf(String name) | |
| values | back to summary |
|---|---|
| public static LockMode[] values() | |