Generation query when the ManyToMany relationship is used by Spring Data Jpa project

青春壹個敷衍的年華 提交于 2019-12-04 08:02:02

Since parameter names are lost in bytecode, you need to use @Param annotation to indicate the parameter that is mapped as the :category variable in your JPQL. So, you code would look like:

@Query("SELECT b FROM Book b INNER JOIN b.categories c WHERE c IN (:categories)")
List<Book> findByCategories(@Param("categories") Collection<Category> categories);

?1 certainly works, but is probably not as readable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!