This question already has answers here:
JPA passing list to IN clause in named native query
                                
                                    (9个答案)
                                
                        
                                在27天前关闭。
            
                    
这是我的查询,我已经在存储库文件中编写过。

@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);

10-06 12:51