|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.orm.hibernate3.HibernateAccessor
org.springframework.orm.hibernate3.HibernateTemplate
ch.elca.el4j.services.persistence.hibernate.dao.ConvenienceHibernateTemplate
public class ConvenienceHibernateTemplate
This is a convenience class for the Hibernate template. Features:
Field Summary |
---|
Fields inherited from class org.springframework.orm.hibernate3.HibernateAccessor |
---|
FLUSH_ALWAYS, FLUSH_AUTO, FLUSH_COMMIT, FLUSH_EAGER, FLUSH_NEVER, logger |
Constructor Summary | |
---|---|
ConvenienceHibernateTemplate(SessionFactory sessionFactory)
Constructor. |
Method Summary | ||
---|---|---|
void |
createHibernateSearchIndex(Collection<?> objects)
Trigger Hibernate Search index process explicitly. |
|
void |
deleteStrong(Class<?> entityClass,
Serializable id,
String objectName)
Deletes the persistent instance given by its identifier in a strong way: first, the persistent instance is retrieved with the help of the identifier. |
|
Object |
findByNamedParamStrong(String queryString,
String paramName,
Object value,
String objectName)
Retrieves a persistent instance with the help of a parameterized query: does the same as the findByNamedParam(String, String, Object) method, but
returns a persistent instance instead of a list of persistent objects and
throws a DataRetrievalException if the returned list does
not contain exactly one element. |
|
int |
findCountByCriteria(DetachedCriteria criteria)
Counts the number of results of a search. |
|
Object |
getByIdStrong(Class<?> entityClass,
Serializable id,
String objectName)
Retrieves the persistent instance given by its identifier in a strong way: does the same as the getById(Class, java.io.Serializable)
method, but throws a DataRetrievalException instead of
null if the persistent instance could not be found. |
|
Object |
getByIdStrongLazy(Class<?> entityClass,
Serializable id,
String objectName)
Retrieves a persistent instance lazily. |
|
int |
getFirstResult()
Gets the id of the first result to return. |
|
protected void |
prepareCriteria(Criteria criteria)
|
|
protected void |
prepareQuery(Query queryObject)
Overload parent class to support also a constraint of the id of the first result to load. |
|
void |
saveOrUpdateStrong(Object entity,
String objectName)
Saves or updates the given persistent instance in a strong way: does the same as the saveOrUpdate(Object) method, but throws a more
specific OptimisticLockingFailureException in the case of
an optimistic locking failure. |
|
|
search(Class<T> entityClass,
String[] fields,
String searchString)
Search for objects having fields that match the search string. |
|
void |
setFirstResult(int firstResult)
Sets the id of the first result to return. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConvenienceHibernateTemplate(SessionFactory sessionFactory)
sessionFactory
- SessionFactory to create SessionsMethod Detail |
---|
public Object getByIdStrong(Class<?> entityClass, Serializable id, String objectName) throws DataAccessException, DataRetrievalFailureException
getById(Class, java.io.Serializable)
method, but throws a DataRetrievalException
instead of
null
if the persistent instance could not be found.
entityClass
- The class of the object which should be returned.id
- An identifier of the persistent instanceobjectName
- Name of the persistent object type.
DataAccessException
- in case of Hibernate errors
DataRetrievalFailureException
- in case the persistent instance is nullHibernateTemplate.get(Class, java.io.Serializable)
public Object getByIdStrongLazy(Class<?> entityClass, Serializable id, String objectName) throws DataAccessException, DataRetrievalFailureException
DataAccessException
DataRetrievalFailureException
getByIdStrong
public Object findByNamedParamStrong(String queryString, String paramName, Object value, String objectName) throws DataAccessException, DataRetrievalFailureException
findByNamedParam(String, String, Object)
method, but
returns a persistent instance instead of a list of persistent objects and
throws a DataRetrievalException
if the returned list does
not contain exactly one element.
queryString
- The string corresponding to HQL queryparamName
- The name of the parametervalue
- The value of the parameterobjectName
- Name of the persistent object type.
DataAccessException
- in case of Hibernate errors
DataRetrievalFailureException
- in case the list of persistent instances is empty, or if it
contains more than one objectHibernateTemplate.findByNamedParam(String, String, Object)
public void saveOrUpdateStrong(Object entity, String objectName) throws DataAccessException, OptimisticLockingFailureException
saveOrUpdate(Object)
method, but throws a more
specific OptimisticLockingFailureException
in the case of
an optimistic locking failure.
entity
- the persistent entity to save or updateobjectName
- Name of the persistent object type.
DataAccessException
- in case of Hibernate errors
OptimisticLockingFailureException
- in case optimistic locking failsHibernateTemplate.saveOrUpdate(Object)
public void deleteStrong(Class<?> entityClass, Serializable id, String objectName) throws DataRetrievalFailureException
DataRetrievalFailureException
will be thrown.
entityClass
- The class of the object which should be deleted.id
- The identifier of the persistent instance to deleteobjectName
- Name of the persistent object type.
DataRetrievalFailureException
- in case the persistent instance to delete is nullHibernateTemplate.delete(Object)
protected void prepareQuery(Query queryObject)
prepareQuery
in class HibernateTemplate
protected void prepareCriteria(Criteria criteria)
prepareCriteria
in class HibernateTemplate
public int findCountByCriteria(DetachedCriteria criteria) throws DataAccessException
criteria
- The criteria for the query.
DataAccessException
public int getFirstResult()
public void setFirstResult(int firstResult)
firstResult
- The id of the first result to return.public void createHibernateSearchIndex(Collection<?> objects) throws DataAccessException, DataRetrievalFailureException
objects
- objects to index
DataAccessException
DataRetrievalFailureException
public <T> List<T> search(Class<T> entityClass, String[] fields, String searchString) throws DataAccessException, DataRetrievalFailureException
T
- the type of entitiesentityClass
- the class of the entities to searchfields
- the names of the fields to consider while searchingsearchString
- the search string
DataAccessException
DataRetrievalFailureException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |