The logic of implementation is generally
Generaldao (Interface). Abstractgeneraldaoimpl (abstract Class), Generalservice (Interface), Abstractgeneralserviceimpl (abstract class).
Specific
Idao extends Generaldao,
Idaoimpl extends Abstractgeneraldaoimpl,
IService extends Generalservice,
Iserviceimpl extends Abstractgeneralserviceimpl
The implementation code is as follows.
Generaldao<t, ID extends serializable>
1:import java.io.Serializable
2:import java.util.Collection;
3:import java.util.List;
4:
5 : Import Pagingvo;
6:
7:/**
8: * General DAO
9: *
: * @author hacker-ttao
: * @version 0.1.0
12: */
13:public interface generaldao<t, ID extends serializable> {
:
15:t FindByID (ID ID);
17:list<t> findall ()
:
19:pagingvo getpagingdata (int currentpage, int pageSize);
21:t Save (T entity)
:
23:void Save (T ... entity);
:
25:t update (t entity); br>:
27:void update (collection<t> entity)
:
29:void saveorupdate (T entity);
30:
31:void Saveorupdate (collection<t> entities);
:
33:void Delete (T entity),
:
35:void Delete (ID ID),
:
37:void Delete (Col lection<t> entities);
:
39:void Marge (T eneity);
:
41:void Marge (T. eneity);
:
43:int getcount ();
: