|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate3.support.HibernateDaoSupport
org.ow2.dragon.persistence.dao.GenericHibernateDAOImpl<T,PK>
T - a type variablePK - the primary key for that typepublic class GenericHibernateDAOImpl<T,PK extends java.io.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.
To register this class in your Spring context file, use the following XML.
<bean id="fooDao" class="org.ow2.dragon.persistence.dao.GenericDaoHibernate">
<property name="type" value="org.ow2.dragon.persistence.bo.Foo"/>
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
| Field Summary | |
|---|---|
java.lang.Class<T> |
type
|
| Fields inherited from class org.springframework.dao.support.DaoSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
GenericHibernateDAOImpl()
|
|
| Method Summary | |
|---|---|
int |
count(com.trg.search.IMutableSearch search)
Returns the total number of results that would be returned using the given ISearch if there were no paging or maxResult limits. |
boolean |
exists(PK id)
Checks for existence of an object of type T using the id arg. |
java.util.List<T> |
findByNamedQuery(java.lang.String queryName,
java.util.Map<java.lang.String,java.lang.Object> queryParams)
Find a list of records by using a named query |
T |
get(PK id)
Return the persistent instance of an entity with the given identifier, or null if not found. |
java.util.List<T> |
getAll()
Generic method used to get all objects of a particular type. |
java.util.List<T> |
getAll(java.util.List<PK> ids)
Retrieve a List of entities matching given ids |
java.util.List<T> |
getAll(java.util.List<PK> ids,
RequestOptions requestOptions)
Retrieve a List of entities matching given ids, sorted and
paginated according to the given request options |
java.util.List<T> |
getAll(RequestOptions requestOptions)
Generic method used to get all objects of a particular type, sorted and paginated according to the given request options. |
java.util.List<T> |
getAllDistinct()
Gets all records without duplicates. |
java.lang.Class<T> |
getManipulatedType()
Return the type of entity manipulated by this DAO |
void |
remove(PK id)
Generic method to delete an object based on class and id |
void |
remove(T object)
Generic method to delete an object |
T |
save(T object)
Generic method to save an object - handles both update and insert. |
java.util.List<T> |
search(com.trg.search.IMutableSearch search)
Search for objects based on the search parameters in the specified ISearch object. |
com.trg.search.SearchResult<T> |
searchAndCount(com.trg.search.IMutableSearch search)
Returns a SearchResult object that includes the list of
results like search() and the total length like
searchLength. |
java.util.List<T> |
searchEquals(java.lang.String[] criteria,
java.lang.String[] properties,
RequestOptions requestOptions)
This method allows to search Objects on String properties, fitting search criteria. |
java.util.List<T> |
searchLike(java.lang.String[] criteria,
java.lang.String[] properties,
RequestOptions requestOptions)
This method allows to search Objects on String properties, fitting search criteria. |
T |
searchUnique(com.trg.search.IMutableSearch search)
Search for a single result using the given parameters. |
void |
setType(java.lang.Class<T> type)
|
| 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 |
|---|
public java.lang.Class<T> type
| Constructor Detail |
|---|
public GenericHibernateDAOImpl()
| Method Detail |
|---|
public void setType(java.lang.Class<T> type)
public java.util.List<T> getAll(RequestOptions requestOptions)
getAll in interface GenericORMDAO<T,PK extends java.io.Serializable>requestOptions - include sort order and pagination information
public java.util.List<T> searchEquals(java.lang.String[] criteria,
java.lang.String[] properties,
RequestOptions requestOptions)
searchEquals in interface GenericORMDAO<T,PK extends java.io.Serializable>criteria - the search criteriaproperties - the searched propertiesrequestOptions - include sort order and pagination information
public java.util.List<T> searchLike(java.lang.String[] criteria,
java.lang.String[] properties,
RequestOptions requestOptions)
searchLike in interface GenericORMDAO<T,PK extends java.io.Serializable>criteria - the search criteriaproperties - the searched propertiesrequestOptions - include sort order and pagination information
public java.util.List<T> getAll()
getAll in interface GenericORMDAO<T,PK extends java.io.Serializable>public java.util.List<T> getAll(java.util.List<PK> ids)
GenericORMDAOList of entities matching given ids
getAll in interface GenericORMDAO<T,PK extends java.io.Serializable>ids - a List of ids
List of entities matching ids, must be non null, could
be empty
public java.util.List<T> getAll(java.util.List<PK> ids,
RequestOptions requestOptions)
List of entities matching given ids, sorted and
paginated according to the given request options
getAll in interface GenericORMDAO<T,PK extends java.io.Serializable>ids - a List of idsrequestOptions - include sort order and pagination information
List of entities matching ids, must be
non null, could be emptypublic java.util.List<T> getAllDistinct()
Note that if you use this method, it is imperative that your model classes correctly implement the hashcode/equals methods
getAllDistinct in interface GenericORMDAO<T,PK extends java.io.Serializable>public T get(PK id)
null if not found.
get in interface GenericORMDAO<T,PK extends java.io.Serializable>id - the identifier of the persistent instance
null if not foundSession.get(Class, java.io.Serializable)public boolean exists(PK id)
exists in interface GenericORMDAO<T,PK extends java.io.Serializable>id - the id of the entity
public T save(T object)
save in interface GenericORMDAO<T,PK extends java.io.Serializable>object - the object to save
public void remove(PK id)
remove in interface GenericORMDAO<T,PK extends java.io.Serializable>id - the identifier (primary key) of the object to removepublic void remove(T object)
remove in interface GenericORMDAO<T,PK extends java.io.Serializable>object - the object to remove
public java.util.List<T> findByNamedQuery(java.lang.String queryName,
java.util.Map<java.lang.String,java.lang.Object> queryParams)
findByNamedQuery in interface GenericORMDAO<T,PK extends java.io.Serializable>queryName - query name of the named queryqueryParams - a map of the query names and the values
public java.lang.Class<T> getManipulatedType()
getManipulatedType in interface GenericORMDAO<T,PK extends java.io.Serializable>Class of the manipulated entitypublic java.util.List<T> search(com.trg.search.IMutableSearch search)
ISearch object.
search in interface GenericORMDAO<T,PK extends java.io.Serializable>ISearchpublic int count(com.trg.search.IMutableSearch search)
ISearch if there were no paging or maxResult limits.
count in interface GenericORMDAO<T,PK extends java.io.Serializable>ISearchpublic com.trg.search.SearchResult<T> searchAndCount(com.trg.search.IMutableSearch search)
SearchResult object that includes the list of
results like search() and the total length like
searchLength.
searchAndCount in interface GenericORMDAO<T,PK extends java.io.Serializable>ISearch
public T searchUnique(com.trg.search.IMutableSearch search)
throws org.hibernate.NonUniqueResultException
searchUnique in interface GenericORMDAO<T,PK extends java.io.Serializable>org.hibernate.NonUniqueResultException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||