|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 convenience methods that mirror various Session methods.
HibernateTemplate
,
Session
Method Summary | |
void |
delete(java.lang.Object entity)
Delete the given persistent instance. |
void |
delete(java.lang.Object entity,
net.sf.hibernate.LockMode lockMode)
Delete the given persistent instance. |
void |
deleteAll(java.util.Collection entities)
Delete all given persistent instances. |
void |
evict(java.lang.Object entity)
Remove the given object from the Session cache. |
java.lang.Object |
execute(HibernateCallback action)
Execute the action specified by the given action object within a session. |
java.util.List |
executeFind(HibernateCallback action)
Execute the specified action assuming that the result object is a List. |
java.util.List |
find(java.lang.String queryString)
Execute a query for persistent instances. |
java.util.List |
find(java.lang.String queryString,
java.lang.Object value)
Execute a query for persistent instances, binding one value to a "?" parameter in the query string. |
java.util.List |
find(java.lang.String queryString,
java.lang.Object[] values)
Execute a query for persistent instances, binding a number of values to "?" parameters in the query string. |
java.util.List |
find(java.lang.String queryString,
java.lang.Object[] values,
net.sf.hibernate.type.Type[] types)
Execute a query for persistent instances, binding a number of values to "?" parameters of the given types in the query string. |
java.util.List |
find(java.lang.String queryString,
java.lang.Object value,
net.sf.hibernate.type.Type type)
Execute a query for persistent instances, binding one value to a "?" parameter of the given type in the query string. |
java.util.List |
findByNamedQuery(java.lang.String queryName)
Execute a named query for persistent instances. |
java.util.List |
findByNamedQuery(java.lang.String queryName,
java.lang.Object value)
Execute a named query for persistent instances, binding one value to a "?" parameter in the query string. |
java.util.List |
findByNamedQuery(java.lang.String queryName,
java.lang.Object[] values)
Execute a named query for persistent instances, binding a number of values to "?" parameters in the query string. |
java.util.List |
findByNamedQuery(java.lang.String queryName,
java.lang.Object[] values,
net.sf.hibernate.type.Type[] types)
Execute a named query for persistent instances, binding a number of values to "?" parameters in the query string. |
java.util.List |
findByNamedQuery(java.lang.String queryName,
java.lang.Object value,
net.sf.hibernate.type.Type type)
Execute a named query for persistent instances, binding one value to a "?" parameter in the query string. |
java.util.List |
findByNamedQueryAndValueBean(java.lang.String queryName,
java.lang.Object valueBean)
Execute a named query for persistent instances, binding the properties of the given bean to named parameters in the query string. |
java.util.List |
findByValueBean(java.lang.String queryString,
java.lang.Object valueBean)
Execute a query for persistent instances, binding the properties of the given bean to named parameters in the query string. |
java.lang.Object |
get(java.lang.Class entityClass,
java.io.Serializable id)
Return the persistent instance of the given entity class with the given identifier, or null if not found. |
java.lang.Object |
get(java.lang.Class entityClass,
java.io.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. |
java.lang.Object |
load(java.lang.Class entityClass,
java.io.Serializable id)
Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. |
java.lang.Object |
load(java.lang.Class entityClass,
java.io.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. |
java.util.List |
loadAll(java.lang.Class entityClass)
Return all persistent instances of the given entity class. |
void |
lock(java.lang.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). |
java.io.Serializable |
save(java.lang.Object entity)
Save the given persistent instance. |
void |
save(java.lang.Object entity,
java.io.Serializable id)
Save the given persistent instance with the given identifier. |
void |
saveOrUpdate(java.lang.Object entity)
Save respectively update the given persistent instance, according to its ID (matching the configured "unsaved-value"?). |
java.lang.Object |
saveOrUpdateCopy(java.lang.Object entity)
Save respectively update the contents of given persistent object, according to its ID (matching the configured "unsaved-value"?). |
void |
update(java.lang.Object entity)
Update the given persistent instance. |
void |
update(java.lang.Object entity,
net.sf.hibernate.LockMode lockMode)
Update the given persistent instance. |
Method Detail |
public java.lang.Object execute(HibernateCallback action) throws DataAccessException
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.
action
- callback object that specifies the Hibernate action
DataAccessException
- in case of Hibernate errorsHibernateTransactionManager
,
org.springframework.dao
,
org.springframework.transaction
public java.util.List executeFind(HibernateCallback action) throws DataAccessException
This is a convenience method for executing Hibernate find calls within an action.
action
- action object that specifies the Hibernate action
DataAccessException
- in case of Hibernate errorspublic java.lang.Object get(java.lang.Class entityClass, java.io.Serializable id) throws DataAccessException
entityClass
- a persistent classid
- an identifier of the persistent instance
DataAccessException
- in case of Hibernate errorsSession.get(Class, java.io.Serializable)
public java.lang.Object get(java.lang.Class entityClass, java.io.Serializable id, net.sf.hibernate.LockMode lockMode) throws DataAccessException
entityClass
- a persistent classid
- an identifier of the persistent instance
DataAccessException
- in case of Hibernate errorsSession.get(Class, java.io.Serializable, net.sf.hibernate.LockMode)
public java.lang.Object load(java.lang.Class entityClass, java.io.Serializable id) throws DataAccessException
entityClass
- a persistent classid
- an identifier of the persistent instance
HibernateObjectRetrievalFailureException
- if the instance could not be found
DataAccessException
- in case of Hibernate errorsSession.load(Class, java.io.Serializable)
public java.lang.Object load(java.lang.Class entityClass, java.io.Serializable id, net.sf.hibernate.LockMode lockMode) throws DataAccessException
entityClass
- a persistent classid
- an identifier of the persistent instance
HibernateObjectRetrievalFailureException
- if the instance could not be found
DataAccessException
- in case of Hibernate errorsSession.load(Class, java.io.Serializable)
public java.util.List loadAll(java.lang.Class entityClass) throws DataAccessException
entityClass
- a persistent class
DataAccessException
- if there is a Hibernate errorSession.createCriteria(java.lang.Class)
public void evict(java.lang.Object entity) throws DataAccessException
entity
- the persistent instance to lock
DataAccessException
- in case of Hibernate errorsSession.evict(Object)
public void lock(java.lang.Object entity, net.sf.hibernate.LockMode lockMode) throws DataAccessException
entity
- the persistent instance to lock
DataAccessException
- in case of Hibernate errorsHibernateOptimisticLockingFailureException
,
Session.lock(Object, net.sf.hibernate.LockMode)
public java.io.Serializable save(java.lang.Object entity) throws DataAccessException
entity
- the persistent instance to save
DataAccessException
- in case of Hibernate errorsSession.save(Object)
public void save(java.lang.Object entity, java.io.Serializable id) throws DataAccessException
entity
- the persistent instance to saveid
- the identifier to assign
DataAccessException
- in case of Hibernate errorsSession.save(Object, java.io.Serializable)
public void saveOrUpdate(java.lang.Object entity) throws DataAccessException
entity
- the persistent instance to save respectively update
(to be associated with the Hibernate Session)
DataAccessException
- in case of Hibernate errorsSession.saveOrUpdate(Object)
public java.lang.Object saveOrUpdateCopy(java.lang.Object entity) throws DataAccessException
entity
- the persistent object to save respectively update
(not necessarily to be associated with the Hibernate Session)
DataAccessException
- in case of Hibernate errorsSession.saveOrUpdateCopy(Object)
public void update(java.lang.Object entity) throws DataAccessException
entity
- the persistent instance to update
DataAccessException
- in case of Hibernate errorsSession.update(Object)
public void update(java.lang.Object entity, net.sf.hibernate.LockMode lockMode) throws DataAccessException
entity
- the persistent instance to update
DataAccessException
- in case of Hibernate errorsHibernateOptimisticLockingFailureException
,
Session.update(Object)
public void delete(java.lang.Object entity) throws DataAccessException
entity
- the persistent instance to delete
DataAccessException
- in case of Hibernate errorsSession.delete(Object)
public void delete(java.lang.Object entity, net.sf.hibernate.LockMode lockMode) throws DataAccessException
entity
- the persistent instance to delete
DataAccessException
- in case of Hibernate errorsHibernateOptimisticLockingFailureException
,
Session.delete(Object)
public void deleteAll(java.util.Collection entities) throws DataAccessException
entities
- the persistent instances to delete
DataAccessException
- in case of Hibernate errorsSession.delete(String)
public java.util.List find(java.lang.String queryString) throws DataAccessException
queryString
- a query expressed in Hibernate's query language
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.createQuery(java.lang.String)
public java.util.List find(java.lang.String queryString, java.lang.Object value) throws DataAccessException
queryString
- a query expressed in Hibernate's query languagevalue
- the value of the parameter
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.createQuery(java.lang.String)
public java.util.List find(java.lang.String queryString, java.lang.Object value, net.sf.hibernate.type.Type type) throws DataAccessException
queryString
- a query expressed in Hibernate's query languagevalue
- the value of the parametertype
- Hibernate type of the parameter
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.createQuery(java.lang.String)
public java.util.List find(java.lang.String queryString, java.lang.Object[] values) throws DataAccessException
queryString
- a query expressed in Hibernate's query languagevalues
- the values of the parameters
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.createQuery(java.lang.String)
public java.util.List find(java.lang.String queryString, java.lang.Object[] values, net.sf.hibernate.type.Type[] types) throws DataAccessException
queryString
- a query expressed in Hibernate's query languagevalues
- the values of the parameterstypes
- Hibernate types of the parameters
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.createQuery(java.lang.String)
public java.util.List findByValueBean(java.lang.String queryString, java.lang.Object valueBean) throws DataAccessException
queryString
- a query expressed in Hibernate's query languagevalueBean
- the values of the parameters
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.createQuery(java.lang.String)
,
Query.setProperties(java.lang.Object)
public java.util.List findByNamedQuery(java.lang.String queryName) throws DataAccessException
queryName
- the name of a Hibernate query in a mapping file
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.getNamedQuery(String)
public java.util.List findByNamedQuery(java.lang.String queryName, java.lang.Object value) throws DataAccessException
queryName
- the name of a Hibernate query in a mapping file
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.getNamedQuery(String)
public java.util.List findByNamedQuery(java.lang.String queryName, java.lang.Object value, net.sf.hibernate.type.Type type) throws DataAccessException
queryName
- the name of a Hibernate query in a mapping filetype
- Hibernate type of the parameter
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.getNamedQuery(String)
public java.util.List findByNamedQuery(java.lang.String queryName, java.lang.Object[] values) throws DataAccessException
queryName
- the name of a Hibernate query in a mapping filevalues
- the values of the parameters
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.getNamedQuery(String)
public java.util.List findByNamedQuery(java.lang.String queryName, java.lang.Object[] values, net.sf.hibernate.type.Type[] types) throws DataAccessException
queryName
- the name of a Hibernate query in a mapping filevalues
- the values of the parameterstypes
- Hibernate types of the parameters
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.getNamedQuery(String)
public java.util.List findByNamedQueryAndValueBean(java.lang.String queryName, java.lang.Object valueBean) throws DataAccessException
queryName
- the name of a Hibernate query in a mapping filevalueBean
- the values of the parameters
DataAccessException
- in case of Hibernate errorsSession.find(String)
,
Session.getNamedQuery(String)
,
Query.setProperties(java.lang.Object)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |