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 all objects of the considered type T which were previously persisted to the database.
76 * @return a list of all objects of the considered type T
78 @SuppressWarnings("unchecked")
79 public List<T> getAll();
82 * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
85 * a result list order. Null is ignored and in such case the result list is unordered.
86 * @return an ordered list of all objects of the considered type T
88 @SuppressWarnings("unchecked")
89 public List<T> getAll(Order anOrder);
92 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
96 * @return a list of objects filtered according to the given criteria
98 public List<T> getFilteredList(Criterion aCondition);
100 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
105 * a result list order. Null is ignored and in such case the result list is unordered.
106 * @return a list of objects filtered according to the given criteria
108 @SuppressWarnings("unchecked")
109 public List<T> getFilteredList(Criterion aCondition, Order anOrder);
112 * Makes detached object persistent.
113 * @param transientObject
114 * transient instance of the object to be made persistent
116 public void persist(T transientObject);
119 * Merge detached object with persistent data.
121 * @param transientObject
122 * transient instance of the object to be merged with persistent data
123 * @return merged persistent object
125 public T merge(T transientObject);