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;
14 import java.util.Properties;
16 import org.hibernate.criterion.Criterion;
17 import org.hibernate.criterion.Order;
20 * Generic DAO interface.
22 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
25 * Persistent object class
29 public interface GenericDAO<T, PK extends Serializable> {
32 * Persist the newInstance object into database.
35 * new object as a transient instance
36 * @return new primary key for the created persistent object
38 PK create(T newInstance);
41 * Retrieve an object that was previously persisted to the database using the indicated id as primary key.
44 * primary key of an object to read
45 * @return an object found by the given key
50 * Save changes made to a persistent object.
52 * @param transientObject
53 * transient instance of the object to update
55 void update(T transientObject);
58 * Remove an object from persistent storage in the database.
60 * @param persistentObject
61 * a persistent object to delete from the database
63 void delete(T persistentObject);
66 * Retrieve an object that was previously persisted to the database using the given criteria.
70 * @return an object found according to the given criteria
72 public T findByCriteria(Criterion aCondition);
75 * Retrieve an object that was previously persisted to the database using the given criteria.
78 * a properties values to filter with AND condition
79 * @return an object found according to the given criteria
81 public T findByCriteria(Properties andParams);
84 * Retrieve a list of all objects of the considered type T which were previously persisted to the database.
86 * @return a list of all objects of the considered type T
88 public List<T> getAll();
91 * Retrieve an ordered list of all objects of the considered type T which were previously persisted to the database.
94 * a result list order. Null is ignored and in such case the result list is unordered.
95 * @return an ordered list of all objects of the considered type T
97 public List<T> getAll(Order... anOrder);
100 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
104 * @return a list of objects filtered according to the given criteria
106 public List<T> getFilteredList(Criterion aCondition);
109 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
114 * a result list order. Null is ignored and in such case the result list is unordered.
115 * @return a list of objects filtered according to the given criteria
117 public List<T> getFilteredList(Criterion aCondition, Order... anOrder);
120 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
123 * a properties values to filter with AND condition
124 * @return a list of objects filtered according to the given criteria
126 public List<T> getFilteredList(Properties andParams);
129 * Retrieve a list of objects which were previously persisted to the database using the given criteria.
132 * a properties values to filter with AND condition
134 * a result list order. Null is ignored and in such case the result list is unordered.
135 * @return a list of objects filtered according to the given criteria
137 public List<T> getFilteredList(Properties andParams, Order... anOrder);
140 * Makes detached object persistent.
142 * @param transientObject
143 * transient instance of the object to be made persistent
145 public void persist(T transientObject);
148 * Merge detached object with persistent data.
150 * @param transientObject
151 * transient instance of the object to be merged with persistent data
152 * @return merged persistent object
154 public T merge(T transientObject);
157 * Synchronize the session data with the database.