@Repository(value="genericDao") public 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 |
|---|---|
|
GenericHibernateDao()
Default constructor
|
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
entityClass of this dao. |
void |
delete(E e)
Deletes the passed entity.
|
List<E> |
findAll()
Returns all Entities by calling findByCriteria(), i.e. without arguments.
|
Map<PersistentObject,PermissionCollection> |
findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup)
This method returns a
Map that maps PersistentObjects
to PermissionCollections for the passed UserGroup. |
Map<PersistentObject,PermissionCollection> |
findAllUserPermissionsOfUser(User user)
|
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.
|
Class<E> |
getEntityClass() |
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.HibernateExceptionpublic Map<PersistentObject,PermissionCollection> findAllUserPermissionsOfUser(User user)
Map that maps PersistentObjects
to PermissionCollections for the passed User. I.e. the keySet
of the map is the collection of all PersistentObjects where the
user has at least one permission and the corresponding value contains
the PermissionCollection for the passed user on the entity.user - public Map<PersistentObject,PermissionCollection> findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup)
Map that maps PersistentObjects
to PermissionCollections for the passed UserGroup. I.e. the keySet
of the map is the collection of all PersistentObjects where the
user group has at least one permission and the corresponding value contains
the PermissionCollection for the passed user group on the entity.userGroup - protected org.hibernate.Criteria createDistinctRootEntityCriteria(org.hibernate.criterion.Criterion... criterion)
entityClass 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.