1、创建dao接口的实现类
UserDao userDao = sqlSession.getMapper(UserDao.class);
一下代码是UserDao接口的实现类
public interface UserDao(){
select List queryAllUsers();
}
public void testProxy(){
UerDao userdao =
Proxy.newProxyInstance(this.clas.getClassLoader(),UserDao.class,InvocationHandler);
}
2、实现接口的方法queryAllUsers
List<Object> lists = sqlsession.selectList("xxx.UserDao "+"".+ "queryAllUsers");
public class testProxyInvocationHandler implement InvocationHandler{
@Override
public Object invoke(Object proxy, Method method, Object[] args){
List<Object> lists = sqlsession.selectList("xxx.UserDao "+"".+ method.getName());
}
}
网友评论