美文网首页
mybatis dao层接口的实现

mybatis dao层接口的实现

作者: zzz_0427 | 来源:发表于2024-05-18 13:50 被阅读0次

    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());
    }
    }

    相关文章

      网友评论

          本文标题:mybatis dao层接口的实现

          本文链接:https://www.haomeiwen.com/subject/jbwwfjtx.html