zoukankan      html  css  js  c++  java
  • Mybatis三种查询方式

    1.selectList()返回值为List<resultType属性控制>

      适用于查询结果都需要遍历的需求:

    List<Flower> list = session.selectList(com.mapper.FlowerMapper.selAll);
            for(Flower flower :list) {
                System.out.println(flower.toString());
            }

    2.selectOne()返回值Object

      适用于返回结果只是变量或一行数据时

    int count = session.selectOne("com.mapper.FlowerMapper.selById");
            System.out.println(count);

    3.selectMap()返回值Map

      适用于需要在查询结果中通过某列的值取到这行数据的需求

      Map<key,resultType控制>

    Map<Object, Object> map = session.selectMap("com.mapper.FlowerMapper.selMap", "name");
            System.out.println(map);

    xml配置文档中对应代码

    <select id="selAll" resultType="com.pojo.Flower">
              select * from flower
          </select>
          <select id="selById" resultType="int">
              select count(*) from flower
          </select>
          <select id="selMap" resultType="com.pojo.Flower">
              select * from flower
          </select>
  • 相关阅读:
    MSDN相关下载地址
    显示代码的博客
    unittest 结合 ddt
    python 学习2 测试报告
    python pytest
    Yaml 的python 应用
    linux 面试题
    面试 常见问题
    Python 内建的filter()函数用于过滤序列。
    python reduce & map 习题
  • 原文地址:https://www.cnblogs.com/haq123/p/9765760.html
Copyright © 2011-2022 走看看