Mybatis 返回值配置理解 您所在的位置:网站首页 resultType返回类型汇总 Mybatis 返回值配置理解

Mybatis 返回值配置理解

2023-12-11 09:06| 来源: 网络整理| 查看: 265

目录 前提1. 返回整形数值2. 返回值 BigDecimal 浮点数 金额类型3. 返回指定实体类格式的 List 数组参考链接

前提

Mybatis报错: A query was run and no Result Maps were found for the Mapped Statement

mybatis中的所有查询标签,都必须返回resultType或者resultMap的值,否则就会报如上错误的,其实仔细看看因为报错原因的意思就好了

1. 返回整形数值

TestMapper.xml 演示:

SELECT COUNT(1) FROM test_table

Java 调用演示:

@Autowired private TestMapper testMapper; Integer mycount = testMapper.getReturnNum(); 2. 返回值 BigDecimal 浮点数 金额类型

TestMapper.xml 演示:

SELECT IFNULL(SUM(mymoney), 0.00) FROM test_table

Java 调用演示:

@Autowired private TestMapper testMapper; Integer mycount = testMapper.getReturnAmount(); 3. 返回指定实体类格式的 List 数组

TestMapper.xml 演示:

SELECT * FROM test_table

Java 调用演示:

import com.test.entity.MyEntity; @Autowired private TestMapper testMapper; List myList = testMapper.getReturnList(); 参考链接

Mybatis报错: A query was run and no Result Maps were found for the Mapped Statement



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有