public abstract class GenericHibernateDao<E extends PersistentObject,ID extends Serializable> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.log4j.Logger |
LOG
The LOGGER instance (that will be available in all subclasses)
|
| Modifier | Constructor and Description |
|---|---|
protected |
GenericHibernateDao(Class<E> clazz)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected org.hibernate.Criteria |
createDistinctRootEntityCriteria(org.hibernate.criterion.Criterion... criterion)
Helper method: Creates a criteria for the
clazz of this dao. |
void |
delete(E e)
Deletes the passed entity.
|
List<E> |
findAll()
Returns all Entities by calling findByCriteria(), i.e. without arguments.
|
List<E> |
findByCriteria(org.hibernate.criterion.Criterion... criterion)
Gets the results, that match a variable number of passed criterions.
|
PagingResult<E> |
findByCriteriaWithSortingAndPaging(Integer firstResult,
Integer maxResults,
List<org.hibernate.criterion.Order> sorters,
org.hibernate.criterion.Criterion... criterion)
Gets the results, that match a variable number of passed criterions,
considering the paging- and sort-info at the same time.
|
E |
findById(ID id)
Return the real object from the database.
|
E |
findByUniqueCriteria(org.hibernate.criterion.Criterion... criterion)
Gets the unique result, that matches a variable number of passed
criterions.
|
E |
loadById(ID id)
Return a proxy of the object (without hitting the database).
|
void |
saveOrUpdate(E e)
Saves or updates the passed entity.
|
protected final org.apache.log4j.Logger LOG
public E findById(ID id)
id - http://www.mkyong.com/hibernate/different-between-session-get-and-session-load/public E loadById(ID id)
id - http://www.mkyong.com/hibernate/different-between-session-get-and-session-load/public List<E> findAll() throws org.hibernate.HibernateException
org.hibernate.HibernateExceptionfindByCriteria(Criterion...)public void saveOrUpdate(E e)
e - The entity to save or update in the database.public void delete(E e)
e - The entity to remove from the database.public List<E> findByCriteria(org.hibernate.criterion.Criterion... criterion) throws org.hibernate.HibernateException
criterion - A variable number of hibernate criterionsorg.hibernate.HibernateExceptionpublic E findByUniqueCriteria(org.hibernate.criterion.Criterion... criterion) throws org.hibernate.HibernateException
criterion - A variable number of hibernate criterionsorg.hibernate.HibernateException - if there is more than one matching resultpublic PagingResult<E> findByCriteriaWithSortingAndPaging(Integer firstResult, Integer maxResults, List<org.hibernate.criterion.Order> sorters, org.hibernate.criterion.Criterion... criterion) throws org.hibernate.HibernateException
firstResult - Starting index for the paging request.maxResults - Max number of result size.criterion - A variable number of hibernate criterionsorg.hibernate.HibernateExceptionprotected org.hibernate.Criteria createDistinctRootEntityCriteria(org.hibernate.criterion.Criterion... criterion)
clazz of this dao.
The query results will be handled with a
DistinctRootEntityResultTransformer. The criteria will contain
all passed criterions.Copyright © 2016 terrestris GmbH & Co. KG. All rights reserved.