简体   繁体   English

spring jdbc模板返回空结果

[英]spring jdbc template returns an empty result

I have the following code 我有以下代码

resultList = daoResources.jdbcTemplate.query(sql, selectParams, new BeanPropertyRowMapper(resultClass));

SQL when run with the selectParams against database, I get result. 当对数据库使用selectParams运行SQL时,得到结果。 The selecting fields name of the sql matches with the fields in the resultClass too. sql的选择字段名称也与resultClass中的字段匹配。 But for above code, I get an empty resultList. 但是对于上面的代码,我得到了一个空的resultList。

Where could be the problem? 问题可能出在哪里?

Debugging is your friend in this scenario. 在这种情况下,调试是您的朋友。 I suggest you enable debug logs for jdbc template to see what sql's and bind parameters are sent to database. 我建议您为jdbc模板启用调试日志,以查看将哪些sql和bind参数发送到数据库。 Below is from the 3.0.x reference doc 下面是来自3.0.x参考文档

All SQL issued by this class is logged at the DEBUG level under the category corresponding to the fully qualified class name of the template instance (typically JdbcTemplate, but it may be different if you are using a custom subclass of the JdbcTemplate class). 此类发出的所有SQL都在DEBUG级别下记录,该类别对应于模板实例的完全合格的类名称(通常为JdbcTemplate,但如果使用JdbcTemplate类的自定义子类,则可能有所不同)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM