Joh*_*nny 3 java spring jpa spring-data spring-data-jpa
我有一个实体类A,它有一组具有ManyToMany关系的B类实体(超出范围我为什么需要这个)
class A {
@ManyToMany(cascade = CascadeType.ALL)
Set<B> setOfB;
}
Run Code Online (Sandbox Code Playgroud)
现在,给定一个B类的对象,我如何检索A类的对象,其中包含B对象?
我已经在我的类A库中尝试过:
interface Arepository extends JpaRepository<A, Long> {
@Query("from A a where ?1 in a.setOfB")
List<A> findByB(B b)
}
Run Code Online (Sandbox Code Playgroud)
但它给了我一个SQLGrammarException,所以这是正确的语法?
谢谢您的帮助.
| 归档时间: |
|
| 查看次数: |
5639 次 |
| 最近记录: |