org.hibernate
Class LockMode

java.lang.Object
  extended byorg.hibernate.LockMode
All Implemented Interfaces:
Serializable

public final class LockMode
extends Object
implements 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.

Author:
Gavin King
See Also:
Session.lock(Object,LockMode), Serialized Form

Field Summary
static LockMode NONE
          No lock required.
static LockMode READ
          A shared lock.
static LockMode UPGRADE
          An upgrade lock.
static LockMode UPGRADE_NOWAIT
          Attempt to obtain an upgrade lock, using an Oracle-style select for update nowait.
static LockMode WRITE
          A WRITE lock is obtained when an object is updated or inserted.
 
Method Summary
 boolean greaterThan(LockMode mode)
          Check if this lock mode is more restrictive than the given lock mode.
 boolean lessThan(LockMode mode)
          Check if this lock mode is less restrictive than the given lock mode.
static LockMode parse(String name)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final LockMode 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

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.


UPGRADE

public static final LockMode UPGRADE
An upgrade lock. Objects loaded in this lock mode are materialized using an SQL select ... for update.


UPGRADE_NOWAIT

public static final LockMode 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

public static final LockMode WRITE
A WRITE lock is obtained when an object is updated or inserted. This is not a valid mode for load() or lock().

Method Detail

toString

public String toString()

greaterThan

public boolean greaterThan(LockMode mode)
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

public boolean lessThan(LockMode mode)
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

public static LockMode parse(String name)