zoukankan      html  css  js  c++  java
  • MyBatis(3.2.3)

    If we have a mapped statement that returns multiple rows and we want the results in a HashMap with some property value as the key and the resulting object as the value, we can use sqlSession.selectMap() as follows:

    <select id=" findAllStudents" resultMap="StudentResult">
    	select * from Students
    </select>
    
    Map<Integer, Student> studentMap = sqlSession.selectMap("com.mybatis3.mappers.StudentMapper.findAllStudents", "studId");

    Here studentMap will contain studId values as keys and Student objects as values.

  • 相关阅读:
    java 读取src下的配置文件
    图书管理系统
    StaticDemo
    MatixDemo
    Magics
    GetPrime
    ConWithThis
    TestTHIS
    ConstructorOverLoad
    Sequence
  • 原文地址:https://www.cnblogs.com/huey/p/5231724.html
Copyright © 2011-2022 走看看