LockOptions (Hibernate JavaDocs)
Date: 2012-04-05

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hibernate
Class LockOptions

    java.lang.Object
      org.hibernate.LockOptions

All Implemented Interfaces:
  Serializable

    public class LockOptions

extends Object
implements Serializable

Contains locking details (LockMode, Timeout and Scope).

See Also:
  Serialized Form

Field Summary
`static int` | `NO_WAIT` Indicates that the database should not wait at all to acquire the pessimistic lock.
`static LockOptions` | `NONE` NONE represents LockMode.NONE (timeout + scope do not apply)
`static LockOptions` | `READ` READ represents LockMode.READ (timeout + scope do not apply)
`static LockOptions` | `UPGRADE` UPGRADE represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked)
`static int` | `WAIT_FOREVER` Indicates that there is no timeout for the acquisition.

Constructor Summary
`LockOptions()`
`LockOptions(LockMode lockMode)`

Method Summary
`static LockOptions` | `copy(LockOptions from, LockOptions dest)` Shallow copy From to Dest
`int` | `getAliasLockCount()` Get the number of aliases that have specific lock modes defined.
`Iterator` | `getAliasLockIterator()` Iterator for accessing Alias (key) and LockMode (value) as Map.Entry
`LockMode` | `getAliasSpecificLockMode(String alias)` Get the `LockMode` explicitly specified for the given alias via `setAliasSpecificLockMode(java.lang.String, org.hibernate.LockMode)` Differs from `getEffectiveLockMode(java.lang.String)` in that here we only return explicitly specified alias-specific lock modes.
`LockMode` | `getEffectiveLockMode(String alias)` Determine the `LockMode` to apply to the given alias.
`LockMode` | `getLockMode()` Retrieve the overall lock mode in effect for this set of options.
`boolean` | `getScope()` Retrieve the current lock scope setting.
`int` | `getTimeOut()` Retrieve the current timeout setting.
`LockOptions` | `setAliasSpecificLockMode(String alias, LockMode lockMode)` Specify the `LockMode` to be used for a specific query alias.
`LockOptions` | `setLockMode(LockMode lockMode)` Set the overall `LockMode` to be used.
`LockOptions` | `setScope(boolean scope)` Set the cope.
`LockOptions` | `setTimeOut(int timeout)` Set the timeout setting.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NONE

    public static final LockOptions NONE

  NONE represents LockMode.NONE (timeout + scope do not apply)

### READ

    public static final LockOptions READ

  READ represents LockMode.READ (timeout + scope do not apply)

### UPGRADE

    public static final LockOptions UPGRADE

  UPGRADE represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked)

### NO_WAIT

    public static final int NO_WAIT

  Indicates that the database should not wait at all to acquire the pessimistic lock.

  See Also:
    `getTimeOut()`, Constant Field Values

### WAIT_FOREVER

    public static final int WAIT_FOREVER

  Indicates that there is no timeout for the acquisition.

  See Also:
    `getTimeOut()`, Constant Field Values

Constructor Detail

### LockOptions

    public LockOptions()

### LockOptions

    public LockOptions(LockMode lockMode)

Method Detail

### getLockMode

    public LockMode getLockMode()

  Retrieve the overall lock mode in effect for this set of options.

  In certain contexts (hql and criteria), lock-modes can be defined in an even more granular `per-alias` fashion

  Returns:
    The overall lock mode.

### setLockMode

    public LockOptions setLockMode(LockMode lockMode)

  Set the overall `LockMode` to be used. The default is `LockMode.NONE`

  Parameters:
    `lockMode` - The new overall lock mode to use.
  Returns:
    this (for method chaining).

### setAliasSpecificLockMode

    public LockOptions setAliasSpecificLockMode(String alias,
                                                LockMode lockMode)

  Specify the `LockMode` to be used for a specific query alias.

  Parameters:
    `alias` - used to reference the LockMode.
    `lockMode` - The lock mode to apply to the given alias
  Returns:
    this LockRequest instance for operation chaining.
  See Also:
    `Query.setLockMode(String, LockMode)`, `Criteria.setLockMode(LockMode)`, `Criteria.setLockMode(String, LockMode)`

### getAliasSpecificLockMode

    public LockMode getAliasSpecificLockMode(String alias)

  Get the `LockMode` explicitly specified for the given alias via `setAliasSpecificLockMode(java.lang.String, org.hibernate.LockMode)`

  Differs from `getEffectiveLockMode(java.lang.String)` in that here we only return explicitly specified alias-specific lock modes.

  Parameters:
    `alias` - The alias for which to locate the explicit lock mode.
  Returns:
    The explicit lock mode for that alias.

### getEffectiveLockMode

    public LockMode getEffectiveLockMode(String alias)

  Determine the `LockMode` to apply to the given alias. If no mode was explicitly `set`, the `overall mode` is returned. If the overall lock mode is `null` as well, `LockMode.NONE` is returned.

  Differs from `getAliasSpecificLockMode(java.lang.String)` in that here we fallback to we only return the overall lock mode.

  Parameters:
    `alias` - The alias for which to locate the effective lock mode.
  Returns:
    The effective lock mode.

### getAliasLockCount

    public int getAliasLockCount()

  Get the number of aliases that have specific lock modes defined.

  Returns:
    the number of explicitly defined alias lock modes.

### getAliasLockIterator

    public Iterator getAliasLockIterator()

  Iterator for accessing Alias (key) and LockMode (value) as Map.Entry

  Returns:
    Iterator for accessing the Map.Entry's

### getTimeOut

    public int getTimeOut()

  Retrieve the current timeout setting.

  The timeout is the amount of time, in milliseconds, we should instruct the database to wait for any requested pessimistic lock acquisition.

  `NO_WAIT` and `WAIT_FOREVER` represent 2 "magic" values.

  Returns:
    timeout in milliseconds, or `NO_WAIT` or `WAIT_FOREVER`

### setTimeOut

    public LockOptions setTimeOut(int timeout)

  Set the timeout setting.

  See `getTimeOut()` for a discussion of meaning.

  Parameters:
    `timeout` - The new timeout setting.
  Returns:
    this (for method chaining).
  See Also:
    `getTimeOut()`

### getScope

    public boolean getScope()

  Retrieve the current lock scope setting.

  "scope" is a JPA defined term. It is basically a cascading of the lock to associations.

  Returns:
    true if locking will be extended to owned associations

### setScope

    public LockOptions setScope(boolean scope)

  Set the cope.

  Parameters:
    `scope` - The new scope setting
  Returns:
    this (for method chaining).

### copy

    public static LockOptions copy(LockOptions from,
                                   LockOptions dest)

  Shallow copy From to Dest

  Parameters:
    `from` - is copied from
    `dest` - is copied to
  Returns:
    dest

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.