这是我的查询,我已写入存储库文件中。
@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/