Package org.hibernate
Class QueryException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
QueryParameterException
public class QueryException extends HibernateException
A problem occurred translating a Hibernate query to SQL due to invalid query syntax, etc.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QueryException(Exception cause)Constructs a QueryException using the specified cause.QueryException(String message)Constructs a QueryException using the specified exception message.QueryException(String message, Exception cause)Constructs a QueryException using the specified exception message and cause.QueryException(String message, String queryString)Constructs a QueryException using the specified exception message and query-string.QueryException(String message, String queryString, Exception cause)Constructs a QueryException using the specified exception message and query-string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected QueryExceptiongenerateQueryException(String queryString)Called fromwrapWithQueryString(String)when we really need to generate a new QueryException (or subclass).StringgetMessage()protected StringgetOriginalMessage()StringgetQueryString()Retrieve the query being evaluated when the exception occurred.QueryExceptionwrapWithQueryString(String queryString)Wraps this exception with another, of same kind, with the specified queryString.-
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 a QueryException using the specified exception message.- Parameters:
message- A message explaining the exception condition
-
QueryException
public QueryException(String message, Exception cause)
Constructs a QueryException 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 a QueryException 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 a QueryException 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
public QueryException(Exception cause)
Constructs a QueryException 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.- Returns:
- The query string
-
getMessage
public String getMessage()
- Overrides:
getMessagein classThrowable
-
getOriginalMessage
protected final String getOriginalMessage()
-
wrapWithQueryString
public final QueryException wrapWithQueryString(String queryString)
Wraps this exception with another, of same kind, with the specified queryString. If this exception already has a queryString 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 new QueryException (or subclass) is returned.
-
generateQueryException
protected QueryException generateQueryException(String queryString)
Called fromwrapWithQueryString(String)when we really need to generate a new QueryException (or subclass). NOTE : implementors should take care to usegetOriginalMessage()for the message, notgetMessage()- Parameters:
queryString- The query string- Returns:
- The generated QueryException (or subclass)
- See Also:
getOriginalMessage()
-
-