Mapper代理_多条件查询

<select id="dim" resultType="DimDyl.Demo05.Dio">
    select * from tb_brand
    where
    id = #{id}
    and Pp_ename  like #{Pp_ename}
    and Qy_ename  like #{Qy_ename};
</select>
     //散装参数
    //List<Dio> dim(@Param("id") int id, @Param("Pp_ename") String Pp_ename, @Param("Qy_ename") String Qy_ename);
    //实体类封装参数
   //List<Dio> dim(Dio dim);
  //map集合
    List<Dio> dim(Map dim);
  //获取查询信息
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();
        String Pp_ename = sc.next();
        String Qy_ename = sc.next();
        //模糊查询
        Pp_ename = "%" + Pp_ename + "%";
        Qy_ename = "%" + Qy_ename + "%";

         //List<Dio> dim(Dio dim);
        //Dio d = new Dio();
       //d.setId(id);
      //d.setPp_ename(Pp_ename);
     //d.setQy_ename(Qy_ename);

        //map
        Map map = new HashMap();
        map.put("id",id);
        map.put("Pp_ename", Pp_ename);
        map.put("Qy_ename",Qy_ename);
        //加载mybatis核心文件
        String re = "mybatis-config.xml";
        InputStream resourceAsStream = Resources.getResourceAsStream(re);
        SqlSessionFactory sq = new SqlSessionFactoryBuilder().build(resourceAsStream);
        //获取sqlsessio对象执行sql
        SqlSession sqlSession = sq.openSession();
        //获取mapper代理接口\
        Demo01 mapper = sqlSession.getMapper(Demo01.class);
       // List<Dio> dim = mapper.dim(id, Pp_ename, Qy_ename);
        // List<Dio> dim = mapper.dim(d);
        List<Dio> dim = mapper.dim(map);

        System.out.println(dim);

您可能还喜欢...