queryForList返回的子集不正确,但在SQL Developer中执行就可以了
DAO 类中返回的子集:
List<Map<String, Object>> agreements = getJdbcTemplate().queryForList(sqlForDataQuery.toString(), paramsForList.toArray());
它期望被排序,但在调试模式下应用程序返回不正确的子集 - 它没有排序。
从另一方面来说,如果使用所有 paramsForList< 执行
sqlForDataQuery
/code> 在 Oracle Sql Developer 中,预期返回已排序的正确子集。
sqlForDataQuery
运行时值:
SELECT * FROM (SELECT t1.*, ROWNUM rn FROM (SELECT /*+ CHOOSE */ DISTINCT a.avtalenavn, a.kunde_id, a.aktivdato, a.bank_id, a.avtalestatus_id, a.produkt_id, a.avtale_id, p.navn, k.foretaksnr, k.navn AS KUNDENAVN FROM es.avtale a, es.avtale_konto ak, es.kunde k, es.produkt p WHERE a.bank_id = ? AND ak.avtale_id = a.avtale_id AND a.kunde_id = k.kunde_id AND UPPER(a.avtalenavn) LIKE UPPER(('%' || ? || '%')) AND a.produkt_id = p.produkt_id ORDER BY ? ) t1 ) WHERE rn BETWEEN ? AND ?
paramsForList
运行时值:
4210, a, AVTALE_ID, 1, 5
看起来查询执行不正确,但没有抛出异常。
您知道问题范围吗?
谢谢。
Subset returned in DAO class:
List<Map<String, Object>> agreements = getJdbcTemplate().queryForList(sqlForDataQuery.toString(), paramsForList.toArray());
It expected to be sorted,but in debug mode application returns incorrect subset - it's not sorted.
From other hand,if to execute sqlForDataQuery
with all paramsForList
in Oracle Sql Developer, that expected sorted correct subset returned.
sqlForDataQuery
runtime value:
SELECT * FROM (SELECT t1.*, ROWNUM rn FROM (SELECT /*+ CHOOSE */ DISTINCT a.avtalenavn, a.kunde_id, a.aktivdato, a.bank_id, a.avtalestatus_id, a.produkt_id, a.avtale_id, p.navn, k.foretaksnr, k.navn AS KUNDENAVN FROM es.avtale a, es.avtale_konto ak, es.kunde k, es.produkt p WHERE a.bank_id = ? AND ak.avtale_id = a.avtale_id AND a.kunde_id = k.kunde_id AND UPPER(a.avtalenavn) LIKE UPPER(('%' || ? || '%')) AND a.produkt_id = p.produkt_id ORDER BY ? ) t1 ) WHERE rn BETWEEN ? AND ?
paramsForList
runtime value:
4210, a, AVTALE_ID, 1, 5
Looks like query executed not correctly,but no Exception thrown.
Have you any idea of problem scope?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个
短篇故事:您不能使用参数作为在PreparedStatement 中进行排序的列,并且jdbcTemplate 在底层使用准备好的语句。
Take a look at this
Short story: you can't use parameters as columns for ordering in a PreparedStatement and jdbcTemplate uses prepared statements under the hood.