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 * Insert a new entity.
12 * create- and lastmodified-date is set with current time.
13 *
14 * @param entity - detached entity object
15 * @see Session#save(Object)
16 */
17 public void save(T entity);
18
19 /**
20 * Inserts a new detached entity or updates if it already exists.
21 * create- and update-date are set automatically.
22 *
23 * @param entity - entity object to be inserted or updated
24 * @see Session#saveOrUpdate(Object)
25 */
26 public void saveOrUpdate(T entity);
27
28 /**
29 * Deletes entity from persistence store.
30 *
31 * @see Session#delete(Object)
32 */
33 public void delete(T entity);
34
35 /**
36 * Remove this instance from the session cache.
37 *
38 * @see Session#evict(Object)
39 */
40 public void detach(T entity);
41
42 /**
43 * Reloads an entity from persistance.
44 *
45 * @see Session#refresh(Object)
46 */
47 public void refresh(T entity);
48
49 /**
50 * Copy the state of the given object onto the persistent object with the same
51 * identifier. If there is no persistent instance currently associated with
52 * the session, it will be loaded.
53 *
54 * @see Session#merge(Object)
55 */
56 public T merge(T entity);
57 }