|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjhomenet.dao.hibernate.GenericHibernateDAO<T,ID>
public class GenericHibernateDAO<T,ID extends java.io.Serializable>
Implements the generic CRUD data access operations using Hibernate APIs.
To write a DAO, subclass and parameterize this class with your persistent class. Of course, assuming that you have a traditional 1:1 appraoch for Entity:DAO design.
You have to inject the Class object of the persistent class and a current Hibernate Session to construct a DAO.
HibernateDAOFactory| Constructor Summary | |
|---|---|
GenericHibernateDAO(java.lang.Class<T> persistentClass,
Session session)
Default constructor. |
|
| Method Summary | |
|---|---|
java.util.List<T> |
findAll()
|
protected java.util.List<T> |
findByCriteria(Criterion... criterion)
Use this inside subclasses as a convenience method. |
java.util.List<T> |
findByExample(T exampleInstance)
|
T |
findById(ID id,
boolean lock)
|
java.lang.Class<T> |
getPersistentClass()
|
protected Session |
getSession()
Get the current Hibernate session. |
T |
makePersistent(T entity)
|
void |
makeTransient(T entity)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericHibernateDAO(java.lang.Class<T> persistentClass,
Session session)
persistentClass - session - | Method Detail |
|---|
protected Session getSession()
public java.lang.Class<T> getPersistentClass()
public T findById(ID id,
boolean lock)
findById in interface GenericDAO<T,ID extends java.io.Serializable>public java.util.List<T> findAll()
findAll in interface GenericDAO<T,ID extends java.io.Serializable>public java.util.List<T> findByExample(T exampleInstance)
findByExample in interface GenericDAO<T,ID extends java.io.Serializable>public T makePersistent(T entity)
makePersistent in interface GenericDAO<T,ID extends java.io.Serializable>public void makeTransient(T entity)
makeTransient in interface GenericDAO<T,ID extends java.io.Serializable>protected java.util.List<T> findByCriteria(Criterion... criterion)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||