Package org.hibernate
Class QueryException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
IllegalNamedQueryOptionsException,IllegalQueryOperationException,InterpretationException,QueryParameterException,SemanticException,UnknownNamedQueryException
public class QueryException extends HibernateException
A problem occurred translating a Hibernate query to SQL due to invalid query syntax, or some similar problem.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QueryException(Exception cause)Constructs aQueryExceptionusing the specified cause.QueryException(String message)Constructs aQueryExceptionusing the specified exception message.QueryException(String message, Exception cause)Constructs aQueryExceptionusing the specified exception message and cause.QueryException(String message, String queryString)Constructs aQueryExceptionusing the specified exception message and query string.QueryException(String message, String queryString, Exception cause)Constructs aQueryExceptionusing the specified exception message and query string.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected QueryExceptiongenerateQueryException(String queryString)Called fromwrapWithQueryString(String)when we really need to generate a newQueryException(or subclass).StringgetMessage()protected StringgetOriginalMessage()StringgetQueryString()Retrieve the query being evaluated when the exception occurred.QueryExceptionwrapWithQueryString(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
public QueryException(String message)
Constructs aQueryExceptionusing the specified exception message.- Parameters:
message- A message explaining the exception condition
-
QueryException
public QueryException(String message, Exception cause)
Constructs aQueryExceptionusing 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 aQueryExceptionusing 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 aQueryExceptionusing 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
public QueryException(Exception cause)
Constructs aQueryExceptionusing 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:
getMessagein 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, ifthishasnullforgetQueryString(); 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()
-
-