Top Description Fields Constructors Methods
org.hibernate

public Class QueryException

extends HibernateException
Class Inheritance
Known Direct Subclasses
org.hibernate.QueryParameterException, org.hibernate.query.IllegalNamedQueryOptionsException, org.hibernate.query.IllegalQueryOperationException, org.hibernate.query.NamedQueryValidationException, org.hibernate.query.SemanticException, org.hibernate.query.SyntaxException, org.hibernate.query.UnknownNamedQueryException, org.hibernate.query.sqm.InterpretationException, org.hibernate.query.sqm.ParsingException

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:

See Also
org.hibernate.query.SemanticException, org.hibernate.query.SyntaxException

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
QueryException(String
A message explaining the exception condition
message
)

Deprecated since 6.3. this constructor does not carry information about the query which caused the failure
Constructs a QueryException using the specified exception message.
public
QueryException(String
A message explaining the exception condition
message
,
Exception
The underlying cause
cause
)

Deprecated since 6.3. this constructor does not carry information about the query which caused the failure
Constructs a QueryException using the specified exception message and cause.
public
QueryException(String
A message explaining the exception condition
message
,
String
The query being evaluated when the exception occurred
queryString
)

Constructs a QueryException using the specified exception message and query string.

public
QueryException(String
A message explaining the exception condition
message
,
String
The query being evaluated when the exception occurred
queryString
,
Exception
The underlying cause
cause
)

Constructs a QueryException using the specified exception message and query string.

public
QueryException(Exception
The underlying cause
cause
)

Deprecated since 6.3. this constructor does not carry information about the query which caused the failure
Constructs a QueryException using the specified cause.

Method Summary

Modifier and TypeMethod and Description
protected QueryException

Returns:

The generated QueryException (or subclass)
generateQueryException
(String
The query string
queryString
)

Called from wrapWithQueryString(String) when we really need to generate a new QueryException (or subclass).

public String
getMessage()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.
protected final String
public String

Returns:

The query string
getQueryString
()

Retrieve the query being evaluated when the exception occurred.

public final QueryException

Returns:

this, if this has null for getQueryString(); otherwise a new QueryException (or subclass) is returned.
wrapWithQueryString
(String
The query string that led to the QueryException
queryString
)

Deprecated for removal since 6.2. This method is no longer used
Wraps this exception with another, of same kind, with the specified query string.

Field Detail

queryStringback to summary
private final String queryString

Constructor Detail

QueryExceptionback to summary
public QueryException(String message)

Deprecated

since 6.3.

this constructor does not carry information about the query which caused the failure

Constructs a QueryException using the specified exception message.

Parameters
message:String

A message explaining the exception condition

Annotations
@Deprecated
since:6.3
QueryExceptionback to summary
public QueryException(String message, Exception cause)

Deprecated

since 6.3.

this constructor does not carry information about the query which caused the failure

Constructs a QueryException using the specified exception message and cause.

Parameters
message:String

A message explaining the exception condition

cause:Exception

The underlying cause

Annotations
@Deprecated
since:6.3
QueryExceptionback to summary
public QueryException(String message, String queryString)

Constructs a QueryException using the specified exception message and query string.

Parameters
message:String

A message explaining the exception condition

queryString:String

The query being evaluated when the exception occurred

QueryExceptionback to summary
public QueryException(String message, String queryString, Exception cause)

Constructs a QueryException using the specified exception message and query string.

Parameters
message:String

A message explaining the exception condition

queryString:String

The query being evaluated when the exception occurred

cause:Exception

The underlying cause

QueryExceptionback to summary
public QueryException(Exception cause)

Deprecated

since 6.3.

this constructor does not carry information about the query which caused the failure

Constructs a QueryException using the specified cause.

Parameters
cause:Exception

The underlying cause

Annotations
@Deprecated
since:6.3

Method Detail

generateQueryExceptionback to summary
protected QueryException generateQueryException(String queryString)

Called from wrapWithQueryString(String) when we really need to generate a new QueryException (or subclass).

Implementation Note

implementors should take care to use getOriginalMessage() for the message, not getMessage()

Parameters
queryString:String

The query string

Returns:QueryException

The generated QueryException (or subclass)

See Also
getOriginalMessage()
getMessageback to summary
public String getMessage()

Overrides java.lang.Throwable.getMessage.

Doc from java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Returns:String

the detail message string of this Throwable instance (which may be null).

Annotations
@Override
getOriginalMessageback to summary
protected final String getOriginalMessage()
getQueryStringback to summary
public String getQueryString()

Retrieve the query being evaluated when the exception occurred. May be null, but generally should not be.

Returns:String

The query string

wrapWithQueryStringback to summary
public final QueryException wrapWithQueryString(String queryString)

Deprecated

for removal since 6.2.

This method is no longer used

Wraps 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 protected generateQueryException(String) is called, to allow subclasses to properly create the correct subclass for return.

Parameters
queryString:String

The query string that led to the QueryException

Returns:QueryException

this, if this has null for getQueryString(); otherwise a new QueryException (or subclass) is returned.

Annotations
@Deprecated
since:6.2
forRemoval:true