org.kuali.student.r2.common.dao
Class GenericEntityDao<T extends PersistableEntity<String>>

java.lang.Object
  extended by org.kuali.student.r2.common.dao.GenericEntityDao<T>
All Implemented Interfaces:
EntityDao<String,T>
Direct Known Subclasses:
AppointmentDao, AppointmentSlotDao, AppointmentWindowDao, AtpAtpRelationDao, AtpDao, AtpMilestoneRelationDao, CheckDao, EnumContextValueDao, EnumeratedValueDao, EnumerationDao, ExtendedOrgDao, InstructionDao, LifecycleDao, MilestoneDao, PopulationDao, PopulationRuleDao, ProcessDao, ResultScaleDao, ResultValueDao, ResultValuesGroupDao, ScheduleComponentDao, ScheduleDao, ScheduleRequestDao, StateChangeDao, StateConstraintDao, StateDao, SubjectCodeDao, SubjectCodeJoinOrgDao, TimeSlotDao, TypeDao, TypeTypeRelationDao

public class GenericEntityDao<T extends PersistableEntity<String>>
extends Object
implements EntityDao<String,T>

Author:
Kuali Student Team

Field Summary
protected  EntityManager em
           
protected  Class<T> entityClass
          Entity class.
 
Constructor Summary
GenericEntityDao()
           
 
Method Summary
 T find(String primaryKey)
          Find object by primary key.
 List<T> findAll()
          Load all entities of this type.
 List<T> findByIds(List<String> primaryKeys)
          Find objects of specified class by primary keys.
 List<T> findByIds(String primaryKeyMemberName, List<String> primaryKeys)
          Find objects of specified class by primary keys.
protected  List<T> findByIdsMaxKeys(List<String> primaryKeys)
          Use this method if the size of primary keys >= 1000.
 EntityManager getEm()
           
protected
<C extends T>
Class<C>
getEntityClass()
           
 T merge(T entity)
          Merge detached object.
 void persist(T entity)
          Persist unsaved object.
 void remove(T entity)
          Remove entity from the persistent store.
 void setEm(EntityManager em)
           
 void update(T entity)
          Update detached object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityClass

protected Class<T extends PersistableEntity<String>> entityClass
Entity class.


em

protected EntityManager em
Constructor Detail

GenericEntityDao

public GenericEntityDao()
Method Detail

find

public T find(String primaryKey)
Description copied from interface: EntityDao
Find object by primary key.

Specified by:
find in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
primaryKey - Primary key
Returns:
Entity for given key

findByIds

public List<T> findByIds(String primaryKeyMemberName,
                         List<String> primaryKeys)
                                                    throws DoesNotExistException
Description copied from interface: EntityDao
Find objects of specified class by primary keys.

Specified by:
findByIds in interface EntityDao<String,T extends PersistableEntity<String>>
primaryKeys - - list of Primary keys
Returns:
Entity for given key
Throws:
DoesNotExistException

findByIds

public List<T> findByIds(List<String> primaryKeys)
                                                    throws DoesNotExistException
Description copied from interface: EntityDao
Find objects of specified class by primary keys. Note: this method assumes that your primary key is "id"

Specified by:
findByIds in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
primaryKeys - - list of Primary keys
Returns:
Entity for given key
Throws:
DoesNotExistException

findByIdsMaxKeys

protected List<T> findByIdsMaxKeys(List<String> primaryKeys)
                                                              throws DoesNotExistException
Use this method if the size of primary keys >= 1000. 1000 is the "in" limit for many databases.

Parameters:
primaryKeys -
Returns:
Throws:
DoesNotExistException

findAll

public List<T> findAll()
Description copied from interface: EntityDao
Load all entities of this type.

Specified by:
findAll in interface EntityDao<String,T extends PersistableEntity<String>>
Returns:
List of entities

persist

public void persist(T entity)
Description copied from interface: EntityDao
Persist unsaved object.

Specified by:
persist in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
entity - Entity to save

update

public void update(T entity)
Description copied from interface: EntityDao
Update detached object.

Specified by:
update in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
entity - Entity to update

remove

public void remove(T entity)
Description copied from interface: EntityDao
Remove entity from the persistent store.

Specified by:
remove in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
entity - Entity to remove

merge

public T merge(T entity)
Description copied from interface: EntityDao
Merge detached object.

Specified by:
merge in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
entity - Entity to save
Returns:
Merged entity.

getEntityClass

protected <C extends T> Class<C> getEntityClass()

setEm

public void setEm(EntityManager em)
Specified by:
setEm in interface EntityDao<String,T extends PersistableEntity<String>>
Parameters:
em - An entity manager, if applicable

getEm

public EntityManager getEm()
Specified by:
getEm in interface EntityDao<String,T extends PersistableEntity<String>>
Returns:
An entity manager, if applicable


Copyright © 2004-2013 The Kuali Foundation. All Rights Reserved.