我有以下麻烦。
有一个实体 Distributor 与实体城镇的多对多关系相关联:
@Entity
public class Distributor{
@ManyToMany
@JoinTable( name = "GS_DISTRIBUTOR_TOWN",
joinColumns = @JoinColumn(name = "CD_DISTRIBUTOR"),
inverseJoinColumns = @JoinColumn(name = "CD_TOWN") )
private List<Town> towns;
....
}
那么实体镇也和District有关系
@Entity
public class Town{
@ManyToMany(mappedBy="towns")
private List<Distributor> distributors;
@ManyToOne
private District district;
....
}
现在我必须过滤(使用 jpql)在一个地区的所有经销商。我能怎么做?