org.ow2.dragon.persistence.dao
Class GenericHibernateCompassDAOImpl<T extends SearchableBaseObject,PK extends java.io.Serializable>

java.lang.Object
  extended by org.ow2.dragon.persistence.dao.GenericHibernateCompassDAOImpl<T,PK>
All Implemented Interfaces:
GenericUnifiedDAO<T,PK>
Direct Known Subclasses:
OrganizationUnitUnifiedDAOImpl

public class GenericHibernateCompassDAOImpl<T extends SearchableBaseObject,PK extends java.io.Serializable>
extends java.lang.Object
implements GenericUnifiedDAO<T,PK>

Author:
ofabre - eBM Websourcing

Constructor Summary
GenericHibernateCompassDAOImpl()
           
 
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 requestOptionsTO)
          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.
protected  GenericORMDAO<T,PK> getGenericORMDAO()
           
protected  GenericOSEMDAO<T,PK> getGenericOSEMDAO()
           
 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.
 java.util.List<T> search(com.trg.search.IMutableSearch search)
          Search for objects based on the search parameters in the specified ISearch object.
 java.util.List<T> search(java.lang.String query)
          Return a List of entity managed by the Full Text Search Engine (Compass etc.).
 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 requestOptionsTO)
          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 requestOptionsTO)
          This method allows to search Objects on String properties, fitting search criteria.
 java.util.List<T> searchORMResult(java.lang.String query)
          Process a research on Full Text Search Engine (Compass etc.) index and return a List of entity managed by the ORM engine (Hibernate, iBatis etc.).
 java.util.List<T> searchORMResult(java.lang.String[] criteria, java.lang.String[] searchedProperties)
          This method allows to search Objects on String properties, fitting search criteria.
 java.util.List<T> searchORMResult(java.lang.String[] criteria, java.lang.String[] searchedProperties, RequestOptions requestOptions)
          This method allows to search Objects on String properties, fitting search criteria.
 java.util.List<T> searchORMResult(java.lang.String query, RequestOptions requestOptions)
          Process a research on Full Text Search Engine (Compass etc.) index and return a List of entity managed by the ORM engine (Hibernate, iBatis etc.), sorted and paginated according to the given request options.
 T searchUnique(com.trg.search.IMutableSearch search)
          Search for a single result using the given parameters.
 void setGenericORMDAO(GenericORMDAO<T,PK> genericORMDAO)
           
 void setGenericOSEMDAO(GenericOSEMDAO<T,PK> genericOSEMDAO)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericHibernateCompassDAOImpl

public GenericHibernateCompassDAOImpl()
Method Detail

exists

public boolean exists(PK id)
Checks for existence of an object of type T using the id arg.

Specified by:
exists in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
id - the id of the entity
Returns:
- true if it exists, false if it doesn't

findByNamedQuery

public 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

Specified by:
findByNamedQuery in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
queryName - query name of the named query
queryParams - a map of the query names and the values
Returns:
a list of the records found

get

public T get(PK id)
Return the persistent instance of an entity with the given identifier, or null if not found.

Specified by:
get in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
id - the identifier of the persistent instance
Returns:
the persistent instance, or null if not found
See Also:
Session.get(Class, java.io.Serializable)

getAll

public java.util.List<T> getAll(RequestOptions requestOptionsTO)
Generic method used to get all objects of a particular type, sorted and paginated according to the given request options. This is the same as lookup up all rows in a table.

Specified by:
getAll in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
requestOptionsTO - include sort order and pagination information, could be null
Returns:
List of populated objects

getAll

public java.util.List<T> getAll()
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 GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Returns:
List of populated objects

getAllDistinct

public java.util.List<T> getAllDistinct()
Gets all records without duplicates.

Note that if you use this method, it is imperative that your model classes correctly implement the hashcode/equals methods

Specified by:
getAllDistinct in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Returns:
List of populated objects

remove

public void remove(PK id)
Generic method to delete an object based on class and id

Specified by:
remove in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
id - the identifier (primary key) of the object to remove

save

public T save(T object)
Generic method to save an object - handles both update and insert.

Specified by:
save in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
object - the object to save
Returns:
the persisted object

search

public java.util.List<T> search(java.lang.String query)
Return a List of entity managed by the Full Text Search Engine (Compass etc.). Only the search engine managed attributes of these entities are populated

Specified by:
search in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
query - a Lucene String query
Returns:
a List of entity managed by the Full Text Search Engine.

searchEquals

public java.util.List<T> searchEquals(java.lang.String[] criteria,
                                      java.lang.String[] properties,
                                      RequestOptions requestOptionsTO)
This method allows to search Objects on String properties, fitting search criteria. Properties can be direct object fields or fields of included objects (in this case, fields must be referenced by the doted notation like "foo.bar"). Use a equality statement for each criteria on each property. Results are sorted and paginated in respect of the given request options.

Specified by:
searchEquals in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
criteria - the search criteria
properties - the searched properties
requestOptionsTO - include sort order and pagination information, could be null
Returns:
a list of object matching the different criteria sorted and paginated

searchLike

public java.util.List<T> searchLike(java.lang.String[] criteria,
                                    java.lang.String[] properties,
                                    RequestOptions requestOptionsTO)
This method allows to search Objects on String properties, fitting search criteria. Properties can be direct object fields or fields of included objects (in this case, fields must be referenced by the doted notation like "foo.bar"). Use a like statement for each criteria on each property. Results are sorted and paginated in respect of the given request options.

Specified by:
searchLike in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
criteria - the search criteria
properties - the searched properties
requestOptionsTO - include sort order and pagination information, could be null
Returns:
a list of object matching the different criteria sorted and paginated

searchORMResult

public java.util.List<T> searchORMResult(java.lang.String query)
Process a research on Full Text Search Engine (Compass etc.) index and return a List of entity managed by the ORM engine (Hibernate, iBatis etc.). All ORM managed attributes of these entities are populated.

Specified by:
searchORMResult in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
query - a Lucene String query
Returns:
a List of entity managed by the ORM engine.

searchORMResult

public java.util.List<T> searchORMResult(java.lang.String query,
                                         RequestOptions requestOptions)
Process a research on Full Text Search Engine (Compass etc.) index and return a List of entity managed by the ORM engine (Hibernate, iBatis etc.), sorted and paginated according to the given request options. All ORM managed attributes of these entities are populated.

Specified by:
searchORMResult in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
query - a Lucene String query
requestOptions - include sort order and pagination information, could be null
Returns:
a List of entity managed by the ORM engine.

getAll

public java.util.List<T> getAll(java.util.List<PK> ids,
                                RequestOptions requestOptions)
Description copied from interface: GenericUnifiedDAO
Retrieve a List of entities matching given ids, sorted and paginated according to the given request options

Specified by:
getAll in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
ids - a List of ids
requestOptions - include sort order and pagination information, could be null
Returns:
a sorted/paginated List of entities matching ids, must be non null, could be empty

getAll

public java.util.List<T> getAll(java.util.List<PK> ids)
Description copied from interface: GenericUnifiedDAO
Retrieve a List of entities matching given ids

Specified by:
getAll in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
ids - a List of ids
Returns:
a List of entities matching ids, must be non null, could be empty

searchORMResult

public java.util.List<T> searchORMResult(java.lang.String[] criteria,
                                         java.lang.String[] searchedProperties)
                                                               throws DAOLayerException
This method allows to search Objects on String properties, fitting search criteria. Properties can be direct object fields or fields of included objects (in this case, fields must be referenced by the doted notation like "foo.bar"). Process a research on Full Text Search Engine (Compass etc.) index and return a List of entity managed by the ORM engine (Hibernate, iBatis etc.). All ORM managed attributes of these entities are populated.

Specified by:
searchORMResult in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
criteria - the search criteria
Returns:
a List of entity managed by the ORM engine.
Throws:
DAOLayerException

searchORMResult

public java.util.List<T> searchORMResult(java.lang.String[] criteria,
                                         java.lang.String[] searchedProperties,
                                         RequestOptions requestOptions)
                                                               throws DAOLayerException
This method allows to search Objects on String properties, fitting search criteria. Properties can be direct object fields or fields of included objects (in this case, fields must be referenced by the doted notation like "foo.bar"). Process a research on Full Text Search Engine (Compass etc.) index and return a List of entity managed by the ORM engine (Hibernate, iBatis etc.), sorted and paginated according to the given request options. All ORM managed attributes of these entities are populated.

Specified by:
searchORMResult in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Parameters:
criteria - the search criteria
requestOptions - include sort order and pagination information, could be null
Returns:
a List of entity managed by the ORM engine.
Throws:
DAOLayerException

setGenericOSEMDAO

public void setGenericOSEMDAO(GenericOSEMDAO<T,PK> genericOSEMDAO)

setGenericORMDAO

public void setGenericORMDAO(GenericORMDAO<T,PK> genericORMDAO)

count

public 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.

Specified by:
count in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
See Also:
ISearch

search

public java.util.List<T> search(com.trg.search.IMutableSearch search)
Search for objects based on the search parameters in the specified ISearch object.

Specified by:
search in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
See Also:
ISearch

searchAndCount

public 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.

Specified by:
searchAndCount in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
See Also:
ISearch

searchUnique

public T searchUnique(com.trg.search.IMutableSearch search)
                                            throws org.hibernate.NonUniqueResultException
Search for a single result using the given parameters.

Specified by:
searchUnique in interface GenericUnifiedDAO<T extends SearchableBaseObject,PK extends java.io.Serializable>
Throws:
org.hibernate.NonUniqueResultException

getGenericOSEMDAO

protected GenericOSEMDAO<T,PK> getGenericOSEMDAO()

getGenericORMDAO

protected GenericORMDAO<T,PK> getGenericORMDAO()


Copyright © 2008-2009 eBMWebsourcing. All Rights Reserved.