All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.QueryException Maven / Gradle / Ivy

There is a newer version: 7.0.0.Beta3
Show newest version
/*
 * SPDX-License-Identifier: LGPL-2.1-or-later
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate;

/**
 * A problem occurred translating a Hibernate query to SQL due to illegal query
 * syntax, an operation which is not well-typed, an unresolvable reference to
 * an entity or attribute, an unknown named query, or any similar problem. This
 * exception type is not used to represent failures that occur while executing
 * a query or reading the result set of a query.
 * 

* The two most important subtypes are: *

    *
  • {@link org.hibernate.query.SyntaxException}, which represents a syntax * error in the HQL query, and *
  • {@link org.hibernate.query.SemanticException}, which represents an error * in the semantics of the query. *
* * @see org.hibernate.query.SemanticException * @see org.hibernate.query.SyntaxException */ public class QueryException extends HibernateException { private final String queryString; /** * Constructs a {@code QueryException} using the specified exception message. * * @param message A message explaining the exception condition * * @deprecated this constructor does not carry information * about the query which caused the failure */ @Deprecated(since = "6.3") public QueryException(String message) { this( message, null, null ); } /** * Constructs a {@code QueryException} using the specified exception message and cause. * * @param message A message explaining the exception condition * @param cause The underlying cause * * @deprecated this constructor does not carry information * about the query which caused the failure */ @Deprecated(since = "6.3") public QueryException(String message, Exception cause) { this( message, null, cause ); } /** * Constructs a {@code QueryException} using the specified exception message and query string. * * @param message A message explaining the exception condition * @param queryString The query being evaluated when the exception occurred */ public QueryException(String message, String queryString) { this( message, queryString, null ); } /** * Constructs a {@code QueryException} using the specified exception message and query string. * * @param message A message explaining the exception condition * @param queryString The query being evaluated when the exception occurred * @param cause The underlying cause */ public QueryException(String message, String queryString, Exception cause) { super( message, cause ); this.queryString = queryString; } /** * Constructs a {@code QueryException} using the specified cause. * * @param cause The underlying cause * * @deprecated this constructor does not carry information * about the query which caused the failure */ @Deprecated(since = "6.3") public QueryException(Exception cause) { this( "A query exception occurred", null, cause ); } /** * Retrieve the query being evaluated when the exception occurred. * May be null, but generally should not be. * * @return The query string */ public String getQueryString() { return queryString; } @Override public String getMessage() { String msg = getOriginalMessage(); if ( queryString != null ) { msg += " [" + queryString + ']'; } return msg; } protected final String getOriginalMessage() { return super.getMessage(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy