org.kuali.rice.core.impl.persistence.dao
Class GenericDaoOjb

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport
          extended by org.kuali.rice.core.impl.persistence.dao.GenericDaoOjb
All Implemented Interfaces:
GenericDao, org.springframework.beans.factory.InitializingBean

public class GenericDaoOjb
extends org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport
implements GenericDao

This class is the OJB implementation of the GenericDao interface. This class was adapted from the Kuali Nervous System (org.kuali.rice.krad.dao.impl.GenericDaoOjb).

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
GenericDaoOjb()
           
 
Method Summary
 int countMatching(Class clazz, Map fieldValues)
           
 int countMatching(Class clazz, Map positiveFieldValues, Map negativeFieldValues)
          This method returns the number of matching result given the positive criterias and negative criterias.
 void delete(List<Object> boList)
          Deletes each business object in the given List from the database.
 void delete(Object bo)
          Deletes a business object from the database.
 void deleteMatching(Class clazz, Map fieldValues)
          Deletes the business objects matching the given fieldValues
 Collection findAll(Class clazz)
          Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
 Collection findAllOrderBy(Class clazz, String sortField, boolean sortAscending)
          Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
 Object findById(Class clazz, Object id)
          Retrieves an object instance identified bys it primary key.
 Object findByPrimaryKey(Class clazz, Map primaryKeys)
          Retrieves an object instance identified by its primary keys and values.
 Object findByUniqueKey(Class clazz, Map uniqueKeys)
          This method should be used to try and locate an object instance by passing in unique keys and values.
 Collection findMatching(Class clazz, org.apache.ojb.broker.query.Criteria criteria)
          This method allows for a more flexible search by allowing the programmer to construct the criteria however they need to and then pass that in for execution.
 Collection findMatching(Class clazz, Criteria criteria)
          This overridden method ...
 Collection findMatching(Class clazz, org.apache.ojb.broker.query.Criteria criteria, boolean selectForUpdate, long wait)
          This method allows for a more flexible search by allowing the programmer to construct the criteria however they need to and then pass that in for execution.
 Collection findMatching(Class clazz, Criteria criteria, boolean selectForUpdate, long wait)
          This overridden method ...
 Collection findMatching(Class clazz, Map fieldValues)
          This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
 Collection findMatching(Class clazz, Map criteria, boolean selectForUpdate, long wait)
          This overridden method ...
 Collection findMatchingByExample(Object object)
          This method allows you to pass in an object that has some fields filled in, and will query underneath by automatically constructing a select statement whose where clause is built automatically by looking at the non-null attributes and using their values as part of the query.
 Collection findMatchingOrderBy(Class clazz, Map fieldValues, String sortField, boolean sortAscending)
          This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
 Object retrieve(Object object)
          Retrieves an object instance identified by the class of the given object and the object's primary key values.
 void save(List businessObjects)
          Saves a List of objects
 void save(Object bo)
          Saves any object
 void setUseSelectForUpdate(boolean useSelectForUpdate)
           
 
Methods inherited from class org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport
checkDaoConfig, convertOjbAccessException, createPersistenceBrokerTemplate, getJcdAlias, getPersistenceBroker, getPersistenceBrokerTemplate, releasePersistenceBroker, setJcdAlias, setPersistenceBrokerTemplate
 
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
 

Constructor Detail

GenericDaoOjb

public GenericDaoOjb()
Method Detail

setUseSelectForUpdate

public void setUseSelectForUpdate(boolean useSelectForUpdate)
Parameters:
selectForUpdate - whether to use select for update to implement pessimistic locking (testing/debugging purposes only)

findById

public Object findById(Class clazz,
                       Object id)
Description copied from interface: GenericDao
Retrieves an object instance identified bys it primary key.

Specified by:
findById in interface GenericDao
Parameters:
clazz - the class
Returns:
Object
See Also:
GenericDao.findById(Class, Object)

findByPrimaryKey

public Object findByPrimaryKey(Class clazz,
                               Map primaryKeys)
Description copied from interface: GenericDao
Retrieves an object instance identified by its primary keys and values. This can be done by constructing a map where the key to the map entry is the primary key attribute and the value of the entry being the primary key value. For composite keys, pass in each primaryKey attribute and its value as a map entry.

Specified by:
findByPrimaryKey in interface GenericDao
Returns:
Object
See Also:
GenericDao.findByPrimaryKey(java.lang.Class, java.util.Map)

findByUniqueKey

public Object findByUniqueKey(Class clazz,
                              Map uniqueKeys)
Description copied from interface: GenericDao
This method should be used to try and locate an object instance by passing in unique keys and values. This can be done by constructing a map where the key to the map entry is the unique key attribute and the value of the entry being the unique key value. For composite keys, pass in each unique key attribute and its value as a map entry.

Specified by:
findByUniqueKey in interface GenericDao
Returns:
Object
See Also:
GenericDao.findByUniqueKey(java.lang.Class, java.util.Map)

findAll

public Collection findAll(Class clazz)
Description copied from interface: GenericDao
Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will only retrieve business objects by class type.

Specified by:
findAll in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findAll(java.lang.Class)

findAllOrderBy

public Collection findAllOrderBy(Class clazz,
                                 String sortField,
                                 boolean sortAscending)
Description copied from interface: GenericDao
Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will only retrieve business objects by class type. Orders the results by the given field.

Specified by:
findAllOrderBy in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findAllOrderBy(java.lang.Class, java.lang.String, boolean)

findMatching

public Collection findMatching(Class clazz,
                               Map fieldValues)
Description copied from interface: GenericDao
This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs, specifically attribute name-expected value.

Specified by:
findMatching in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findMatching(java.lang.Class, java.util.Map)

countMatching

public int countMatching(Class clazz,
                         Map fieldValues)
Specified by:
countMatching in interface GenericDao
Returns:
count of BusinessObjects of the given class whose fields match the values in the given Map.
See Also:
GenericDao.countMatching(java.lang.Class, java.util.Map)

countMatching

public int countMatching(Class clazz,
                         Map positiveFieldValues,
                         Map negativeFieldValues)
Description copied from interface: GenericDao
This method returns the number of matching result given the positive criterias and negative criterias. The negative criterias are the ones that will be set to "notEqualTo" or "notIn"

Specified by:
countMatching in interface GenericDao
positiveFieldValues - Map of fields and values for positive criteria
negativeFieldValues - Map of fields and values for negative criteria
Returns:
int
See Also:
GenericDao.countMatching(java.lang.Class, java.util.Map, java.util.Map)

findMatchingOrderBy

public Collection findMatchingOrderBy(Class clazz,
                                      Map fieldValues,
                                      String sortField,
                                      boolean sortAscending)
Description copied from interface: GenericDao
This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs, specifically attribute name-expected value. Orders the results by the given field.

Specified by:
findMatchingOrderBy in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findMatchingOrderBy(java.lang.Class, java.util.Map, java.lang.String, boolean)

save

public void save(Object bo)
          throws org.springframework.dao.DataAccessException
Description copied from interface: GenericDao
Saves any object

Specified by:
save in interface GenericDao
Throws:
org.springframework.dao.DataAccessException
See Also:
GenericDao.save(java.lang.Object)

save

public void save(List businessObjects)
          throws org.springframework.dao.DataAccessException
Description copied from interface: GenericDao
Saves a List of objects

Specified by:
save in interface GenericDao
Throws:
org.springframework.dao.DataAccessException
See Also:
GenericDao.save(java.util.List)

delete

public void delete(Object bo)
Description copied from interface: GenericDao
Deletes a business object from the database.

Specified by:
delete in interface GenericDao
See Also:
GenericDao.delete(java.lang.Object)

delete

public void delete(List<Object> boList)
Description copied from interface: GenericDao
Deletes each business object in the given List from the database.

Specified by:
delete in interface GenericDao
See Also:
GenericDao.delete(java.util.List)

deleteMatching

public void deleteMatching(Class clazz,
                           Map fieldValues)
Description copied from interface: GenericDao
Deletes the business objects matching the given fieldValues

Specified by:
deleteMatching in interface GenericDao
See Also:
GenericDao.deleteMatching(java.lang.Class, java.util.Map)

retrieve

public Object retrieve(Object object)
Description copied from interface: GenericDao
Retrieves an object instance identified by the class of the given object and the object's primary key values.

Specified by:
retrieve in interface GenericDao
Returns:
Object
See Also:
GenericDao.retrieve(java.lang.Object)

findMatchingByExample

public Collection findMatchingByExample(Object object)
Description copied from interface: GenericDao
This method allows you to pass in an object that has some fields filled in, and will query underneath by automatically constructing a select statement whose where clause is built automatically by looking at the non-null attributes and using their values as part of the query. This is basically a query by "template" method.

Specified by:
findMatchingByExample in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findMatchingByExample(java.lang.Object)

findMatching

public Collection findMatching(Class clazz,
                               org.apache.ojb.broker.query.Criteria criteria)
Description copied from interface: GenericDao
This method allows for a more flexible search by allowing the programmer to construct the criteria however they need to and then pass that in for execution.

Specified by:
findMatching in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findMatching(java.lang.Class, org.apache.ojb.broker.query.Criteria)

findMatching

public Collection findMatching(Class clazz,
                               org.apache.ojb.broker.query.Criteria criteria,
                               boolean selectForUpdate,
                               long wait)
Description copied from interface: GenericDao
This method allows for a more flexible search by allowing the programmer to construct the criteria however they need to and then pass that in for execution.

Specified by:
findMatching in interface GenericDao
selectForUpdate - whether to perform a select for update query
wait - millis to wait for select for update
Returns:
Collection
See Also:
org.kuali.rice.core.framework.persistence.dao.GenericDao#findMatching(Class, Criteria, boolean)

findMatching

public Collection findMatching(Class clazz,
                               Criteria criteria)
This overridden method ...

Specified by:
findMatching in interface GenericDao
Returns:
Collection
See Also:
GenericDao.findMatching(java.lang.Class, org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria)

findMatching

public Collection findMatching(Class clazz,
                               Criteria criteria,
                               boolean selectForUpdate,
                               long wait)
This overridden method ...

Specified by:
findMatching in interface GenericDao
selectForUpdate - whether to perform a select for update query
wait - millis to wait for select for update
Returns:
Collection
See Also:
GenericDao.findMatching(java.lang.Class, org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria, boolean, long)

findMatching

public Collection findMatching(Class clazz,
                               Map criteria,
                               boolean selectForUpdate,
                               long wait)
This overridden method ...

Specified by:
findMatching in interface GenericDao
See Also:
GenericDao.findMatching(java.lang.Class, java.util.Map, boolean, long)


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.