I have a simple class, called Person, as follows:
public class Person {
private Integer id;
private String name;
private List<PersonState> states;
...
}
And each PersonState is defined like:
public class PersonState {
private Integer id;
private State state;
private Date date;
...
}
And State is a simple class, containing only an id and name, and I have all the mapping files configured and working.
I want to get those Persons whose last PersonState (based on it’s date) has an State with id = 5 (for instance), so what would be the HQL query like?
Thanks!
Something like this: