我試圖避免與傳遞第二個參數法列表大小的冗餘。相反,我使用EL,但我有一個錯誤:爲什麼規劃環境地政司的支持並不在Spring數據JPA @Query工作?
org.hibernate.QueryException: Not all named parameters have been set: [$synthetic$__1] [SELECT distinct b FROM Book b join b.bookHashtags as ht where ht.hashtagName in :tags group by b.uniqueIdentifier having count(ht.uniqueIdentifier) = :$synthetic$__1]
@Repository
public interface BookRepository extends JpaRepository<Book, Long>, JpaSpecificationExecutor<Book> {
@Query("SELECT distinct b FROM Book b join b.bookHashtags as ht where ht.hashtagName in :tags " +
"group by b.uniqueIdentifier having count(ht.uniqueIdentifier) = :#{#tags.size()}")
List<Book> findAllBooksContainedTags(@Param("tags") Set<String> tags);
}
我用彈簧數據的JPA 1.11.0.RELEASE。我知道,這個功能是在1.4版本開發。爲什麼它不會在我的情況下工作...