com.gisgraphy.dao.hibernate
Class UniversalDaoHibernate
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate3.support.HibernateDaoSupport
com.gisgraphy.dao.hibernate.UniversalDaoHibernate
- All Implemented Interfaces:
- UniversalDao, org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
- LookupDaoHibernate
public class UniversalDaoHibernate
- extends org.springframework.orm.hibernate3.support.HibernateDaoSupport
- implements UniversalDao
This class serves as the a class that can CRUD any object witout any Spring
configuration. The only downside is it does require casting from Object to
the object class.
- Author:
- Bryan Noll
Field Summary |
protected org.apache.commons.logging.Log |
log
Log variable for all child classes. |
Fields inherited from class org.springframework.dao.support.DaoSupport |
logger |
Method Summary |
java.lang.Object |
get(java.lang.Class<?> clazz,
java.io.Serializable id)
Generic method to get an object based on class and identifier. |
java.util.List<?> |
getAll(java.lang.Class<?> clazz)
Generic method used to get all objects of a particular type. |
void |
remove(java.lang.Class<?> clazz,
java.io.Serializable id)
Generic method to delete an object based on class and id |
java.lang.Object |
save(java.lang.Object o)
Generic method to save an object - handles both update and insert. |
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport |
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory |
Methods inherited from class org.springframework.dao.support.DaoSupport |
afterPropertiesSet, initDao |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected final org.apache.commons.logging.Log log
- Log variable for all child classes. Uses LogFactory.getLog(getClass())
from Commons Logging
UniversalDaoHibernate
public UniversalDaoHibernate()
save
public java.lang.Object save(java.lang.Object o)
- Generic method to save an object - handles both update and insert.
- Specified by:
save
in interface UniversalDao
- Parameters:
o
- the object to save
- Returns:
- a populated object
get
public java.lang.Object get(java.lang.Class<?> clazz,
java.io.Serializable id)
- Generic method to get an object based on class and identifier. An
ObjectRetrievalFailureException Runtime Exception is thrown if nothing is
found.
- Specified by:
get
in interface UniversalDao
- Parameters:
clazz
- model class to lookupid
- the identifier (primary key) of the class
- Returns:
- a populated object
- See Also:
ObjectRetrievalFailureException
getAll
public java.util.List<?> getAll(java.lang.Class<?> clazz)
- Generic method used to get all objects of a particular type. This is the
same as lookup up all rows in a table.
- Specified by:
getAll
in interface UniversalDao
- Parameters:
clazz
- the type of objects (a.k.a. while table) to get data from
- Returns:
- List of populated objects
remove
public void remove(java.lang.Class<?> clazz,
java.io.Serializable id)
- Generic method to delete an object based on class and id
- Specified by:
remove
in interface UniversalDao
- Parameters:
clazz
- model class to lookupid
- the identifier (primary key) of the class
Copyright © 2010. All Rights Reserved.