|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.banda.serverbase.persistence.GenericHibernate4DAO<T,PK>
T - a type variablePK - the primary key for that typepublic class GenericHibernate4DAO<T,PK extends Serializable>
This class serves as the Base class for all other DAOs - namely to hold common CRUD methods that they might all use. You should only need to extend this class when your require custom CRUD logic.
| Field Summary | |
|---|---|
protected org.apache.commons.logging.Log |
log
Log variable for all child classes. |
| Constructor Summary | |
|---|---|
protected |
GenericHibernate4DAO(Class<? extends T> persistentClass)
Constructor that takes in a class to see which type of entity to persist |
| Method Summary | ||
|---|---|---|
void |
clear()
Clears session. |
|
protected static
|
createDaoInstance(Class<T> clazz)
For Spring configuration purpose only. |
|
void |
evict(T object)
Evicts given object from session. |
|
boolean |
exists(PK id)
Checks for existence of an object with given key. |
|
void |
flush()
Flushes session. |
|
Collection<T> |
get(Collection<PK> ids)
Generic method to get objects based on class and identifiers. |
|
T |
get(PK id)
Generic method to get an object based on class and identifier. |
|
List<T> |
getAll()
Generic method used to get all objects of a particular type. |
|
List<T> |
getByExample(T object)
Gets objects from the database that match given example. |
|
T |
getByUniqueExample(T object)
Gets object from the database that match given example. |
|
PK |
getKey(T object)
Generic method to get the identifier of a given object. |
|
T |
getLast()
Generic method to get the last object. |
|
PK |
getNextPK(PK id)
Get primary key larger than given one |
|
PK |
getPreviousPK(PK id)
Get primary key smaller than given one |
|
org.hibernate.SessionFactory |
getSessionFactory()
|
|
void |
remove(Collection<T> objects)
Generic method to delete a given object |
|
void |
remove(PK id)
Generic method to delete an object with given id |
|
void |
remove(T object)
Generic method to delete a given object |
|
|
save(C objects)
Generic method to save collection of objects - handles insert, update and remove. |
|
T |
save(T object)
Generic method to save an object - handles insert, update and remove. |
|
void |
setKey(T object,
PK key)
Generic method to set the identifier for a given object. |
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.apache.commons.logging.Log log
| Constructor Detail |
|---|
protected GenericHibernate4DAO(Class<? extends T> persistentClass)
persistentClass - the class type you'd like to persistkeyExtractor - | Method Detail |
|---|
public List<T> getAll()
getAll in interface GenericDAO<T,PK extends Serializable>public T get(PK id)
GenericDAO
get in interface GenericDAO<T,PK extends Serializable>id - The identifier (primary key) of the object to get
com.pge.smartgrid.serverbase.dao.GenericDAO#get(java.io.Serializable)public Collection<T> get(Collection<PK> ids)
GenericDAO
get in interface GenericDAO<T,PK extends Serializable>ids - The identifiers (primary keys) of the objects to get
com.pge.smartgrid.serverbase.dao.GenericDAO#get(Collection)public List<T> getByExample(T object)
GenericDAO
getByExample in interface GenericDAO<T,PK extends Serializable>object - The template object to match (not null columns)
com.pge.smartgrid.serverbase.dao.GenericDAO#getByExample(java.lang.Object)public T getByUniqueExample(T object)
GenericDAO
getByUniqueExample in interface GenericDAO<T,PK extends Serializable>object - The template object to match (not null columns)
com.pge.smartgrid.serverbase.dao.GenericDAO#getByExample(java.lang.Object)public boolean exists(PK id)
GenericDAO
exists in interface GenericDAO<T,PK extends Serializable>id - The id of the entity
com.pge.smartgrid.serverbase.dao.GenericDAO#exists(java.io.Serializable)public T save(T object)
GenericDAO
save in interface GenericDAO<T,PK extends Serializable>object - The object to save
com.pge.smartgrid.serverbase.dao.GenericDAO#save(java.lang.Object)public void remove(T object)
GenericDAO
remove in interface GenericDAO<T,PK extends Serializable>object - The object to removecom.pge.smartgrid.serverbase.dao.GenericDAO#remove(java.lang.Object)public void remove(Collection<T> objects)
GenericDAO
remove in interface GenericDAO<T,PK extends Serializable>com.pge.smartgrid.serverbase.dao.GenericDAO#remove(java.util.Collection)public void remove(PK id)
GenericDAO
remove in interface GenericDAO<T,PK extends Serializable>id - The identifier (primary key) of the object to removecom.pge.smartgrid.serverbase.dao.GenericDAO#remove(java.io.Serializable)public <C extends Collection<T>> C save(C objects)
GenericDAO
save in interface GenericDAO<T,PK extends Serializable>C - Type of collectionobjects - The objects to savecom.pge.smartgrid.serverbase.dao.GenericDAO#save(java.util.Collection)public void clear()
GenericDAO
clear in interface GenericDAO<T,PK extends Serializable>com.pge.smartgrid.serverbase.dao.GenericDAO#clear()public void flush()
GenericDAO
flush in interface GenericDAO<T,PK extends Serializable>com.pge.smartgrid.serverbase.dao.GenericDAO#flush()public void evict(T object)
GenericDAO
evict in interface GenericDAO<T,PK extends Serializable>com.pge.smartgrid.serverbase.dao.GenericDAO#evict(java.lang.Object)public PK getKey(T object)
GenericDAO
getKey in interface GenericDAO<T,PK extends Serializable>object - The object to get PK for
com.pge.smartgrid.serverbase.dao.GenericDAO#getKey(java.lang.Object)
public void setKey(T object,
PK key)
GenericDAO
setKey in interface GenericDAO<T,PK extends Serializable>object - The object to get PK forkey - The identifier (primary key) of a given objectcom.pge.smartgrid.serverbase.dao.GenericDAO#setKey(java.lang.Object, java.io.Serializable)public T getLast()
GenericDAO
getLast in interface GenericDAO<T,PK extends Serializable>public PK getNextPK(PK id)
GenericDAO
getNextPK in interface GenericDAO<T,PK extends Serializable>public PK getPreviousPK(PK id)
GenericDAO
getPreviousPK in interface GenericDAO<T,PK extends Serializable>public org.hibernate.SessionFactory getSessionFactory()
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
protected static <T,PK extends Serializable> GenericHibernate4DAO<T,PK> createDaoInstance(Class<T> clazz)
clazz -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||