我有以下代码
resultList = daoResources.jdbcTemplate.query(sql, selectParams, new BeanPropertyRowMapper(resultClass));
当针对数据库使用 selectParams 运行 SQL 时,我得到结果。 sql的选择字段名称也与resultClass中的字段匹配。但对于上面的代码,我得到一个空的 resultList。
问题可能出在哪里?
最佳答案
在这种情况下,调试是你的 friend 。我建议您启用 jdbc 模板的调试日志,以查看发送到数据库的 sql 和绑定(bind)参数。以下来自3.0.x reference doc
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).
关于java - spring jdbc 模板返回空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8515358/