码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis中的include标签学习

时间:2018-04-30 14:31:30      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:mybatis中的include标签学习

<!-- sql标签可以存放多条sql语句中相同的部分 --> <sql id="common"> username,PASSWORD </sql> <!-- include 标签--> <select id="getUserByConditionSql" resultType="Map" parameterType="Map"> SELECT <include refid="common"/> FROM users WHERE username=#{username} AND PASSWORD=#{password} </select> <select id="getUserByConditionSql2" resultType="Map" parameterType="Map"> SELECT <include refid="common"/> FROM users </select>
  /**
     *sql 与 include 标签
     *
     * */
    @Test
    public void getUserByConditionSql() {
        // 1、创建一个Map来封装参数
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("username", "北京");
        paramMap.put("password", "8888");
        Map<String, Object> userMap = session.selectOne("cn.liwen.impl.UserDaoImpl.getUserByConditionSql", paramMap);
        System.out.println(userMap);// null
    }

    @Test
    public void getUserByConditionSql2() {
        // 1、创建一个Map来封装参数
        List<Map<String, Object>> userList = session.selectList("cn.liwen.impl.UserDaoImpl.getUserByConditionSql2");
        System.out.println(userList);
    }

mybatis中的include标签学习

标签:mybatis中的include标签学习

原文地址:http://blog.51cto.com/357712148/2109219

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!