Using Hibernate\'s Criteria API, I want to select the record within a table with the maximum value for a given column.
I tried to use Projections, creating an alias
The cleaner solution would also be :
DetachedCriteria criteria = DetachedCriteria.forClass(Foo.class).setProjection(Projections.max("id")); Foo fooObj =(Foo) criteria.getExecutableCriteria(getCurrentSession()).list().get(0);