T - a type variablePK - the primary key for that typepublic class GenericDaoHibernate<T,PK extends Serializable> extends org.springframework.orm.hibernate3.support.HibernateDaoSupport implements GenericDao<T,PK>
To register this class in your Spring context file, use the following XML.
<bean id="fooDao" class="com.gisgraphy.dao.hibernate.GenericDaoHibernate">
<constructor-arg value="com.gisgraphy.model.Foo"/>
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
log
Log variable for all child classes.
|
| Constructor and Description |
|---|
GenericDaoHibernate(Class<T> persistentClass)
Constructor that takes in a class to see which type of entity to persist
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
exists(PK id)
Checks for existence of an object of type T using the id arg.
|
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.
|
void |
remove(PK id)
Generic method to delete an object based on class and id
|
T |
save(T object)
Generic method to save an object - handles both update and insert.
|
protected final org.apache.commons.logging.Log log
public List<T> getAll()
getAll in interface GenericDao<T,PK extends Serializable>public T get(PK id)
get in interface GenericDao<T,PK extends Serializable>id - the identifier (primary key) of the object to getObjectRetrievalFailureExceptionpublic boolean exists(PK id)
exists in interface GenericDao<T,PK extends Serializable>id - the id of the entitypublic T save(T object)
save in interface GenericDao<T,PK extends Serializable>object - the object to savepublic void remove(PK id)
remove in interface GenericDao<T,PK extends Serializable>id - the identifier (primary key) of the object to removeCopyright © 2015. All rights reserved.