I have a hibernate object heirarchy in a table named "entry". All entries have a dateCreated field. I would like to select entries based on several parameters, one of which is that the entry should be the most recent of those that match the rest of the parameters.
The best I've been able to do is get a dateCreated-ordered list of the entries like this:
session.find("from Score as score where score.gradeRecord = ? order by score.dateCreated desc", gradeRecord, Hibernate.entity(GradeRecord.class));
and return the first member of the list. This is an inefficient solution, and I'm looking for a better one. Any ideas?
Thanks!
Josh
|