1 package org.kuali.student.r2.common.dao; 2 3 import java.io.Serializable; 4 import java.util.List; 5 6 /** 7 * Interface, that describes default methods of Dao objects for entity. 8 * 9 * @author ihar 10 */ 11 public interface EntityDao<T> { 12 13 /** 14 * Find object by primary key. 15 * 16 * @param primaryKey Primary key 17 * @return Entity for given key 18 */ 19 T find(Serializable primaryKey); 20 21 /** 22 * Find objects of specified class by primary keys. 23 * 24 * @param primaryKeys - list of Primary keys 25 * @return Entity for given key 26 */ 27 public List<T> findByIds(List<? extends Serializable> primaryKeys) throws Exception; 28 29 /** 30 * Load all entities of this type. 31 * 32 * @return List of entities 33 */ 34 List<T> findAll(); 35 36 /** 37 * Persist unsaved object. 38 * 39 * @param entity Entity to save 40 */ 41 void persist(T entity); 42 43 /** 44 * Update detached object. 45 * 46 * @param entity Entity to update 47 */ 48 void update(T entity); 49 50 51 /** 52 * Merge detached object. 53 * 54 * @param entity Entity to save 55 * @param <T> the Entity type 56 * @return Merged entity. 57 */ 58 T merge(T entity); 59 60 /** 61 * Remove entity from the persistent store. 62 * 63 * @param entity Entity to remove 64 */ 65 void remove(T entity); 66 }