1 package com.germinus.merlin.dao; 2 3 import java.io.Serializable; 4 import java.util.List; 5 6 7 /** 8 * Generic DAO (Data Access Object) with common methods to CRUD POJOs. 9 * 10 * <p>Extend this interface if you want typesafe (no casting necessary) DAO's for your 11 * domain objects. 12 * 13 * @author <a href="mailto:bwnoll@gmail.com">Bryan Noll</a> 14 */ 15 public interface IGenericDao <T, PK extends Serializable> { 16 17 /** 18 * Generic method used to get all objects of a particular type. This 19 * is the same as lookup up all rows in a table. 20 * @return List of populated objects 21 */ 22 public List<T> getAll(); 23 24 /** 25 * Generic method to get an object based on class and identifier. An 26 * ObjectRetrievalFailureException Runtime Exception is thrown if 27 * nothing is found. 28 * 29 * @param id the identifier (primary assignmentId) of the object to get 30 * @return a populated object 31 * @see org.springframework.orm.ObjectRetrievalFailureException 32 */ 33 public T get(PK id); 34 35 /** 36 * Checks for existence of an object of type T using the id arg. 37 * @param id 38 * @return - true if it exists, false if it doesn't 39 */ 40 public boolean exists(PK id); 41 42 /** 43 * Generic method to save an object - handles both update and insert. 44 * @param object the object to save 45 */ 46 public T save(T object); 47 48 /** 49 * Generic method to delete an object based on class and id 50 * @param id the identifier (primary assignmentId) of the object to remove 51 */ 52 public void remove(PK id); 53 }