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

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

public class PersistenceDaoJpa
extends Object
implements PersistenceDao


Constructor Summary
PersistenceDaoJpa()
           
 
Method Summary
protected  Object buildForeignKeyObject(Object o, EntityDescriptor localEntityDescriptor, ObjectDescriptor objectDescriptor)
          Builds a foreign key object for the relationship given by the foreignKeyClass and the objectDescriptor
protected  Map<String,JoinColumnDescriptor> buildJoinColumnDescriptorMap(List<JoinColumnDescriptor> joinColumnDescriptors)
          Turns a List of JoinColumnDescriptors and maps them by their name
protected  Object buildSingleKeyForeignKeyObject(Object o, String singleForeignKeyFieldName)
          Builds a foreign key, where that foreign key has a single field
 void clearCache()
           
 javax.persistence.EntityManager getEntityManager()
           
protected  String getForeignKeyPropertyForKey(String foreignKey, EntityDescriptor localEntityDescriptor, EntityDescriptor foreignEntityDescriptor, Map<String,JoinColumnDescriptor> joinColumnDescriptors)
          Finds the correct foreign key property which corresponds to the given key
protected  String getForeignKeyPropertyForKeyWithPossibleInverse(String foreignKey, EntityDescriptor localEntityDescriptor, EntityDescriptor foreignEntityDescriptor, CollectionDescriptor collectionDescriptor)
          Finds the correct foreign key property which corresponds to the given key
 boolean isProxied(Object object)
          True if object is an instance of HibernateProxy, false otherwise
protected  boolean isReferenceCollection(Object o, String referenceName)
          Determines if the reference on the given object represents a collection or not
 Object resolveProxy(Object o)
           
 void retrieveAllReferences(Object o)
           
protected  Collection retrieveCollectionReference(Object o, String referenceName)
          This method fetches a collection to refresh a reference
protected  Object retrieveObjectReference(Object o, String referenceName)
          Fetches an object reference
 void retrieveReference(Object o, String referenceName)
           
 void setEntityManager(javax.persistence.EntityManager entityManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceDaoJpa

public PersistenceDaoJpa()
Method Detail

clearCache

public void clearCache()
Specified by:
clearCache in interface PersistenceDao
See Also:
PersistenceDao.clearCache()

resolveProxy

public Object resolveProxy(Object o)
Specified by:
resolveProxy in interface PersistenceDao
See Also:
PersistenceDao.resolveProxy(java.lang.Object)

retrieveAllReferences

public void retrieveAllReferences(Object o)
Specified by:
retrieveAllReferences in interface PersistenceDao
See Also:
PersistenceDao.retrieveAllReferences(java.lang.Object)

retrieveReference

public void retrieveReference(Object o,
                              String referenceName)
Specified by:
retrieveReference in interface PersistenceDao
See Also:
PersistenceDao.retrieveReference(java.lang.Object, java.lang.String)

isReferenceCollection

protected boolean isReferenceCollection(Object o,
                                        String referenceName)
Determines if the reference on the given object represents a collection or not

Parameters:
o - the object which is to be refreshed
referenceName - the name of the reference to refresh
Returns:
true if the reference is a collection, false otherwise

retrieveCollectionReference

protected Collection retrieveCollectionReference(Object o,
                                                 String referenceName)
                                          throws NoSuchFieldException,
                                                 IllegalArgumentException,
                                                 IllegalAccessException
This method fetches a collection to refresh a reference

Parameters:
o - the object to refresh
referenceName - the name of the reference to refresh
Returns:
the retrieved object to refresh the
Throws:
NoSuchFieldException
IllegalAccessException
IllegalArgumentException

getForeignKeyPropertyForKeyWithPossibleInverse

protected String getForeignKeyPropertyForKeyWithPossibleInverse(String foreignKey,
                                                                EntityDescriptor localEntityDescriptor,
                                                                EntityDescriptor foreignEntityDescriptor,
                                                                CollectionDescriptor collectionDescriptor)
Finds the correct foreign key property which corresponds to the given key

Parameters:
foreignKey - the name of the key we want to find the proper foreign name for
localEntityDescriptor - the descriptor of the entity that key is on
foreignEntityDescriptor - the descriptor of the entity we're trying to retrieve
joinColumnDescriptors - a Map of the JoinColumnDescriptors that describe the relationship from the local entity's point of view, keyed by the column name of the JoinColumnDescriptor
Returns:
the name of the property on the related object

retrieveObjectReference

protected Object retrieveObjectReference(Object o,
                                         String referenceName)
                                  throws IllegalArgumentException,
                                         IllegalAccessException,
                                         NoSuchFieldException,
                                         InstantiationException,
                                         ClassNotFoundException
Fetches an object reference

Parameters:
o - the object to refresh
referenceName - the name of the reference to fetch
Returns:
the fetched referred to object
Throws:
IllegalAccessException
IllegalArgumentException
NoSuchFieldException
ClassNotFoundException
InstantiationException

buildForeignKeyObject

protected Object buildForeignKeyObject(Object o,
                                       EntityDescriptor localEntityDescriptor,
                                       ObjectDescriptor objectDescriptor)
                                throws IllegalArgumentException,
                                       NoSuchFieldException,
                                       IllegalAccessException,
                                       InstantiationException
Builds a foreign key object for the relationship given by the foreignKeyClass and the objectDescriptor

Parameters:
o - the object to refresh
localEntityDescriptor - the entity descriptor for that object
objectDescriptor - the object descriptor for the relationship to refresh
Returns:
the foreign key to fetch that object
Throws:
IllegalArgumentException
NoSuchFieldException
IllegalAccessException
InstantiationException

getForeignKeyPropertyForKey

protected String getForeignKeyPropertyForKey(String foreignKey,
                                             EntityDescriptor localEntityDescriptor,
                                             EntityDescriptor foreignEntityDescriptor,
                                             Map<String,JoinColumnDescriptor> joinColumnDescriptors)
Finds the correct foreign key property which corresponds to the given key

Parameters:
foreignKey - the name of the key we want to find the proper foreign name for
localEntityDescriptor - the descriptor of the entity that key is on
foreignEntityDescriptor - the descriptor of the entity we're trying to retrieve
joinColumnDescriptors - a Map of the JoinColumnDescriptors that describe the relationship from the local entity's point of view, keyed by the column name of the JoinColumnDescriptor
Returns:
the name of the property on the related object

buildJoinColumnDescriptorMap

protected Map<String,JoinColumnDescriptor> buildJoinColumnDescriptorMap(List<JoinColumnDescriptor> joinColumnDescriptors)
Turns a List of JoinColumnDescriptors and maps them by their name

Parameters:
joinColumnDescriptors - a List of JoinColumnDescriptors
Returns:
a Map the List as a Map, keyed by the name of the JoinColumn

buildSingleKeyForeignKeyObject

protected Object buildSingleKeyForeignKeyObject(Object o,
                                                String singleForeignKeyFieldName)
                                         throws NoSuchFieldException,
                                                IllegalArgumentException,
                                                IllegalAccessException
Builds a foreign key, where that foreign key has a single field

Parameters:
o - the object to get the foreign key value from
singleForeignKeyFieldName - the name of the foreign key field
Returns:
a value for the foreign key
Throws:
NoSuchFieldException
IllegalArgumentException
IllegalAccessException

isProxied

public boolean isProxied(Object object)
True if object is an instance of HibernateProxy, false otherwise

Specified by:
isProxied in interface PersistenceDao
Parameters:
object - the object to determine if it is a proxy
Returns:
true if the object is an ORM proxy; false otherwise
See Also:
PersistenceDao.isProxied(java.lang.Object)

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-2013 The Kuali Foundation. All Rights Reserved.