public abstract class GenericDAOImpl<T,ID extends Serializable> extends AbstractDAOImpl implements GenericDAO<T,ID>
| Constructor and Description |
|---|
GenericDAOImpl()
Constructs the DAO
|
GenericDAOImpl(Class<T> persistentClass)
Constructs the DAO.
|
GenericDAOImpl(Class<T> persistentClass,
org.hibernate.SessionFactory sessionFactory)
Constructs the DAO.
|
GenericDAOImpl(org.hibernate.SessionFactory sessionFactory)
Constructs the DAO
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete(T entity)
Deletes an entity instance.
|
void |
deleteById(ID id)
Deletes an entity instance.
|
List<T> |
findAll()
Returns all entities of the persistent type.
|
protected List<T> |
findByCriteria(org.hibernate.criterion.Criterion... criterion)
Returns the list of entity instances that matches the provided crtieria.
|
T |
findById(ID id,
boolean lock)
Finds an entity by ID.
|
protected T |
first(org.hibernate.Query query)
Returns the first result of a query returning instances of the persisted
class.
|
protected Class<T> |
getPersistentClass()
Returns the persistent class.
|
protected List<T> |
list(org.hibernate.Query query)
Returns the results of a query as a list of the persisted class.
|
protected org.hibernate.Criteria |
newCriteria()
Returns a new criteria object.
|
T |
save(T entity)
Saves an entity.
|
T |
saveOrUpdate(T entity)
Saves or updates an entity, depending upon resolution of the
unsaved-value checks.
|
protected T |
unique(org.hibernate.Query query)
Returns the unique result of a query returning instances of the persisted
class.
|
T |
update(T entity)
Updates an entity.
|
clear, evict, first, flush, getNamedQuery, getSession, list, list, setSessionFactory, sync, unique, uniquepublic GenericDAOImpl(org.hibernate.SessionFactory sessionFactory)
sessionFactory - Hibernate Session factory.public GenericDAOImpl(Class<T> persistentClass, org.hibernate.SessionFactory sessionFactory)
persistentClass - Persistent class.sessionFactory - Hibernate Session factory.public GenericDAOImpl()
protected final Class<T> getPersistentClass()
public void delete(T entity)
GenericDAOdelete in interface GenericDAO<T,ID extends Serializable>entity - Instance to delete.public void deleteById(ID id)
GenericDAOdeleteById in interface GenericDAO<T,ID extends Serializable>id - Id of the instance to delete.public List<T> findAll()
GenericDAOfindAll in interface GenericDAO<T,ID extends Serializable>public T findById(ID id, boolean lock)
GenericDAOfindById in interface GenericDAO<T,ID extends Serializable>id - IDlock - If the entity shall be locked.null if it is not found.public T save(T entity)
GenericDAOsave in interface GenericDAO<T,ID extends Serializable>entity - Entity to save.public T saveOrUpdate(T entity)
GenericDAOsaveOrUpdate in interface GenericDAO<T,ID extends Serializable>entity - Entity to persist.public T update(T entity)
GenericDAOupdate in interface GenericDAO<T,ID extends Serializable>entity - Entity to update.protected final org.hibernate.Criteria newCriteria()
protected final List<T> findByCriteria(org.hibernate.criterion.Criterion... criterion)
criterion - Search criteria.protected final List<T> list(org.hibernate.Query query)
query - Query to execute.protected final T first(org.hibernate.Query query)
query - Query to execute.null if there are no results.protected final T unique(org.hibernate.Query query)
query - Query to execute.null if there are no results.org.hibernate.NonUniqueResultException - if there are more than one result.Copyright © 2014. All rights reserved.