Package org.hibernate
Class QueryException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- javax.persistence.PersistenceException
-
- org.hibernate.HibernateException
-
- org.hibernate.QueryException
-
- All Implemented Interfaces:
java.io.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(java.lang.Exception cause)
Constructs a QueryException using the specified cause.QueryException(java.lang.String message)
Constructs a QueryException using the specified exception message.QueryException(java.lang.String message, java.lang.Exception cause)
Constructs a QueryException using the specified exception message and cause.QueryException(java.lang.String message, java.lang.String queryString)
Constructs a QueryException using the specified exception message and query-string.QueryException(java.lang.String message, java.lang.String queryString, java.lang.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 QueryException
generateQueryException(java.lang.String queryString)
Called fromwrapWithQueryString(String)
when we really need to generate a new QueryException (or subclass).java.lang.String
getMessage()
protected java.lang.String
getOriginalMessage()
java.lang.String
getQueryString()
Retrieve the query being evaluated when the exception occurred.QueryException
wrapWithQueryString(java.lang.String queryString)
Wraps this exception with another, of same kind, with the specified queryString.
-
-
-
Constructor Detail
-
QueryException
public QueryException(java.lang.String message)
Constructs a QueryException using the specified exception message.- Parameters:
message
- A message explaining the exception condition
-
QueryException
public QueryException(java.lang.String message, java.lang.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(java.lang.String message, java.lang.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(java.lang.String message, java.lang.String queryString, java.lang.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(java.lang.Exception cause)
Constructs a QueryException using the specified cause.- Parameters:
cause
- The underlying cause
-
-
Method Detail
-
getQueryString
public java.lang.String getQueryString()
Retrieve the query being evaluated when the exception occurred. May be null, but generally should not.- Returns:
- The query string
-
getMessage
public java.lang.String getMessage()
- Overrides:
getMessage
in classjava.lang.Throwable
-
getOriginalMessage
protected final java.lang.String getOriginalMessage()
-
wrapWithQueryString
public final QueryException wrapWithQueryString(java.lang.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
, ifthis
hasnull
forgetQueryString()
; otherwise a new QueryException (or subclass) is returned.
-
generateQueryException
protected QueryException generateQueryException(java.lang.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()
-
-