今天在写项目的时候发现了点小问题:
需求是:需要从数据库中用聚合函数sum查询一个属性的总数,并且要查询到此行的其他信息
jtt的query()方法以及jtt.list()方法 均 设置为对应语句参数以及传入包裹对象为Map.class后,查询发现返回空集合
解决方法为:
使用以下语句进行查询:
jdbcTemplate.queryForList(SEVEN_DAY_RANK_SQL, new Object[]{});
查询实现将结果行映射为一个map对象
将所有结果集中的结果行放入一个list中并返回list
成功返回结果:
{
"msg": "",
"rankList": [
{
"exchange_item_id": 1,
"sender_acount_id": 1,
"receiver_acount_id": 2,
"exchange_type": 1,
"amount": 1111,
"create_time": 1441443600000,
"pay_type": 1,
"pay_no": "1",
"status": 1,
"totalMoney": 8328
},
{
"exchange_item_id": 13,
"sender_acount_id": 3,
"receiver_acount_id": 2,
"exchange_type": 1,
"amount": 1111,
"create_time": 1441443600000,
"pay_type": 1,
"pay_no": "1",
"status": 1,
"totalMoney": 3654
},
{
"exchange_item_id": 25,
"sender_acount_id": 5,
"receiver_acount_id": 2,
"exchange_type": 1,
"amount": 1111,
"create_time": 1441443600000,
"pay_type": 1,
"pay_no": "1",
"status": 1,
"totalMoney": 2332
},
{
"exchange_item_id": 23,
"sender_acount_id": 4,
"receiver_acount_id": 2,
"exchange_type": 1,
"amount": 1111,
"create_time": 1441443600000,
"pay_type": 1,
"pay_no": "1",
"status": 1,
"totalMoney": 1234
},
{
"exchange_item_id": 28,
"sender_acount_id": 6,
"receiver_acount_id": 2,
"exchange_type": 1,
"amount": 100,
"create_time": 1441443600000,
"pay_type": 1,
"pay_no": "1",
"status": 1,
"totalMoney": 200
}
],
"status": "0"
}
相关推荐
spring-jdbc-4.2.4.RELEASE.jar,spring-tx-4.2.4.RELEASE.jar,jdbcTemplate使用的jar包
使用spring+springmvc+jdbcTemplate 数据库使用orcal、redis 完成一个webdemo
spring-jdbc-5.2.7.RELEASE.jar,JdbcTemplate所需要的jar包。
29.2. Using JdbcTemplate 29.3. JPA and “Spring Data” 29.3.1. Entity Classes 29.3.2. Spring Data JPA Repositories 29.3.3. Creating and Dropping JPA Databases 29.3.4. Open EntityManager in View 29.4. ...
Spring5.2.6相关环境资源,以及JdbcTemplate学习过程中需要的jar包,解压后将需要的jar包导入项目即可使用。包括:mysql-connector-java-8.0.29.jar、com.springsource.net.sf.cglib-2.2.0.jar、...
Spring4--3.jdbcTemplate事务
查询所有的内容,封装为list用 :template.queryForList(sql) 查询所有的内容,封装为对象用:template.query(sql, new BeanPropertyRowMapper<对象>(对象.class)); 查询需要使用聚合函数的内容,如:select count...
spring中使用JdbcTemplate操作数据库crud,一图详解(脑图)
commons-logging-1.2.jar druid-1.0.9.jar mysql-connector-java-5.1.7-bin.jar spring-aop-5.3.4.jar spring-aspects-5.3.4.jar spring-beans-5.3.4.jar spring-context-5.3.4.jar ...spring-tx-5.3.4.jar
spring-ldap-1.3.0.RELEASE-with-dependencies.zip spring对ldap的封装,用法与jdbctemplate类似。 为什么传了1.3.1还要传1.3.0呢?因为1.3.0的包里有文档和API,呵呵。
spring持久层,建立持久数据库,spring-jdbc(jdbctemplate)所需jar包 spring持久层,建立持久数据库,spring-jdbc(jdbctemplate)所需jar包
主要介绍了Java 使用JdbcTemplate 中的queryForList发生错误解决办法的相关资料,需要的朋友可以参考下
有commons-logging-1.2.jar、spring-beans-5.1.10.RELEASE.jar、spring-core-5.1.10.RELEASE.jar\、spring-jdbc-5.1.10.RELEASE.jar、spring-tx-5.1.10.RELEASE.jar
spring JdbcTemplate所需要的相关jar包:spring-jdbc-4.0.0.jar
保存jdbcTemplate的一些jar包,其中包含commons-logging-1.2.jar、spring-beans-5.0.0.RELEASE.jar、spring-core-5.0.0.RELEASE.jar、spring-jdbc-5.0.0.RELEASE.jar、spring-tx-5.0.0.RELEASE.jar
spring-jdbcTemplate实例工程
spring提供了一个工具类JdbcTemplate,在类...JdbcTemplate: Spring 框架中提供一个ORM技术,对JDBC进行了封装 类似于我们之前的mybatis框架,对数据库做增删改查操作的 学习目标:了解该技术的使用、掌握单表的增删改查
spring boot demo 是一个用来深度学习并实战 spring boot 的项目,该项目已成功集成 actuator(监控)、admin(可视化监控)、logback(日志)、aopLog(通过AOP记录web请求日志)、统一异常处理(json级别和页面级别)、...