org.kuali.rice.krad.dao.impl
Class BusinessObjectDaoJpa

java.lang.Object
  extended by org.kuali.rice.krad.dao.impl.BusinessObjectDaoJpa
All Implemented Interfaces:
BusinessObjectDao

public class BusinessObjectDaoJpa
extends Object
implements BusinessObjectDao

This class is the JPA implementation of the BusinessObjectDao interface.


Constructor Summary
BusinessObjectDaoJpa(javax.persistence.EntityManager entityManager, PersistenceStructureService persistenceStructureService)
           
 
Method Summary
 int countMatching(Class clazz, Map<String,?> fieldValues)
          This is the default impl that comes with Kuali - uses OJB.
 int countMatching(Class clazz, Map<String,?> positiveFieldValues, Map<String,?> negativeFieldValues)
          This is the default impl that comes with Kuali - uses OJB.
 void delete(List<? extends PersistableBusinessObject> boList)
          Deletes each business object in the given List from the database.
 void delete(PersistableBusinessObject bo)
          Deletes the business object passed in.
 void deleteMatching(Class clazz, Map<String,?> fieldValues)
          Deletes the business objects matching the given fieldValues
<T extends BusinessObject>
Collection<T>
findAll(Class<T> clazz)
          Retrieves all of the records for a given class name.
<T extends BusinessObject>
Collection<T>
findAllActive(Class<T> clazz)
          Retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
<T extends BusinessObject>
Collection<T>
findAllActiveOrderBy(Class<T> 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.
<T extends BusinessObject>
Collection<T>
findAllInactive(Class<T> clazz)
           
<T extends BusinessObject>
Collection<T>
findAllOrderBy(Class<T> 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.
<T extends BusinessObject>
T
findByPrimaryKey(Class<T> clazz, Map<String,?> primaryKeys)
          Retrieves an object instance identified bys it primary keys and values.
<T extends BusinessObject>
T
findByPrimaryKeyUsingKeyObject(Class<T> clazz, Object pkObject)
          Retrieves an object, based on its PK object
<T extends BusinessObject>
T
findBySinglePrimaryKey(Class<T> clazz, Object primaryKey)
          Retrieves an object instance identified by its primary key.
<T extends BusinessObject>
Collection<T>
findMatching(Class<T> clazz, Map<String,?> fieldValues)
          This is the default impl that comes with Kuali - uses OJB.
<T extends BusinessObject>
Collection<T>
findMatching(Criteria criteria)
          Uses the passed query to form a Rice QueryByCriteria, which then translates to a JPA query and retrieves results
<T extends BusinessObject>
Collection<T>
findMatchingActive(Class<T> clazz, Map<String,?> fieldValues)
          This method retrieves a collection of business objects populated with data, such that each record in the database populates a new object instance.
<T extends BusinessObject>
Collection<T>
findMatchingOrderBy(Class<T> clazz, Map<String,?> fieldValues, String sortField, boolean sortAscending)
          This is the default impl that comes with Kuali - uses OJB.
 javax.persistence.EntityManager getEntityManager()
           
protected  PersistenceStructureService getPersistenceStructureService()
          Gets the persistenceStructureService attribute.
 PersistableBusinessObject manageReadOnly(PersistableBusinessObject bo)
          Merges the given business object, but tells the ORM that the object is to be treated as Read Only, and even if it has changes, it will not be persisted to the database
protected  PersistableBusinessObject materialize(PersistableBusinessObject bo)
          If the object is a proxy, materializes it
 PersistableBusinessObject retrieve(PersistableBusinessObject object)
          Retrieves an object instance identified by the class of the given object and the object's primary key values.
 List<? extends PersistableBusinessObject> save(List businessObjects)
          Saves a business object.
 PersistableBusinessObject save(PersistableBusinessObject bo)
          Saves a business object.
 void setEntityManager(javax.persistence.EntityManager entityManager)
           
 void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
          Sets the persistenceStructureService attribute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BusinessObjectDaoJpa

public BusinessObjectDaoJpa(javax.persistence.EntityManager entityManager,
                            PersistenceStructureService persistenceStructureService)
Method Detail

findBySinglePrimaryKey

public <T extends BusinessObject> T findBySinglePrimaryKey(Class<T> clazz,
                                                           Object primaryKey)
Description copied from interface: BusinessObjectDao
Retrieves an object instance identified by its primary key. For composite keys, use BusinessObjectDao.findByPrimaryKey(Class, Map)

Specified by:
findBySinglePrimaryKey in interface BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.findBySinglePrimaryKey(java.lang.Class, java.lang.Object)

findByPrimaryKey

public <T extends BusinessObject> T findByPrimaryKey(Class<T> clazz,
                                                     Map<String,?> primaryKeys)
Description copied from interface: BusinessObjectDao
Retrieves an object instance identified bys it 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 BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.findByPrimaryKey(java.lang.Class, java.util.Map)

findByPrimaryKeyUsingKeyObject

public <T extends BusinessObject> T findByPrimaryKeyUsingKeyObject(Class<T> clazz,
                                                                   Object pkObject)
Retrieves an object, based on its PK object

Specified by:
findByPrimaryKeyUsingKeyObject in interface BusinessObjectDao
Parameters:
clazz - the class of the object to retrieve
pkObject - the value of the primary key
Returns:
the retrieved PersistableBusinessObject

findAll

public <T extends BusinessObject> Collection<T> findAll(Class<T> clazz)
Retrieves all of the records for a given class name.

Specified by:
findAll in interface BusinessObjectDao
Parameters:
clazz - - the name of the object being used, either KualiCodeBase or a subclass
Returns:
Collection
See Also:
BusinessObjectDao.findAll(java.lang.Class)

findAllOrderBy

public <T extends BusinessObject> Collection<T> findAllOrderBy(Class<T> clazz,
                                                               String sortField,
                                                               boolean sortAscending)
Description copied from interface: BusinessObjectDao
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 BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.findAllOrderBy(java.lang.Class, java.lang.String, boolean)

findMatching

public <T extends BusinessObject> Collection<T> findMatching(Class<T> clazz,
                                                             Map<String,?> fieldValues)
This is the default impl that comes with Kuali - uses OJB.

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

findMatching

public <T extends BusinessObject> Collection<T> findMatching(Criteria criteria)
Uses the passed query to form a Rice QueryByCriteria, which then translates to a JPA query and retrieves results

See Also:
org.kuali.rice.krad.dao.BusinessObjectDao#findMatching(org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria)

findAllActive

public <T extends BusinessObject> Collection<T> findAllActive(Class<T> clazz)
Description copied from interface: BusinessObjectDao
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. Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active

Specified by:
findAllActive in interface BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.findAllActive(java.lang.Class)

findAllInactive

public <T extends BusinessObject> Collection<T> findAllInactive(Class<T> clazz)
Specified by:
findAllInactive in interface BusinessObjectDao
See Also:
BusinessObjectDao.findAllActive(java.lang.Class)

findAllActiveOrderBy

public <T extends BusinessObject> Collection<T> findAllActiveOrderBy(Class<T> clazz,
                                                                     String sortField,
                                                                     boolean sortAscending)
Description copied from interface: BusinessObjectDao
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. Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active

Specified by:
findAllActiveOrderBy in interface BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.findAllActiveOrderBy(java.lang.Class, java.lang.String, boolean)

findMatchingActive

public <T extends BusinessObject> Collection<T> findMatchingActive(Class<T> clazz,
                                                                   Map<String,?> fieldValues)
Description copied from interface: BusinessObjectDao
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. Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active

Specified by:
findMatchingActive in interface BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.findMatchingActive(java.lang.Class, java.util.Map)

countMatching

public int countMatching(Class clazz,
                         Map<String,?> fieldValues)
This is the default impl that comes with Kuali - uses OJB.

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

countMatching

public int countMatching(Class clazz,
                         Map<String,?> positiveFieldValues,
                         Map<String,?> negativeFieldValues)
This is the default impl that comes with Kuali - uses OJB.

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

findMatchingOrderBy

public <T extends BusinessObject> Collection<T> findMatchingOrderBy(Class<T> clazz,
                                                                    Map<String,?> fieldValues,
                                                                    String sortField,
                                                                    boolean sortAscending)
This is the default impl that comes with Kuali - uses OJB.

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

save

public PersistableBusinessObject save(PersistableBusinessObject bo)
                               throws org.springframework.dao.DataAccessException
Saves a business object.

Specified by:
save in interface BusinessObjectDao
Throws:
org.springframework.dao.DataAccessException
See Also:
BusinessObjectDao.save(org.kuali.rice.krad.bo.PersistableBusinessObject)

save

public List<? extends PersistableBusinessObject> save(List businessObjects)
                                               throws org.springframework.dao.DataAccessException
Saves a business object.

Specified by:
save in interface BusinessObjectDao
Throws:
org.springframework.dao.DataAccessException
See Also:
BusinessObjectDao.save(org.kuali.rice.krad.bo.PersistableBusinessObject)

delete

public void delete(PersistableBusinessObject bo)
Deletes the business object passed in.

Specified by:
delete in interface BusinessObjectDao
Parameters:
bo -
Throws:
org.springframework.dao.DataAccessException
See Also:
BusinessObjectDao.delete(org.kuali.rice.krad.bo.PersistableBusinessObject)

materialize

protected PersistableBusinessObject materialize(PersistableBusinessObject bo)
If the object is a proxy, materializes it

Parameters:
bo - the business object, which may be a sneaky proxy
Returns:
the materialized non-proxied business object

delete

public void delete(List<? extends PersistableBusinessObject> boList)
Description copied from interface: BusinessObjectDao
Deletes each business object in the given List from the database.

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

deleteMatching

public void deleteMatching(Class clazz,
                           Map<String,?> fieldValues)
Description copied from interface: BusinessObjectDao
Deletes the business objects matching the given fieldValues

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

retrieve

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

Specified by:
retrieve in interface BusinessObjectDao
Returns:
See Also:
BusinessObjectDao.retrieve(org.kuali.rice.krad.bo.PersistableBusinessObject)

manageReadOnly

public PersistableBusinessObject manageReadOnly(PersistableBusinessObject bo)
Description copied from interface: BusinessObjectDao
Merges the given business object, but tells the ORM that the object is to be treated as Read Only, and even if it has changes, it will not be persisted to the database

Specified by:
manageReadOnly in interface BusinessObjectDao
Parameters:
bo - the business object to managed
Returns:
the managed copied of the business object
See Also:
BusinessObjectDao.manageReadOnly(org.kuali.rice.krad.bo.PersistableBusinessObject)

getPersistenceStructureService

protected PersistenceStructureService getPersistenceStructureService()
Gets the persistenceStructureService attribute.

Returns:
Returns the persistenceStructureService.

setPersistenceStructureService

public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
Sets the persistenceStructureService attribute value.

Parameters:
persistenceStructureService - The persistenceStructureService to set.

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Returns:
the entityManager

setEntityManager

public void setEntityManager(javax.persistence.EntityManager entityManager)
Parameters:
entityManager - the entityManager to set


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