Question

Simple question JPA / JPQL. J'ai une entité avec une relation ManyToMany:

@Entity
public class Employee {      
  @ManyToMany
  @JoinTablename="employee_project"
      joinColumns={@JoinColumn(name="employee_id"}
      inverseJoinColumns={@JoinColumn(name="project_id"})
  private List<Project> projects;

Quelle est la requête JPQL pour renvoyer tous les employés qui n'ont des projets?

Était-ce utile?

La solution

from Employee e where not exists elements(e.projects)

ou

from Employee e where size(e.projects) = 0

Autres conseils

JQPL n'ont consacré opérateur de comparaison de IS [NOT] EMPTY pour la vérification est collection vide:

SELECT e FROM Employee e WHERE e.projects IS EMPTY
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top