I have an entity class A which has a Set of entities of class B with a ManyToMany relationship (out of scope why I need this)
class A {
@ManyToMany(cascade = CascadeType.ALL)
Set<B> setOfB;
}
Now, given an object of class B, how can I retrieve the object(s) of class A which has the B object in its Set??
I have tried in my class A repository with this:
interface Arepository extends JpaRepository<A, Long> {
@Query("from A a where ?1 in a.setOfB")
List<A> findByB(B b)
}
But it gives me a SQLGrammarException, so which is the correct syntax?
Thank you for your help.
Aucun commentaire:
Enregistrer un commentaire