Package org.hibernate
Class QueryException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
IllegalNamedQueryOptionsException
,IllegalQueryOperationException
,InterpretationException
,NamedQueryValidationException
,ParsingException
,QueryParameterException
,SemanticException
,SyntaxException
,UnknownNamedQueryException
public class QueryException extends HibernateException
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:
SyntaxException
, which represents a syntax error in the HQL query, andSemanticException
, which represents an error in the semantics of the query.
- See Also:
SemanticException
,SyntaxException
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QueryException(Exception cause)
Deprecated.this constructor does not carry information about the query which caused the failureQueryException(String message)
Deprecated.this constructor does not carry information about the query which caused the failureQueryException(String message, Exception cause)
Deprecated.this constructor does not carry information about the query which caused the failureQueryException(String message, String queryString)
Constructs aQueryException
using the specified exception message and query string.QueryException(String message, String queryString, Exception cause)
Constructs aQueryException
using the specified exception message and query string.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected QueryException
generateQueryException(String queryString)
Called fromwrapWithQueryString(String)
when we really need to generate a newQueryException
(or subclass).String
getMessage()
protected String
getOriginalMessage()
String
getQueryString()
Retrieve the query being evaluated when the exception occurred.QueryException
wrapWithQueryString(String queryString)
Deprecated, for removal: This API element is subject to removal in a future version.This method is no longer used-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
QueryException
@Deprecated(since="6.3") public QueryException(String message)
Deprecated.this constructor does not carry information about the query which caused the failureConstructs aQueryException
using the specified exception message.- Parameters:
message
- A message explaining the exception condition
-
QueryException
@Deprecated(since="6.3") public QueryException(String message, Exception cause)
Deprecated.this constructor does not carry information about the query which caused the failureConstructs aQueryException
using the specified exception message and cause.- Parameters:
message
- A message explaining the exception conditioncause
- The underlying cause
-
QueryException
public QueryException(String message, String queryString)
Constructs aQueryException
using the specified exception message and query string.- Parameters:
message
- A message explaining the exception conditionqueryString
- The query being evaluated when the exception occurred
-
QueryException
public QueryException(String message, String queryString, Exception cause)
Constructs aQueryException
using the specified exception message and query string.- Parameters:
message
- A message explaining the exception conditionqueryString
- The query being evaluated when the exception occurredcause
- The underlying cause
-
QueryException
@Deprecated(since="6.3") public QueryException(Exception cause)
Deprecated.this constructor does not carry information about the query which caused the failureConstructs aQueryException
using the specified cause.- Parameters:
cause
- The underlying cause
-
-
Method Detail
-
getQueryString
public String getQueryString()
Retrieve the query being evaluated when the exception occurred. May be null, but generally should not be.- Returns:
- The query string
-
getMessage
public String getMessage()
- Overrides:
getMessage
in classThrowable
-
getOriginalMessage
protected final String getOriginalMessage()
-
wrapWithQueryString
@Deprecated(since="6.2", forRemoval=true) public final QueryException wrapWithQueryString(String queryString)
Deprecated, for removal: This API element is subject to removal in a future version.This method is no longer usedWraps this exception with another, of same kind, with the specified query string. If this exception already has a query string defined, the same exception (this
) is returned. Otherwise, the protectedgenerateQueryException(String)
is called, to allow subclasses to properly create the correct subclass for return.- Parameters:
queryString
- The query string that led to the QueryException- Returns:
this
, ifthis
hasnull
forgetQueryString()
; otherwise a newQueryException
(or subclass) is returned.
-
generateQueryException
protected QueryException generateQueryException(String queryString)
Called fromwrapWithQueryString(String)
when we really need to generate a newQueryException
(or subclass).- Parameters:
queryString
- The query string- Returns:
- The generated
QueryException
(or subclass) - See Also:
getOriginalMessage()
- Implementation Note:
- implementors should take care to use
getOriginalMessage()
for the message, notgetMessage()
-
-