org.springframework.orm.hibernate
Interface HibernateOperations

All Known Implementing Classes:
HibernateTemplate

public interface HibernateOperations

Interface that specifies a basic set of Hibernate operations. Implemented by HibernateTemplate. Not often used, but a useful option to enhance testability, as it can easily be mocked or stubbed.

Provides HibernateTemplate's data access methods that mirror various Session methods. See the Hibernate Session javadocs for details on those methods.

Note that operations that return an Iterator (i.e. iterate) are supposed to be used within Spring-driven or JTA-driven transactions (with HibernateTransactionManager, JtaTransactionManager, or EJB CMT). Else, the Iterator won't be able to read results from its ResultSet anymore, as the underlying Hibernate Session will already have been closed.

Lazy loading will also just work with an open Hibernate Session, either within a transaction or within OpenSessionInViewFilter/Interceptor. Furthermore, some operations just make sense within transactions, for example: contains, evict, lock, flush, clear.

Since:
05.02.2004
Author:
Juergen Hoeller
See Also:
HibernateTemplate, Session, iterate(java.lang.String), HibernateTransactionManager, JtaTransactionManager, OpenSessionInViewFilter, OpenSessionInViewInterceptor

Method Summary
 void clear()
          Remove all objects from the Session cache, and cancel all pending saves, updates and deletes.
 void closeIterator(Iterator it)
          Close an Iterator created by iterate operations immediately, instead of waiting until the session is closed or disconnected.
 boolean contains(Object entity)
          Check whether the given object is in the Session cache.
 void delete(Object entity)
          Delete the given persistent instance.
 void delete(Object entity, net.sf.hibernate.LockMode lockMode)
          Delete the given persistent instance.
 int delete(String queryString)
          Delete all objects returned by the query.
 int delete(String queryString, Object[] values, net.sf.hibernate.type.Type[] types)
          Delete all objects returned by the query.
 int delete(String queryString, Object value, net.sf.hibernate.type.Type type)
          Delete all objects returned by the query.
 void deleteAll(Collection entities)
          Delete all given persistent instances.
 void evict(Object entity)
          Remove the given object from the Session cache.
 Object execute(HibernateCallback action)
          Execute the action specified by the given action object within a Session.
 List executeFind(HibernateCallback action)
          Execute the specified action assuming that the result object is a List.
 List find(String queryString)
          Execute a query for persistent instances.
 List find(String queryString, Object value)
          Execute a query for persistent instances, binding one value to a "?"
 List find(String queryString, Object[] values)
          Execute a query for persistent instances, binding a number of values to "?"
 List find(String queryString, Object[] values, net.sf.hibernate.type.Type[] types)
          Execute a query for persistent instances, binding a number of values to "?"
 List find(String queryString, Object value, net.sf.hibernate.type.Type type)
          Execute a query for persistent instances, binding one value to a "?"
 List findByNamedParam(String queryString, String[] paramNames, Object[] values)
          Execute a query for persistent instances, binding a number of values to ":" named parameters in the query string.
 List findByNamedParam(String queryString, String[] paramNames, Object[] values, net.sf.hibernate.type.Type[] types)
          Execute a query for persistent instances, binding a number of values to ":" named parameters in the query string.
 List findByNamedParam(String queryName, String paramName, Object value)
          Execute a query for persistent instances, binding one value to a ":" named parameter in the query string.
 List findByNamedParam(String queryName, String paramName, Object value, net.sf.hibernate.type.Type type)
          Execute a query for persistent instances, binding one value to a ":" named parameter in the query string.
 List findByNamedQuery(String queryName)
          Execute a named query for persistent instances.
 List findByNamedQuery(String queryName, Object value)
          Execute a named query for persistent instances, binding one value to a "?"
 List findByNamedQuery(String queryName, Object[] values)
          Execute a named query for persistent instances, binding a number of values to "?"
 List findByNamedQuery(String queryName, Object[] values, net.sf.hibernate.type.Type[] types)
          Execute a named query for persistent instances, binding a number of values to "?"
 List findByNamedQuery(String queryName, Object value, net.sf.hibernate.type.Type type)
          Execute a named query for persistent instances, binding one value to a "?"
 List findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
          Execute a named query for persistent instances, binding a number of values to ":" named parameters in the query string.
 List findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values, net.sf.hibernate.type.Type[] types)
          Execute a named query for persistent instances, binding a number of values to ":" named parameters in the query string.
 List findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
          Execute a named query for persistent instances, binding one value to a ":" named parameter in the query string.
 List findByNamedQueryAndNamedParam(String queryName, String paramName, Object value, net.sf.hibernate.type.Type type)
          Execute a named query for persistent instances, binding one value to a ":" named parameter in the query string.
 List findByNamedQueryAndValueBean(String queryName, Object valueBean)
          Execute a named query for persistent instances, binding the properties of the given bean to ":" named parameters in the query string.
 List findByValueBean(String queryString, Object valueBean)
          Execute a query for persistent instances, binding the properties of the given bean to named parameters in the query string.
 void flush()
          Flush all pending saves, updates and deletes to the database.
 Object get(Class entityClass, Serializable id)
          Return the persistent instance of the given entity class with the given identifier, or null if not found.
 Object get(Class entityClass, Serializable id, net.sf.hibernate.LockMode lockMode)
          Return the persistent instance of the given entity class with the given identifier, or null if not found.
 void initialize(Object proxy)
          Force initialization of a Hibernate proxy or persistent collection.
 Iterator iterate(String queryString)
          Execute a query for persistent instances.
 Iterator iterate(String queryString, Object value)
          Execute a query for persistent instances, binding one value to a "?"
 Iterator iterate(String queryString, Object[] values)
          Execute a query for persistent instances, binding a number of values to "?"
 Iterator iterate(String queryString, Object[] values, net.sf.hibernate.type.Type[] types)
          Execute a query for persistent instances, binding a number of values to "?"
 Iterator iterate(String queryString, Object value, net.sf.hibernate.type.Type type)
          Execute a query for persistent instances, binding one value to a "?"
 Object load(Class entityClass, Serializable id)
          Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found.
 Object load(Class entityClass, Serializable id, net.sf.hibernate.LockMode lockMode)
          Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found.
 void load(Object entity, Serializable id)
          Load the persistent instance with the given identifier into the given object, throwing an exception if not found.
 List loadAll(Class entityClass)
          Return all persistent instances of the given entity class.
 void lock(Object entity, net.sf.hibernate.LockMode lockMode)
          Obtain the specified lock level upon the given object, implicitly checking whether the corresponding database entry still exists (throwing an OptimisticLockingFailureException if not found).
 void refresh(Object entity)
          Re-read the state of the given persistent instance.
 void refresh(Object entity, net.sf.hibernate.LockMode lockMode)
          Re-read the state of the given persistent instance.
 void replicate(Object entity, net.sf.hibernate.ReplicationMode replicationMode)
          Persist the state of the given detached instance according to the given replication mode, reusing the current identifier value.
 Serializable save(Object entity)
          Persist the given transient instance.
 void save(Object entity, Serializable id)
          Persist the given transient instance with the given identifier.
 void saveOrUpdate(Object entity)
          Save or update the given persistent instance, according to its id (matching the configured "unsaved-value"?).
 void saveOrUpdateAll(Collection entities)
          Save or update all given persistent instances, according to its id (matching the configured "unsaved-value"?).
 Object saveOrUpdateCopy(Object entity)
          Save or update the contents of given persistent object, according to its id (matching the configured "unsaved-value"?).
 void update(Object entity)
          Update the given persistent instance.
 void update(Object entity, net.sf.hibernate.LockMode lockMode)
          Update the given persistent instance.
 

Method Detail

execute

Object execute(HibernateCallback action)
               throws DataAccessException
Execute the action specified by the given action object within a Session. Application exceptions thrown by the action object get propagated to the caller (can only be unchecked). Hibernate exceptions are transformed into appropriate DAO ones. Allows for returning a result object, i.e. a domain object or a collection of domain objects.

Note: Callback code is not supposed to handle transactions itself! Use an appropriate transaction manager like HibernateTransactionManager. Generally, callback code must not touch any Session lifecycle methods, like close, disconnect, or reconnect, to let the template do its work.

Parameters:
action - callback object that specifies the Hibernate action
Returns:
a result object returned by the action, or null
Throws:
DataAccessException - in case of Hibernate errors
See Also:
HibernateTransactionManager, org.springframework.dao, org.springframework.transaction, Session

executeFind

List executeFind(HibernateCallback action)
                 throws DataAccessException
Execute the specified action assuming that the result object is a List. This is a convenience method for executing Hibernate find calls or queries within an action.

Parameters:
action - calback object that specifies the Hibernate action
Returns:
a List result returned by the action, or null
Throws:
DataAccessException - in case of Hibernate errors

get

Object get(Class entityClass,
           Serializable id)
           throws DataAccessException
Return the persistent instance of the given entity class with the given identifier, or null if not found.

Parameters:
entityClass - a persistent class
id - an identifier of the persistent instance
Returns:
the persistent instance, or null if not found
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.get(Class, java.io.Serializable)

get

Object get(Class entityClass,
           Serializable id,
           net.sf.hibernate.LockMode lockMode)
           throws DataAccessException
Return the persistent instance of the given entity class with the given identifier, or null if not found. Obtains the specified lock mode if the instance exists.

Parameters:
entityClass - a persistent class
id - an identifier of the persistent instance
lockMode - the lock mode to obtain
Returns:
the persistent instance, or null if not found
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.get(Class, java.io.Serializable, net.sf.hibernate.LockMode)

load

Object load(Class entityClass,
            Serializable id)
            throws DataAccessException
Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found.

Parameters:
entityClass - a persistent class
id - an identifier of the persistent instance
Returns:
the persistent instance
Throws:
ObjectRetrievalFailureException - if not found
DataAccessException - in case of Hibernate errors
See Also:
Session.load(Class, java.io.Serializable)

load

Object load(Class entityClass,
            Serializable id,
            net.sf.hibernate.LockMode lockMode)
            throws DataAccessException
Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. Obtains the specified lock mode if the instance exists.

Parameters:
entityClass - a persistent class
id - an identifier of the persistent instance
lockMode - the lock mode to obtain
Returns:
the persistent instance
Throws:
ObjectRetrievalFailureException - if not found
DataAccessException - in case of Hibernate errors
See Also:
Session.load(Class, java.io.Serializable)

loadAll

List loadAll(Class entityClass)
             throws DataAccessException
Return all persistent instances of the given entity class. Note: Use queries or criteria for retrieving a specific subset.

Parameters:
entityClass - a persistent class
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - if there is a Hibernate error
See Also:
Session.createCriteria(java.lang.Class)

load

void load(Object entity,
          Serializable id)
          throws DataAccessException
Load the persistent instance with the given identifier into the given object, throwing an exception if not found.

Parameters:
entity - the object (of the target class) to load into
id - an identifier of the persistent instance
Throws:
ObjectRetrievalFailureException - if not found
DataAccessException - in case of Hibernate errors
See Also:
Session.load(Object, java.io.Serializable)

refresh

void refresh(Object entity)
             throws DataAccessException
Re-read the state of the given persistent instance.

Parameters:
entity - the persistent instance to re-read
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.refresh(Object)

refresh

void refresh(Object entity,
             net.sf.hibernate.LockMode lockMode)
             throws DataAccessException
Re-read the state of the given persistent instance. Obtains the specified lock mode for the instance.

Parameters:
entity - the persistent instance to re-read
lockMode - the lock mode to obtain
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.refresh(Object, net.sf.hibernate.LockMode)

contains

boolean contains(Object entity)
                 throws DataAccessException
Check whether the given object is in the Session cache.

Parameters:
entity - the persistence instance to check
Returns:
whether the given object is in the Session cache
Throws:
DataAccessException - if there is a Hibernate error
See Also:
Session.contains(java.lang.Object)

evict

void evict(Object entity)
           throws DataAccessException
Remove the given object from the Session cache.

Parameters:
entity - the persistent instance to evict
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.evict(java.lang.Object)

initialize

void initialize(Object proxy)
                throws DataAccessException
Force initialization of a Hibernate proxy or persistent collection.

Parameters:
proxy - a proxy for a persistent object or a persistent collection
Throws:
DataAccessException - if we can't initialize the proxy, for example because it is not associated with an active Session
See Also:
Hibernate.initialize(java.lang.Object)

lock

void lock(Object entity,
          net.sf.hibernate.LockMode lockMode)
          throws DataAccessException
Obtain the specified lock level upon the given object, implicitly checking whether the corresponding database entry still exists (throwing an OptimisticLockingFailureException if not found).

Parameters:
entity - the persistent instance to lock
lockMode - the lock mode to obtain
Throws:
ObjectOptimisticLockingFailureException - if not found
DataAccessException - in case of Hibernate errors
See Also:
HibernateOptimisticLockingFailureException, Session.lock(Object, net.sf.hibernate.LockMode)

save

Serializable save(Object entity)
                  throws DataAccessException
Persist the given transient instance.

Parameters:
entity - the transient instance to persist
Returns:
the generated identifier
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.save(Object)

save

void save(Object entity,
          Serializable id)
          throws DataAccessException
Persist the given transient instance with the given identifier.

Parameters:
entity - the transient instance to persist
id - the identifier to assign
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.save(Object, java.io.Serializable)

update

void update(Object entity)
            throws DataAccessException
Update the given persistent instance.

Parameters:
entity - the persistent instance to update
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.update(Object)

update

void update(Object entity,
            net.sf.hibernate.LockMode lockMode)
            throws DataAccessException
Update the given persistent instance.

Obtains the specified lock mode if the instance exists, implicitly checking whether the corresponding database entry still exists (throwing an OptimisticLockingFailureException if not found).

Parameters:
entity - the persistent instance to update
lockMode - the lock mode to obtain
Throws:
ObjectOptimisticLockingFailureException - if not found
DataAccessException - in case of Hibernate errors
See Also:
HibernateOptimisticLockingFailureException, Session.update(Object)

saveOrUpdate

void saveOrUpdate(Object entity)
                  throws DataAccessException
Save or update the given persistent instance, according to its id (matching the configured "unsaved-value"?).

Parameters:
entity - the persistent instance to save or update (to be associated with the Hibernate Session)
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.saveOrUpdate(Object)

saveOrUpdateAll

void saveOrUpdateAll(Collection entities)
                     throws DataAccessException
Save or update all given persistent instances, according to its id (matching the configured "unsaved-value"?).

Parameters:
entities - the persistent instances to save or update (to be associated with the Hibernate Session)
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.saveOrUpdate(Object)

saveOrUpdateCopy

Object saveOrUpdateCopy(Object entity)
                        throws DataAccessException
Save or update the contents of given persistent object, according to its id (matching the configured "unsaved-value"?). Will copy the contained fields to an already loaded instance with the same id, if appropriate.

Parameters:
entity - the persistent object to save or update (not necessarily to be associated with the Hibernate Session)
Returns:
the actually associated persistent object (either an already loaded instance with the same id, or the given object)
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.saveOrUpdateCopy(Object)

replicate

void replicate(Object entity,
               net.sf.hibernate.ReplicationMode replicationMode)
               throws DataAccessException
Persist the state of the given detached instance according to the given replication mode, reusing the current identifier value.

Parameters:
entity - the persistent object to replicate
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.replicate(Object, net.sf.hibernate.ReplicationMode)

delete

void delete(Object entity)
            throws DataAccessException
Delete the given persistent instance.

Parameters:
entity - the persistent instance to delete
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.delete(Object)

delete

void delete(Object entity,
            net.sf.hibernate.LockMode lockMode)
            throws DataAccessException
Delete the given persistent instance.

Obtains the specified lock mode if the instance exists, implicitly checking whether the corresponding database entry still exists (throwing an OptimisticLockingFailureException if not found).

Parameters:
entity - the persistent instance to delete
lockMode - the lock mode to obtain
Throws:
ObjectOptimisticLockingFailureException - if not found
DataAccessException - in case of Hibernate errors
See Also:
HibernateOptimisticLockingFailureException, Session.delete(Object)

deleteAll

void deleteAll(Collection entities)
               throws DataAccessException
Delete all given persistent instances.

This can be combined with any of the find methods to delete by query in two lines of code, similar to Session's delete by query methods.

Parameters:
entities - the persistent instances to delete
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.delete(String)

flush

void flush()
           throws DataAccessException
Flush all pending saves, updates and deletes to the database.

Only invoke this for selective eager flushing, for example when JDBC code needs to see certain changes within the same transaction. Else, it's preferable to rely on auto-flushing at transaction completion.

Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.flush()

clear

void clear()
           throws DataAccessException
Remove all objects from the Session cache, and cancel all pending saves, updates and deletes.

Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.clear()

find

List find(String queryString)
          throws DataAccessException
Execute a query for persistent instances.

Parameters:
queryString - a query expressed in Hibernate's query language
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String), Session.createQuery(java.lang.String)

find

List find(String queryString,
          Object value)
          throws DataAccessException
Execute a query for persistent instances, binding one value to a "?" parameter in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
value - the value of the parameter
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.createQuery(java.lang.String)

find

List find(String queryString,
          Object value,
          net.sf.hibernate.type.Type type)
          throws DataAccessException
Execute a query for persistent instances, binding one value to a "?" parameter of the given type in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
value - the value of the parameter
type - Hibernate type of the parameter (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.createQuery(java.lang.String)

find

List find(String queryString,
          Object[] values)
          throws DataAccessException
Execute a query for persistent instances, binding a number of values to "?" parameters in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
values - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.createQuery(java.lang.String)

find

List find(String queryString,
          Object[] values,
          net.sf.hibernate.type.Type[] types)
          throws DataAccessException
Execute a query for persistent instances, binding a number of values to "?" parameters of the given types in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
values - the values of the parameters
types - Hibernate types of the parameters (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.createQuery(java.lang.String)

findByNamedParam

List findByNamedParam(String queryName,
                      String paramName,
                      Object value)
                      throws DataAccessException
Execute a query for persistent instances, binding one value to a ":" named parameter in the query string.

Parameters:
queryName - the name of a Hibernate query in a mapping file
paramName - the name of parameter
value - the value of the parameter
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.getNamedQuery(String)

findByNamedParam

List findByNamedParam(String queryName,
                      String paramName,
                      Object value,
                      net.sf.hibernate.type.Type type)
                      throws DataAccessException
Execute a query for persistent instances, binding one value to a ":" named parameter in the query string.

Parameters:
queryName - the name of a Hibernate query in a mapping file
paramName - the name of the parameter
value - the value of the parameter
type - Hibernate type of the parameter (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.getNamedQuery(String)

findByNamedParam

List findByNamedParam(String queryString,
                      String[] paramNames,
                      Object[] values)
                      throws DataAccessException
Execute a query for persistent instances, binding a number of values to ":" named parameters in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
paramNames - the names of the parameters
values - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.getNamedQuery(String)

findByNamedParam

List findByNamedParam(String queryString,
                      String[] paramNames,
                      Object[] values,
                      net.sf.hibernate.type.Type[] types)
                      throws DataAccessException
Execute a query for persistent instances, binding a number of values to ":" named parameters in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
paramNames - the names of the parameters
values - the values of the parameters
types - Hibernate types of the parameters (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.getNamedQuery(String)

findByValueBean

List findByValueBean(String queryString,
                     Object valueBean)
                     throws DataAccessException
Execute a query for persistent instances, binding the properties of the given bean to named parameters in the query string.

Parameters:
queryString - a query expressed in Hibernate's query language
valueBean - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Query.setProperties(java.lang.Object), Session.createQuery(java.lang.String)

findByNamedQuery

List findByNamedQuery(String queryName)
                      throws DataAccessException
Execute a named query for persistent instances. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String), Session.getNamedQuery(String)

findByNamedQuery

List findByNamedQuery(String queryName,
                      Object value)
                      throws DataAccessException
Execute a named query for persistent instances, binding one value to a "?" parameter in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.getNamedQuery(String)

findByNamedQuery

List findByNamedQuery(String queryName,
                      Object value,
                      net.sf.hibernate.type.Type type)
                      throws DataAccessException
Execute a named query for persistent instances, binding one value to a "?" parameter in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
type - Hibernate type of the parameter (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.getNamedQuery(String)

findByNamedQuery

List findByNamedQuery(String queryName,
                      Object[] values)
                      throws DataAccessException
Execute a named query for persistent instances, binding a number of values to "?" parameters in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
values - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.getNamedQuery(String)

findByNamedQuery

List findByNamedQuery(String queryName,
                      Object[] values,
                      net.sf.hibernate.type.Type[] types)
                      throws DataAccessException
Execute a named query for persistent instances, binding a number of values to "?" parameters in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
values - the values of the parameters
types - Hibernate types of the parameters (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.getNamedQuery(String)

findByNamedQueryAndNamedParam

List findByNamedQueryAndNamedParam(String queryName,
                                   String paramName,
                                   Object value)
                                   throws DataAccessException
Execute a named query for persistent instances, binding one value to a ":" named parameter in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
paramName - the name of parameter
value - the value of the parameter
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.getNamedQuery(String)

findByNamedQueryAndNamedParam

List findByNamedQueryAndNamedParam(String queryName,
                                   String paramName,
                                   Object value,
                                   net.sf.hibernate.type.Type type)
                                   throws DataAccessException
Execute a named query for persistent instances, binding one value to a ":" named parameter in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
paramName - the name of the parameter
value - the value of the parameter
type - Hibernate type of the parameter (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object, net.sf.hibernate.type.Type), Session.getNamedQuery(String)

findByNamedQueryAndNamedParam

List findByNamedQueryAndNamedParam(String queryName,
                                   String[] paramNames,
                                   Object[] values)
                                   throws DataAccessException
Execute a named query for persistent instances, binding a number of values to ":" named parameters in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
paramNames - the names of the parameters
values - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.getNamedQuery(String)

findByNamedQueryAndNamedParam

List findByNamedQueryAndNamedParam(String queryName,
                                   String[] paramNames,
                                   Object[] values,
                                   net.sf.hibernate.type.Type[] types)
                                   throws DataAccessException
Execute a named query for persistent instances, binding a number of values to ":" named parameters in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
paramNames - the names of the parameters
values - the values of the parameters
types - Hibernate types of the parameters (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.getNamedQuery(String)

findByNamedQueryAndValueBean

List findByNamedQueryAndValueBean(String queryName,
                                  Object valueBean)
                                  throws DataAccessException
Execute a named query for persistent instances, binding the properties of the given bean to ":" named parameters in the query string. A named query is defined in a Hibernate mapping file.

Parameters:
queryName - the name of a Hibernate query in a mapping file
valueBean - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Query.setProperties(java.lang.Object), Session.getNamedQuery(String)

iterate

Iterator iterate(String queryString)
                 throws DataAccessException
Execute a query for persistent instances.

Returns the results as Iterator. Entities returned are initialized on demand. See Hibernate docs for details.

Parameters:
queryString - a query expressed in Hibernate's query language
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.iterate(String), Session.createQuery(java.lang.String)

iterate

Iterator iterate(String queryString,
                 Object value)
                 throws DataAccessException
Execute a query for persistent instances, binding one value to a "?" parameter in the query string.

Returns the results as Iterator. Entities returned are initialized on demand. See Hibernate docs for details.

Parameters:
queryString - a query expressed in Hibernate's query language
value - the value of the parameter
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.iterate(String, Object, net.sf.hibernate.type.Type), Session.createQuery(java.lang.String)

iterate

Iterator iterate(String queryString,
                 Object value,
                 net.sf.hibernate.type.Type type)
                 throws DataAccessException
Execute a query for persistent instances, binding one value to a "?" parameter of the given type in the query string.

Returns the results as Iterator. Entities returned are initialized on demand. See Hibernate docs for details.

Parameters:
queryString - a query expressed in Hibernate's query language
value - the value of the parameter
type - Hibernate type of the parameter (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.iterate(String, Object, net.sf.hibernate.type.Type), Session.createQuery(java.lang.String)

iterate

Iterator iterate(String queryString,
                 Object[] values)
                 throws DataAccessException
Execute a query for persistent instances, binding a number of values to "?" parameters in the query string.

Returns the results as Iterator. Entities returned are initialized on demand. See Hibernate docs for details.

Parameters:
queryString - a query expressed in Hibernate's query language
values - the values of the parameters
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.createQuery(java.lang.String)

iterate

Iterator iterate(String queryString,
                 Object[] values,
                 net.sf.hibernate.type.Type[] types)
                 throws DataAccessException
Execute a query for persistent instances, binding a number of values to "?" parameters of the given types in the query string.

Returns the results as Iterator. Entities returned are initialized on demand. See Hibernate docs for details.

Parameters:
queryString - a query expressed in Hibernate's query language
values - the values of the parameters
types - Hibernate types of the parameters (or null)
Returns:
a List containing 0 or more persistent instances
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.find(String, Object[], net.sf.hibernate.type.Type[]), Session.createQuery(java.lang.String)

closeIterator

void closeIterator(Iterator it)
                   throws DataAccessException
Close an Iterator created by iterate operations immediately, instead of waiting until the session is closed or disconnected.

Parameters:
it - the Iterator to close
Throws:
DataAccessException - if the Iterator could not be closed
See Also:
Hibernate.close(java.util.Iterator)

delete

int delete(String queryString)
           throws DataAccessException
Delete all objects returned by the query. Return the number of entity instances deleted.

Parameters:
queryString - a query expressed in Hibernate's query language
Returns:
the number of instances deleted
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.delete(String)

delete

int delete(String queryString,
           Object value,
           net.sf.hibernate.type.Type type)
           throws DataAccessException
Delete all objects returned by the query. Return the number of entity instances deleted.

Parameters:
queryString - a query expressed in Hibernate's query language
value - the value of the parameter
type - Hibernate type of the parameter (or null)
Returns:
the number of instances deleted
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.delete(String, Object, net.sf.hibernate.type.Type)

delete

int delete(String queryString,
           Object[] values,
           net.sf.hibernate.type.Type[] types)
           throws DataAccessException
Delete all objects returned by the query. Return the number of entity instances deleted.

Parameters:
queryString - a query expressed in Hibernate's query language
values - the values of the parameters
types - Hibernate types of the parameters (or null)
Returns:
the number of instances deleted
Throws:
DataAccessException - in case of Hibernate errors
See Also:
Session.delete(String, Object[], net.sf.hibernate.type.Type[])


Copyright (c) 2002-2006 The Spring Framework Project.