execute method for Session-based lambda expressions.
Implemented by HibernateTemplate. Not often used, but a useful option
to enhance testability, as it can easily be mocked or stubbed.
Defines HibernateTemplate's data access methods that mirror various
org. methods. Users are strongly encouraged to read the
Hibernate Session javadocs for details on the semantics of those methods.
A deprecation note: While HibernateTemplate and this operations
interface are being kept around for backwards compatibility in terms of the data
access implementation style in Spring applications, we strongly recommend the use
of native org. access code for non-trivial interactions.
This in particular affects parameterized queries where - on Java 8+ - a custom
HibernateCallback lambda code block with createQuery and several
setParameter calls on the org. interface
is an elegant solution, to be executed via the general execute method.
All such operations which benefit from a lambda variant have been marked as
deprecated on this interface.
A Hibernate compatibility note: HibernateTemplate and the
operations on this interface generally aim to be applicable across all Hibernate
versions. In terms of binary compatibility, Spring ships a variant for each major
generation of Hibernate (in the present case: Hibernate ORM 5.x). However, due to
refactorings and removals in Hibernate ORM 5.3, some variants - in particular
legacy positional parameters starting from index 0 - do not work anymore.
All affected operations are marked as deprecated; please replace them with the
general execute method and custom lambda blocks creating the queries,
ideally setting named parameters through org..
Please be aware that deprecated operations are known to work with Hibernate
ORM 5.2 but may not work with Hibernate ORM 5.3 and higher anymore.
HibernateTemplate, org.hibernate.Session , HibernateTransactionManager
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the number of instances updated/deletedan update/delete query expressed in Hibernate's query language queryString, Object... the values of the parameters values)
Deprecated
as of 5.0.4, in favor of a custom
Update/delete all objects according to the given query, binding a number of
values to "?" parameters in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public void | clear()
Remove all objects from the |
| public void | closeIterator(Iterator<?>
the it)Iterator to close
Deprecated
as of 5.0.4, in favor of a custom
Immediately close an HibernateCallback
lambda code block passed to the general execute method
Iterator created by any of the various
iterate(..) operations, instead of waiting until the
session is closed or disconnected.
|
| public boolean | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | deleteAll(Collection<?>
the persistent instances to delete entities)Delete all given persistent instances. |
| public Filter | Returns: the enabled HibernateFilter (either already
enabled or enabled on the fly by this operation)the name of the filter filterName)Return an enabled Hibernate |
| public void | evict(Object
the persistent instance to evict entity)Remove the given object from the |
| public <T> T | Returns: a result object returned by the action, ornullcallback object that specifies the Hibernate action action)Execute the action specified by the given action object within a
|
| public List | Returns: aList containing the results of the query executiona query expressed in Hibernate's query language queryString, Object... the values of the parameters values)
Deprecated
as of 5.0.4, in favor of a custom
Execute an HQL query, binding a number of values to "?" parameters
in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing 0 or more persistent instancesthe detached Hibernate criteria object. criteria)Note Do not reuse criteria objects! They need to recreated per execution, due to the suboptimal design of Hibernate's criteria facility. Execute a query based on a given Hibernate criteria object. |
| public List | Returns: aList containing 0 or more persistent instancesthe detached Hibernate criteria object. criteria, int Note Do not reuse criteria objects! They need to recreated per execution, due to the suboptimal design of Hibernate's criteria facility. the index of the first result object to be retrieved
(numbered from 0) firstResult, int the maximum number of result objects to retrieve
(or <=0 for no limit) maxResults)Execute a query based on the given Hibernate criteria object. |
| public <T> List | Returns: aList containing 0 or more persistent instancesan instance of the desired entity,
serving as example for "query-by-example" exampleEntity)Execute a query based on the given example entity object. |
| public <T> List | Returns: aList containing 0 or more persistent instancesthe name of the persistent entity entityName, T an instance of the desired entity,
serving as example for "query-by-example" exampleEntity)Execute a query based on the given example entity object. |
| public <T> List | Returns: aList containing 0 or more persistent instancesan instance of the desired entity,
serving as example for "query-by-example" exampleEntity, int the index of the first result object to be retrieved
(numbered from 0) firstResult, int the maximum number of result objects to retrieve
(or <=0 for no limit) maxResults)Execute a query based on a given example entity object. |
| public <T> List | Returns: aList containing 0 or more persistent instancesthe name of the persistent entity entityName, T an instance of the desired entity,
serving as example for "query-by-example" exampleEntity, int the index of the first result object to be retrieved
(numbered from 0) firstResult, int the maximum number of result objects to retrieve
(or <=0 for no limit) maxResults)Execute a query based on a given example entity object. |
| public List | Returns: aList containing the results of the query executiona query expressed in Hibernate's query language queryString, String the name of the parameter paramName, Object the value of the parameter value)
Deprecated
as of 5.0.4, in favor of a custom
Execute an HQL query, binding one value to a ":" named parameter
in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing the results of the query executiona query expressed in Hibernate's query language queryString, String[] the names of the parameters paramNames, Object[] the values of the parameters values)
Deprecated
as of 5.0.4, in favor of a custom
Execute an HQL query, binding a number of values to ":" named
parameters in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing the results of the query executionthe name of a Hibernate query in a mapping file queryName, Object... the values of the parameters values)
Deprecated
as of 5.0.4, in favor of a custom
Execute a named query binding a number of values to "?" parameters
in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing the results of the query executionthe name of a Hibernate query in a mapping file queryName, String the name of parameter paramName, Object the value of the parameter value)
Deprecated
as of 5.0.4, in favor of a custom
Execute a named query, binding one value to a ":" named parameter
in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing the results of the query executionthe name of a Hibernate query in a mapping file queryName, String[] the names of the parameters paramNames, Object[] the values of the parameters values)
Deprecated
as of 5.0.4, in favor of a custom
Execute a named query, binding a number of values to ":" named
parameters in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing the results of the query executionthe name of a Hibernate query in a mapping file queryName, Object the values of the parameters valueBean)
Deprecated
as of 5.0.4, in favor of a custom
Execute a named query, binding the properties of the given bean to
":" named parameters in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public List | Returns: aList containing the results of the query executiona query expressed in Hibernate's query language queryString, Object the values of the parameters valueBean)
Deprecated
as of 5.0.4, in favor of a custom
Execute an HQL query, binding the properties of the given bean to
named parameters in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public void | |
| public <T> T | Returns: the persistent instance, ornull if not founda persistent class entityClass, Serializable the identifier of the persistent instance id)Return the persistent instance of the given entity class
with the given identifier, or |
| public <T> T | Returns: the persistent instance, ornull if not founda persistent class entityClass, Serializable the identifier of the persistent instance id, LockMode the lock mode to obtain lockMode)Return the persistent instance of the given entity class
with the given identifier, or |
| public Object | Returns: the persistent instance, ornull if not foundthe name of the persistent entity entityName, Serializable the identifier of the persistent instance id)Return the persistent instance of the given entity class
with the given identifier, or |
| public Object | Returns: the persistent instance, ornull if not foundthe name of the persistent entity entityName, Serializable the identifier of the persistent instance id, LockMode the lock mode to obtain lockMode)Return the persistent instance of the given entity class
with the given identifier, or |
| public void | initialize(Object
a proxy for a persistent object or a persistent collection proxy)Force initialization of a Hibernate proxy or persistent collection. |
| public Iterator | Returns: anIterator containing 0 or more persistent instancesa query expressed in Hibernate's query language queryString, Object... the values of the parameters values)
Deprecated
as of 5.0.4, in favor of a custom
Execute a query for persistent instances, binding a number of
values to "?" parameters in the query string.
HibernateCallback
lambda code block passed to the general execute method
|
| public <T> T | Returns: the persistent instancea persistent class entityClass, Serializable the identifier of the persistent instance id)Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. |
| public <T> T | Returns: the persistent instancea persistent class entityClass, Serializable the identifier of the persistent instance id, LockMode the lock mode to obtain lockMode)Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. |
| public Object | Returns: the persistent instancethe name of the persistent entity entityName, Serializable the identifier of the persistent instance id)Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. |
| public Object | Returns: the persistent instancethe name of the persistent entity entityName, Serializable the identifier of the persistent instance id, LockMode the lock mode to obtain lockMode)Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. |
| public void | load(Object
the object (of the target class) to load into entity, Serializable the identifier of the persistent instance id)Load the persistent instance with the given identifier into the given object, throwing an exception if not found. |
| public <T> List | |
| public void | |
| public void | |
| public <T> T | Returns: the updated, registered persistent instancethe object to merge with the corresponding persistence instance entity)Copy the state of the given object onto the persistent object with the same identifier. |
| public <T> T | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | replicate(Object
the persistent object to replicate entity, ReplicationMode the Hibernate ReplicationMode replicationMode)Persist the state of the given detached instance according to the given replication mode, reusing the current identifier value. |
| public void | replicate(String
the name of the persistent entity entityName, Object the persistent object to replicate entity, ReplicationMode the Hibernate ReplicationMode replicationMode)Persist the state of the given detached instance according to the given replication mode, reusing the current identifier value. |
| public Serializable | |
| public Serializable | |
| public void | saveOrUpdate(Object
the persistent instance to save or update
(to be associated with the Hibernate entity)Session)Save or update the given persistent instance, according to its id (matching the configured "unsaved-value"?). |
| public void | saveOrUpdate(String
the name of the persistent entity entityName, Object the persistent instance to save or update
(to be associated with the Hibernate entity)Session)Save or update the given persistent instance, according to its id (matching the configured "unsaved-value"?). |
| public void | update(Object
the persistent instance to update entity)Update the given persistent instance,
associating it with the current Hibernate |
| public void | update(Object
the persistent instance to update entity, LockMode the lock mode to obtain lockMode)Update the given persistent instance,
associating it with the current Hibernate |
| public void | update(String
the name of the persistent entity entityName, Object the persistent instance to update entity)Update the given persistent instance,
associating it with the current Hibernate |
| public void | update(String
the name of the persistent entity entityName, Object the persistent instance to update entity, LockMode the lock mode to obtain lockMode)Update the given persistent instance,
associating it with the current Hibernate |