0

I have two classes Student and Class in @ManyToMany relationship. I would like to select all classes in which student (id = 1) is not. How can I do it?

Amsik
  • 698
  • 2
  • 6
  • 26

1 Answers1

0

You will have to user MEMBER OF and equivalent in Critera API. Here you have some details http://www.objectdb.com/java/jpa/query/jpql/collection.

In your case it will be something like

cb.isMemberOf(student,c.get("students"));

where student is Student entity, and c is query root - Class.

Antoniossss
  • 31,590
  • 6
  • 57
  • 99