java - 如何在java中的存储库文件中的 native sql查询中传递参数?

标签 java sql hibernate orm repository

这是我的查询,我已写入存储库文件中。

@Query(value = "select * from A a join B b ON a.allocateBy = b.empNo join D d ON b.departmentName = d.departmentName where a.allocateBy in (:allocateByList)",  nativeQuery = true)

ArrayList<A> findAllByAllocateByIn(@Param("allocateByList") String allocateByList);

没有错误,但 :allocateByList 未获取数据。我之前已经打印了 allocateByList 的值。它有数据。

我错过了什么吗?

最佳答案

将 allocateByList 更改为列表并使用以下查询

@Query(value = "select * from A a join B b ON a.allocateBy = b.empNo join D d ON b.departmentName = d.departmentName where a.allocateBy in ?1",  nativeQuery = true);

ArrayList<PointAllocation> findAllByAllocateByIn(List<String> allocateByList);

关于java - 如何在java中的存储库文件中的 native sql查询中传递参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60275336/

相关文章:

php - 如何从两个表中查询第三个表的条件

hibernate - 为什么 Hibernate 不设置 child 对 parent 的引用?

java - 增强的 for 循环 - JAVA

java - 如何对 JFreeChart 中的图例进行排序?

mysql - MySQL 中何时使用单引号、双引号和反引号

java - 在 JPA 查询上设置 ORDER BY 和 LIMIT 子句

java - 由 : java. io.FileNotFoundException : Could not open ServletContext resource [/applicationContext. xml 引起]

java - 使用Spring依赖注入(inject)时如何模拟在其他方法中调用的方法?

java - Android 上常见的性能缺陷?

sql - 如果列为空,则 INNER JOIN