Hello Hibernate Experts,
i would very much appreciate your help in transforming the following SQL statement to a valid HQL Statement. I tried for hours but was not successfull:
SELECT * FROM master as m left outer join (select * from child as c where c.id = (select max(d.id) from child as d where d.MasterFk = c.MasterFk) )as b ON m.id = b.MasterFk;
public class Master {
private Long id;
private Collection childs;
...
}
public Class Child {
private Long id;
private Master master;
}
In the Hibernate Mapping File I map the Master to the Child via a Standard SET (-Mapping) and the relation back from Child to Master is a Many-To-One Association. (This is working.)
==> The objective is to Query the Master with only the latest Child Record (=Only ONE Record!) correctly initialized as the only element in the SET of childs...
Whatever I tried, I failed miserably.
Thank you very much!