com.gisgraphy.dao.hibernate
Class UniversalDaoHibernate

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by 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
 
Constructor Summary
UniversalDaoHibernate()
           
 
Method Summary
 Object get(Class<?> clazz, Serializable id)
          Generic method to get an object based on class and identifier.
 List<?> getAll(Class<?> clazz)
          Generic method used to get all objects of a particular type.
 void remove(Class<?> clazz, Serializable id)
          Generic method to delete an object based on class and id
 Object save(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
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Log variable for all child classes. Uses LogFactory.getLog(getClass()) from Commons Logging

Constructor Detail

UniversalDaoHibernate

public UniversalDaoHibernate()
Method Detail

save

public Object save(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 Object get(Class<?> clazz,
                  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 lookup
id - the identifier (primary key) of the class
Returns:
a populated object
See Also:
ObjectRetrievalFailureException

getAll

public List<?> getAll(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(Class<?> clazz,
                   Serializable id)
Generic method to delete an object based on class and id

Specified by:
remove in interface UniversalDao
Parameters:
clazz - model class to lookup
id - the identifier (primary key) of the class


Copyright © 2012. All Rights Reserved.