项目的持久层用的hibernate,给项目做框架的用的是封装的一套方法
一个更新的流程
BaseDao:
public <T> void update(T obj);
BaseDaolmpl:
private SessionFactory sessionFactory;
public <T> void update(T obj){
sessionFactory.getCurrentSession().update(obj);
}
EmpDao:
public Emp update(Emp obj) throws Exception;
EmpDaoImpl:
private BaseDao ibaseDao;
public Emp update(Emp obj) throws Exception{
ibaseDao.update(obj);
return obj;
}
EmpService:
public Emp update(Emp obj) throws Exception;
EmpServiceImpl:
private EmpDao empDao;
public Emp update(Emp obj) throws Exception{
obj=empDao.update(obj);
return obj;
}
EmpAction:
private EmpService empService;
public void update(){
Emp emp=this.getModel();
try{
empService.update(emp);
}catch(){}
}
以上就是走了一个流程;他用的是封装好的方法。但是如果我要是想要写sql语句,应该则么写?在哪写?怎么调用?
------解决思路----------------------
你自己写的dao继承BaseDao