org.kuali.rice.core.dao
Interface GenericDao

All Known Implementing Classes:
GenericDaoOjb

public interface GenericDao

This is the generic data access interface for business objects. This class was adapted from the Kuali Nervous System (org.kuali.rice.kns.dao.BusinessObjectDao). It's not as generic as it could be as it relies on the OJB criteria object...

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

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 keyValue)
          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, 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, 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 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
 

Method Detail

save

void save(Object bo)
Saves any object

Parameters:
bo -

save

void save(List businessObjects)
Saves a List of objects

Parameters:
businessObjects -

findById

Object findById(Class clazz,
                Object keyValue)
Retrieves an object instance identified bys it primary key.

Parameters:
clazz - the class
id - the primary key value
Returns:
Object

findByPrimaryKey

Object findByPrimaryKey(Class clazz,
                        Map primaryKeys)
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.

Parameters:
clazz -
primaryKeys -
Returns:
Object

findByUniqueKey

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

Parameters:
clazz -
uniqueKeys -
Returns:
Object

retrieve

Object retrieve(Object object)
Retrieves an object instance identified by the class of the given object and the object's primary key values.

Parameters:
object -
Returns:
Object

findMatchingByExample

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. This is basically a query by "template" method.

Parameters:
object -
Returns:
Collection

findAll

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. This will only retrieve business objects by class type.

Parameters:
clazz -
Returns:
Collection

findAllOrderBy

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. This will only retrieve business objects by class type. Orders the results by the given field.

Parameters:
clazz -
Returns:
Collection

findMatching

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. This will retrieve business objects by class type and also by criteria passed in as key-value pairs, specifically attribute name-expected value.

Parameters:
clazz -
fieldValues -
Returns:
Collection

findMatching

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.

Parameters:
clazz -
criteria -
Returns:
Collection

findMatching

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.

Parameters:
clazz -
criteria -
selectForUpdate - whether to perform a select for update query
wait - millis to wait for select for update
Returns:
Collection

countMatching

int countMatching(Class clazz,
                  Map fieldValues)
Parameters:
clazz -
fieldValues -
Returns:
count of BusinessObjects of the given class whose fields match the values in the given Map.

countMatching

int countMatching(Class clazz,
                  Map positiveFieldValues,
                  Map negativeFieldValues)
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"

Parameters:
clazz -
positiveFieldValues - Map of fields and values for positive criteria
negativeFieldValues - Map of fields and values for negative criteria
Returns:
int

findMatchingOrderBy

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

Parameters:
clazz -
fieldValues -
Returns:
Collection

delete

void delete(Object bo)
Deletes a business object from the database.

Parameters:
bo -

delete

void delete(List<Object> boList)
Deletes each business object in the given List from the database.

Parameters:
boList -

deleteMatching

void deleteMatching(Class clazz,
                    Map fieldValues)
Deletes the business objects matching the given fieldValues

Parameters:
clazz -
fieldValues -


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.