In Spring Intreface I have following code:
@Query("select gl from GroupEntity gl where ?1 in gl.contacts ")
List<GroupEntity> findGroupsByContact(ContactEntity contactEntity);
and want to find all Group with contains a Contact, but IntelliJ idea shows error after where condition ( ?1 in gl.contacts) and shows this error:
'(' or <input parameter> expected, got 'gl'
what is the solution?
related parts of Entities are:
@Entity
@Table(name = "contactGroup")
public class GroupEntity {
...
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<ContactEntity> contacts;
...
}
but in ContactEntity did not use @ManyToMany for GroupEntity(Is it the root of the problem?)
@Entity
@Table(name = "contact")
public class ContactEntity {
...
}