org.hibernate.Query |
Known Indirect Subclasses |
An object-oriented representation of a Hibernate query. A Query instance is obtained by calling Session.createQuery(). This interface exposes some extra functionality beyond that provided by Session.iterate() and Session.find():
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Execute the update or delete statement.
| |||||||||||
Return the names of all named parameters of the query.
| |||||||||||
Get the query string.
| |||||||||||
Return the HQL select clause aliases (if any)
| |||||||||||
Return the Hibernate types of the query result set.
| |||||||||||
Should entities and proxies loaded by this Query be put in read-only mode? If the
read-only/modifiable setting was not initialized, then the default
read-only/modifiable setting for the persistence context is returned instead.
| |||||||||||
Return the query results as an Iterator.
| |||||||||||
Return the query results as a List.
| |||||||||||
Return the query results as ScrollableResults.
| |||||||||||
Return the query results as ScrollableResults.
| |||||||||||
Override the current session cache mode, just for
this query.
| |||||||||||
Set the name of the cache region.
| |||||||||||
Enable caching of this query result set.
| |||||||||||
Add a comment to the generated SQL.
| |||||||||||
Bind an instance of a mapped persistent class to a named query parameter.
| |||||||||||
Bind an instance of a mapped persistent class to a JDBC-style query parameter.
| |||||||||||
Set a fetch size for the underlying JDBC query.
| |||||||||||
Set the first row to retrieve.
| |||||||||||
Override the current session flush mode, just for
this query.
| |||||||||||
Set the lockmode for the objects idententified by the
given alias that appears in the FROM clause.
| |||||||||||
Set the lock options for the objects idententified by the
given alias that appears in the FROM clause.
| |||||||||||
Set the maximum number of rows to retrieve.
| |||||||||||
Bind a value to a JDBC-style query parameter.
| |||||||||||
Bind a value to a named query parameter.
| |||||||||||
Bind a value to a JDBC-style query parameter.
| |||||||||||
Bind a value to a named query parameter.
| |||||||||||
Bind multiple values to a named query parameter.
| |||||||||||
Bind multiple values to a named query parameter.
| |||||||||||
Bind multiple values to a named query parameter.
| |||||||||||
Bind multiple values to a named query parameter.
| |||||||||||
Bind values and types to positional parameters.
| |||||||||||
Bind the values of the given Map for each named parameters of the query,
matching key names with parameter names and mapping value types to
Hibernate types using hueristics.
| |||||||||||
Bind the property values of the given bean to named parameters of the query,
matching property names with parameter names and mapping property types to
Hibernate types using hueristics.
| |||||||||||
Set the read-only/modifiable mode for entities and proxies
loaded by this Query.
| |||||||||||
Set a strategy for handling the query results.
| |||||||||||
Set a timeout for the underlying JDBC query.
| |||||||||||
Convenience method to return a single instance that matches
the query, or null if the query returns no results.
|
Execute the update or delete statement.
The semantics are compliant with the ejb3 Query.executeUpdate() method.HibernateException |
---|
Return the names of all named parameters of the query.
HibernateException |
---|
Return the HQL select clause aliases (if any)
HibernateException |
---|
Return the Hibernate types of the query result set.
HibernateException |
---|
Should entities and proxies loaded by this Query be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context is returned instead.
Return the query results as an Iterator. If the query
contains multiple results pre row, the results are returned in
an instance of Object[].
Entities returned as results are initialized on demand. The first
SQL query returns identifiers only.
HibernateException |
---|
Return the query results as a List. If the query contains multiple results pre row, the results are returned in an instance of Object[].
HibernateException |
---|
Return the query results as ScrollableResults. The
scrollability of the returned results depends upon JDBC driver
support for scrollable ResultSets.
HibernateException |
---|
Return the query results as ScrollableResults. The
scrollability of the returned results depends upon JDBC driver
support for scrollable ResultSets.
HibernateException |
---|
Override the current session cache mode, just for this query.
Set the name of the cache region.
cacheRegion | the name of a query cache region, or null for the default query cache |
---|
Enable caching of this query result set.
cacheable | Should the query results be cacheable? |
---|
Add a comment to the generated SQL.
comment | a human-readable string |
---|
Bind an instance of a mapped persistent class to a named query parameter.
name | the name of the parameter |
---|---|
val | a non-null instance of a persistent class |
Bind an instance of a mapped persistent class to a JDBC-style query parameter.
position | the position of the parameter in the query string, numbered from 0. |
---|---|
val | a non-null instance of a persistent class |
Set a fetch size for the underlying JDBC query.
fetchSize | the fetch size |
---|
Set the first row to retrieve. If not set, rows will be retrieved beginnning from row 0.
firstResult | a row number, numbered from 0 |
---|
Override the current session flush mode, just for this query.
Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.
alias | a query alias, or this for a collection filter |
---|
Set the lock options for the objects idententified by the given alias that appears in the FROM clause.
Set the maximum number of rows to retrieve. If not set, there is no limit to the number of rows retrieved.
maxResults | the maximum number of rows |
---|
Bind a value to a JDBC-style query parameter.
position | the position of the parameter in the query string, numbered from 0. |
---|---|
val | the possibly-null parameter value |
type | the Hibernate type |
Bind a value to a named query parameter.
name | the name of the parameter |
---|---|
val | the possibly-null parameter value |
type | the Hibernate type |
Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the given object.
position | the position of the parameter in the query string, numbered from 0. |
---|---|
val | the non-null parameter value |
HibernateException | if no type could be determined |
---|
Bind a value to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the given object.
name | the name of the parameter |
---|---|
val | the non-null parameter value |
HibernateException | if no type could be determined |
---|
Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
name | the name of the parameter |
---|---|
vals | a collection of values to list |
HibernateException |
---|
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
name | the name of the parameter |
---|---|
vals | a collection of values to list |
type | the Hibernate type of the values |
HibernateException |
---|
Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the array. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
name | the name of the parameter |
---|---|
vals | a collection of values to list |
HibernateException |
---|
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).
name | the name of the parameter |
---|---|
vals | a collection of values to list |
type | the Hibernate type of the values |
HibernateException |
---|
Bind values and types to positional parameters.
HibernateException |
---|
Bind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using hueristics.
bean | a java.util.Map |
---|
HibernateException |
---|
Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using hueristics.
bean | any JavaBean or POJO |
---|
HibernateException |
---|
Set the read-only/modifiable mode for entities and proxies loaded by this Query. This setting overrides the default setting for the persistence context.
readOnly | true, entities and proxies loaded by the query will be put in read-only mode false, entities and proxies loaded by the query will be put in modifiable mode |
---|
To set the default read-only/modifiable setting used for
entities and proxies that are loaded into the session:
setDefaultReadOnly(boolean)
Read-only entities are not dirty-checked and snapshots of persistent
state are not maintained. Read-only entities can be modified, but
changes are not persisted.
When a proxy is initialized, the loaded entity will have the same
read-only/modifiable setting as the uninitialized
proxy has, regardless of the session's current setting.
The read-only/modifiable setting has no impact on entities/proxies
returned by the query that existed in the session before the query was executed.
Set a strategy for handling the query results. This can be used to change "shape" of the query result.
transformer | The transformer to apply |
---|
Set a timeout for the underlying JDBC query.
timeout | the timeout in seconds |
---|
Convenience method to return a single instance that matches the query, or null if the query returns no results.
NonUniqueResultException | if there is more than one matching result |
---|---|
HibernateException |