|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jhomenet.server.dao.hibernate.GenericHibernateDAO<T,ID>
public abstract 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 a current Hibernate Session to use a DAO. Otherwise, this generic implementation will use HibernateUtil.getSessionFactory() to obtain the curren Session.
HibernateDAOFactory
Constructor Summary | |
---|---|
GenericHibernateDAO()
|
Method Summary | |
---|---|
void |
clear()
Affects every managed instance in the current persistence context! |
java.util.List<T> |
findAll()
List of all of the entities. |
protected java.util.List<T> |
findByCriteria(Criterion... criterion)
Use this inside subclasses as a convenience method. |
java.util.List<T> |
findByExample(T exampleInstance,
java.lang.String... excludeProperty)
Find an entity by example. |
T |
findById(ID id,
boolean lock)
Find an entity object given the entity's ID. |
void |
flush()
Affects every managed instance in the current persistence context! |
java.lang.Class<T> |
getPersistentClass()
|
protected Session |
getSession()
|
T |
makePersistent(T entity)
Make an entity object persistent. |
void |
makeTransient(T entity)
Make a currently persistent entity object transient. |
void |
setSession(Session s)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericHibernateDAO()
Method Detail |
---|
public void setSession(Session s)
s
- protected Session getSession()
public java.lang.Class<T> getPersistentClass()
public T findById(ID id, boolean lock)
GenericDao
findById
in interface GenericDao<T,ID extends java.io.Serializable>
GenericDao.findById(java.io.Serializable, boolean)
public java.util.List<T> findAll()
GenericDao
findAll
in interface GenericDao<T,ID extends java.io.Serializable>
GenericDao.findAll()
public java.util.List<T> findByExample(T exampleInstance, java.lang.String... excludeProperty)
GenericDao
findByExample
in interface GenericDao<T,ID extends java.io.Serializable>
GenericDao.findByExample(java.lang.Object, java.lang.String[])
public T makePersistent(T entity)
GenericDao
makePersistent
in interface GenericDao<T,ID extends java.io.Serializable>
entity
- The entity object to persist
GenericDao.makePersistent(java.lang.Object)
public void makeTransient(T entity)
GenericDao
makeTransient
in interface GenericDao<T,ID extends java.io.Serializable>
entity
- The entity object to make persistentGenericDao.makeTransient(java.lang.Object)
protected java.util.List<T> findByCriteria(Criterion... criterion)
public void flush()
GenericDao
flush
in interface GenericDao<T,ID extends java.io.Serializable>
GenericDao.flush()
public void clear()
GenericDao
clear
in interface GenericDao<T,ID extends java.io.Serializable>
GenericDao.clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |