2016 - 2024

感恩一路有你

mybatis返回list结果集 mybatis怎么返回一个map?

浏览量:2617 时间:2021-03-15 12:27:59 作者:admin

mybatis怎么返回一个map?

MapParam.java 需要mybatis返回Map时需要指定参数类型为MapParam,可以通过构造函数单独指定Key

mybatis怎么返回null值返回类型是个map?

创建mybatis-config.xml123456789<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEconfigurationPUBLIC"-//mybatis.org//DTDConfig3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><settings><!--当返回数据类型为map,设置callSettersOnNulls会把值为null的key也返回--><settingname="callSettersOnNulls"value="true"/></settings></configuration>在配置数据源的配置文件中,配置Mybatis的SqlSessionFactoryBean123456789<beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="configLocation"value="classpath:/META-INF/spring/mybatis-config.xml"/><propertyname="mapperLocations"><array>  <value>classpath*:/yunnex/saofu/shop/beibao/mappe

mybatis如何返回list>?

Mapper里面返回List,就是说Mapper里面的方法声明是

public List

dao、service层也作相应修改,改为返回List

SELECT count(*) value, c. NAME label, ifnull(b.device_status, 0) device_status

FROM td01_device a

LEFT OUTER JOIN td06_device_status b ON a.id = b.device_id

LEFT OUTER JOIN td05_dd_device_status c ON c.ID = ifnull(b.device_status, 0)

GROUP BY ifnull(b.device_status, 0), c. NAME

ORDER BY device_status

public interface OnlineStatMapper {

public List

}

mybatis返回list结果集 mybatis返回map集合 mybatis返回map结果集

版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。