void saveOrUpdate(T entity);
27:
28: void saveOrUpdate(Collection<T> entities);
29:
30: void delete(T entity);
31:
32: void delete(Collection<T> entities);
33:
34: void delete(ID id);
35:
36: void marge(T eneity);
37:
38: void marge(T... eneity);
39: }
JavaEE 3蚊尺更議DAO,Service,Web酒汽撃廾(5)
扮寂:2011-02-04 鴬人坩 Hacker-TTAO
AbstractServiceImpl<T, ID extends Serializable, DAO extends GeneralDAO<T, ID>>
1: import java.io.Serializable;
2: import java.util.Collection;
3: import java.util.List;
4:
5: import org.apache.commons.logging.Log;
6: import org.apache.commons.logging.LogFactory;
7:
8: /**
9: *
10: * @author Hacker-TTAO
11: *
12: * @param <T>
13: * @param <ID>
14: * @param <DAO>
15: */
16: public abstract class AbstractServiceImpl<T, ID extends Serializable, DAO extends GeneralDAO<T, ID>> implements GeneralService<T, ID, DAO> {
17:
18: private DAO dao;
19:
20: private static final Log log = LogFactory.getLog(AbstractServiceImpl.class);
21:
22: public List<T> findAll() {
23: List<T> result = getDao().findAll();
24: log.info("findAll execute success");
25: return result;
26: }
27:
28: public T findByID(ID id) {
29: T result = getDao().findByID(id);
30: log.info("findById execute success");
31: return result;
32: }
33:
34: public void delete(Collection<T> entities) {
35: getDao().update(entities);
36: }
37:
38: public void delete(T entity) {
39: getDao().delete(entity);
40: }
41:
42: public void delete(ID id) {
43: getDao().delete(id);
44: }
45:
46: public void marge(T... eneity) {
47: }
48:
49: public void marge(T eneity) {
50: getDao().marge(eneity);
51:
52: }
53:
54: public void save(T... entity) {
55: getDao().save(entity);
56: }
57:
58: public T save(T entity) {
59: return getDao().save(entity);
60: }
61:
62: public void saveOrUpdate(Collection<T> entities) {
63: getDao().saveOrUpdate(entities);
64: }
65:
66: public void saveOrUpdate(T entity) {
67: getDao().saveOrUpdate(entity);
68: }
69:
70: public void update(Collection<T> entity) {
71: getDao().update(entity);
72: }
73:
74: public T update(T entity)
|