001/*
002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved.
003 *
004 * This program and the accompanying materials are made available under the
005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
006 * which accompanies this distribution.  The Eclipse Public License is available
007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
008 * is available at http://www.eclipse.org/org/documents/edl-v10.php.
009 */
010package javax.persistence;
011
012/**
013 * Thrown by the persistence provider when an pessimistic locking
014 * conflict occurs that does not result in transaction rollback. This
015 * exception may be thrown as part of an API call, at, flush or at
016 * commit time. The current transaction, if one is active, will be not
017 * be marked for rollback.
018 *
019 * @since Java Persistence 2.0
020 */
021public class LockTimeoutException extends PersistenceException {
022  /**
023   * The object that caused the exception
024   */
025  Object entity;
026
027  /**
028   * Constructs a new <code>LockTimeoutException</code> exception
029   * with <code>null</code> as its detail message.
030   */
031  public LockTimeoutException() {
032    super();
033  }
034
035  /**
036   * Constructs a new <code>LockTimeoutException</code> exception
037   * with the specified detail message.
038   *
039   * @param message the detail message.
040   */
041  public LockTimeoutException(String message) {
042    super(message);
043  }
044
045  /**
046   * Constructs a new <code>LockTimeoutException</code> exception
047   * with the specified detail message and cause.
048   *
049   * @param message the detail message.
050   * @param cause   the cause.
051   */
052  public LockTimeoutException(String message, Throwable cause) {
053    super(message, cause);
054  }
055
056  /**
057   * Constructs a new <code>LockTimeoutException</code> exception
058   * with the specified cause.
059   *
060   * @param cause the cause.
061   */
062  public LockTimeoutException(Throwable cause) {
063    super(cause);
064  }
065
066  /**
067   * Constructs a new <code>LockTimeoutException</code> exception
068   * with the specified object.
069   *
070   * @param entity the entity.
071   */
072  public LockTimeoutException(Object entity) {
073    this.entity = entity;
074  }
075
076  /**
077   * Constructs a new <code>LockTimeoutException</code> exception
078   * with the specified detail message, cause, and entity.
079   *
080   * @param message the detail message.
081   * @param cause   the cause.
082   * @param entity  the entity.
083   */
084  public LockTimeoutException(String message, Throwable cause, Object entity) {
085    super(message, cause);
086    this.entity = entity;
087  }
088
089  /**
090   * Returns the object that caused this exception.
091   *
092   * @return the entity
093   */
094  public Object getObject() {
095    return this.entity;
096  }
097}