6
Ho il problema seguito.Query molti-a-molti jpql
V'è un distributore soggetto che è collegato con il rapporto ManyToMany in città entità:
@Entity
public class Distributor{
@ManyToMany
@JoinTable(name = "GS_DISTRIBUTOR_TOWN",
joinColumns = @JoinColumn(name = "CD_DISTRIBUTOR"),
inverseJoinColumns = @JoinColumn(name = "CD_TOWN"))
private List<Town> towns;
....
}
Poi la città entità è anche in relazione con il Distretto
@Entity
public class Town{
@ManyToMany(mappedBy="towns")
private List<Distributor> distributors;
@ManyToOne
private District district;
....
}
Ora devo filtrare (con jpql) tutti i distributori che si trovano in un distretto. Come posso fare?