Using hibernate I have the following query
String PQ = "select k from Customer k inner join k.winterSet vs where vs.year = :year";
TypedQuery<Customer> tq = legacyEm.createQuery(PQ,Customer.class);
tq.setParameter("year", DateUtil.getCurrentWinterSeason());
List<Customer> result = tq.getResultList();
The mapping in Customer is
@OneToMany(fetch = FetchType.LAZY, mappedBy = "customer")
private Set<Winter> winterSet = new HashSet<>(0);
and in Winter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cnr")
private Customer customer;
When I run this query I get only rows from Customer that actually has a related row in Winter with the attribute year matching the given parameter. So far so good. However those Customer objects have their winterSet populated with all the related Winter objects, not only those with the desired value in the year attribute. How can I achieve that?