# Class OptimisticLockException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.cayenne.CayenneRuntimeException
org.apache.cayenne.access.OptimisticLockException

All Implemented Interfaces:
  `Serializable`

public class OptimisticLockException extends CayenneRuntimeException
An exception thrown on optimistic lock failure.

Since:
  1.1
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OptimisticLockException(ObjectId id, DbEntity rootEntity, Map<String,?> qualifierSnapshot, TranslatedStatement statement)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ObjectId`
  `getFailedObjectId()`
  Returns the ObjectId of the object that caused the OptimisticLockException.
  `Map<?,?>`
  `getFreshSnapshot(ObjectContext context)`
  Retrieves fresh snapshot for the failed row.
  `String`
  `getMessage()`
  Returns descriptive message for this exception.
  `Map`
  `getQualifierSnapshot()`
  `String`
  `getQuerySQL()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  in favor of `getStatement()`
  `TranslatedStatement`
  `getStatement()`

  ### Methods inherited from class CayenneRuntimeException

  `getExceptionLabel, getUnlabeledMessage`

  ### Methods inherited from class Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### OptimisticLockException

    public OptimisticLockException(ObjectId id, DbEntity rootEntity, Map<String,?> qualifierSnapshot, TranslatedStatement statement)

- ## Method Details

  - ### getStatement

    public TranslatedStatement getStatement()
    Since:
      5.0

  - ### getQualifierSnapshot

    public Map getQualifierSnapshot()

  - ### getQuerySQL

    @Deprecated(since="5.0", forRemoval=true) public String getQuerySQL()
    Deprecated, for removal: This API element is subject to removal in a future version.
    in favor of `getStatement()`

  - ### getFreshSnapshot

    public Map<?,?> getFreshSnapshot(ObjectContext context)
    Retrieves fresh snapshot for the failed row. Null row indicates that it was deleted.
    Since:
      3.0

  - ### getMessage

    public String getMessage()
    Returns descriptive message for this exception.
    Overrides:
      `getMessage` in class `CayenneRuntimeException`

  - ### getFailedObjectId

    public ObjectId getFailedObjectId()
    Returns the ObjectId of the object that caused the OptimisticLockException.
    Since:
      3.1