For example, I have the Service
entity:
@OneToMany(fetch = FetchType.EAGER, mappedBy = "service")
public List<ServiceStatus> getServiceStatuses() {
return serviceStatuses;
}
and the ServiceStatus
entity:
@ManyToOne
@JoinColumn(name = "service", nullable = false)
public Service getService() {
return service;
}
@Column(name = "date", nullable = false)
@Temporal(TemporalType.DATE)
public Date getDate() {
return date;
}
Now I need to query all the Service
objects so that each of it has only those ServiceStatus
objects where ServiceStatus.date
is between date1
and date2
. That is, if there are 10 ServiceStatus
objects with the proper date, the serviceStatuses
list will have only those 10 objects and nothing more. Is it possible?
Thanks in advance.