Mybatis 返回值配置理解 |
您所在的位置:网站首页 › decimal对应的实体类 › Mybatis 返回值配置理解 |
目录
前提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_tableJava 调用演示: @Autowired private TestMapper testMapper; Integer mycount = testMapper.getReturnNum(); 2. 返回值 BigDecimal 浮点数 金额类型TestMapper.xml 演示: SELECT IFNULL(SUM(mymoney), 0.00) FROM test_tableJava 调用演示: @Autowired private TestMapper testMapper; Integer mycount = testMapper.getReturnAmount(); 3. 返回指定实体类格式的 List 数组TestMapper.xml 演示: SELECT * FROM test_tableJava 调用演示: 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 办公设备维修网 版权所有 豫ICP备15022753号-3 |