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 a query times out
014 * and only the statement is rolled back.
015 * The current transaction, if one is active, will be not
016 * be marked for rollback.
017 *
018 * @since Java Persistence 2.0
019 */
020public class QueryTimeoutException extends PersistenceException {
021  /**
022   * The query object that caused the exception
023   */
024  Query query;
025
026  /**
027   * Constructs a new <code>QueryTimeoutException</code> exception
028   * with <code>null</code> as its detail message.
029   */
030  public QueryTimeoutException() {
031    super();
032  }
033
034  /**
035   * Constructs a new <code>QueryTimeoutException</code> exception
036   * with the specified detail message.
037   *
038   * @param message the detail message.
039   */
040  public QueryTimeoutException(String message) {
041    super(message);
042  }
043
044  /**
045   * Constructs a new <code>QueryTimeoutException</code> exception
046   * with the specified detail message and cause.
047   *
048   * @param message the detail message.
049   * @param cause   the cause.
050   */
051  public QueryTimeoutException(String message, Throwable cause) {
052    super(message, cause);
053  }
054
055  /**
056   * Constructs a new <code>QueryTimeoutException</code> exception
057   * with the specified cause.
058   *
059   * @param cause the cause.
060   */
061  public QueryTimeoutException(Throwable cause) {
062    super(cause);
063  }
064
065
066  /**
067   * Constructs a new <code>QueryTimeoutException</code> exception
068   * with the specified query.
069   *
070   * @param query the query.
071   */
072  public QueryTimeoutException(Query query) {
073    this.query = query;
074  }
075
076  /**
077   * Constructs a new <code>QueryTimeoutException</code> exception
078   * with the specified detail message, cause, and query.
079   *
080   * @param message the detail message.
081   * @param cause   the cause.
082   * @param query   the query.
083   */
084  public QueryTimeoutException(String message, Throwable cause, Query query) {
085    super(message, cause);
086    this.query = query;
087  }
088
089  /**
090   * Returns the query that caused this exception.
091   *
092   * @return the query.
093   */
094  public Query getQuery() {
095    return this.query;
096  }
097}