1 package org.itracker.persistence.dao;
2
3 import org.hibernate.Session;
4 import org.itracker.model.Entity;
5
6 /**
7 *
8 */
9 public interface BaseDAO<T extends Entity> {
10 /**
11 *
12 * Insert a new entity.
13 * create- and lastmodified-date is set with current time.
14 *
15 * @see Session#save(Object)
16 *
17 * @param entity - detached entity object
18 */
19 public void save(T entity);
20 /**
21 *
22 * Inserts a new detached entity or updates if it already exists.
23 * create- and update-date are set automatically.
24 *
25 * @see Session#saveOrUpdate(Object)
26 *
27 * @param entity - entity object to be inserted or updated
28 */
29 public void saveOrUpdate(T entity);
30
31 /**
32 *
33 * Deletes entity from persistence store.
34 *
35 * @see Session#delete(Object)
36 *
37 * @param entity
38 */
39 public void delete(T entity);
40
41 /**
42 *
43 * Remove this instance from the session cache.
44 *
45 * @see Session#evict(Object)
46 *
47 * @param entity
48 */
49 public void detach(T entity);
50
51 /**
52 *
53 * Reloads an entity from persistance.
54 *
55 * @see Session#refresh(Object)
56 *
57 * @param entity
58 */
59 public void refresh(T entity);
60 /**
61 *
62 * Copy the state of the given object onto the persistent object with the same
63 * identifier. If there is no persistent instance currently associated with
64 * the session, it will be loaded.
65 *
66 * @see Session#merge(Object)
67 *
68 * @param entity
69 * @return
70 */
71 public T merge(T entity);
72 }