本机查询未获取任何结果
下面的 JPA Native 查询始终返回“0”(无结果),但是我们在数据库中有此条件的记录。
有人可以告诉我们我们在这里做错了什么吗?
List<Integer> intArrayList = new ArrayList<>();
intArrayList.add(10);
intArrayList.add(20);
String col3Vals = "'test1','test2'";
Query qry = entityMgr.createNativeQuery("select count(*) from mytable where col1 = ?1 and col2 in ?2 and col3 in (?3)")
.setParameter(1, "testVal")
.setParameter(2, intArrayList);
.setParameter(3, col3Vals);
List<?> res = qry.getResultList();
提前致谢!
The below JPA Native query always returns '0' (no results), however we have records for this condition in the DB.
Can someone please advise what we are doing wrong here?
List<Integer> intArrayList = new ArrayList<>();
intArrayList.add(10);
intArrayList.add(20);
String col3Vals = "'test1','test2'";
Query qry = entityMgr.createNativeQuery("select count(*) from mytable where col1 = ?1 and col2 in ?2 and col3 in (?3)")
.setParameter(1, "testVal")
.setParameter(2, intArrayList);
.setParameter(3, col3Vals);
List<?> res = qry.getResultList();
Thanks in Advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改如下代码解决了该问题,问题在于我们如何填充“IN”子句之一中的“col3”列的字符串值。
Changing the code like below resolved the issue, the issue was with the way how we populated the String values for column 'col3' that we had in one of the 'IN' clauses.