1 /*****************************************************************************
5 * Creation date 08.10.2012
8 *****************************************************************************/
10 package org.splat.dal.dao.kernel;
12 import java.io.Serializable;
13 import java.util.List;
15 import org.hibernate.criterion.Criterion;
16 import org.hibernate.criterion.Order;
19 * Generic DAO interface.
21 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
24 * Persistent object class
28 public interface GenericDAO<T, PK extends Serializable> {
31 * Persist the newInstance object into database.
34 * new object as a transient instance
35 * @return new primary key for the created persistent object
37 PK create(T newInstance);
40 * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
43 * primary key of an object to read
44 * @return an object found by the given key
49 * Save changes made to a persistent object.
51 * @param transientObject
52 * transient instance of the object to update
54 void update(T transientObject);
57 * Remove an object from persistent storage in the database.
59 * @param persistentObject
60 * a persistent object to delete from the database
62 void delete(T persistentObject);
65 * Retrieve an object that was previously persisted to the database using the given criteria.
69 * @return an object found according to the given criteria
71 public T findByCriteria(Criterion aCondition);
74 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
78 * @return a list of objects filtered according to the given criteria
80 public List<T> getFilteredList(Criterion aCondition);
82 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
87 * a result list order. Null is ignored and in such case the result list is unordered.
88 * @return a list of objects filtered according to the given criteria
90 @SuppressWarnings("unchecked")
91 public List<T> getFilteredList(Criterion aCondition, Order anOrder);