Issue with selecting max id rows using criteria query / hibernate query?
问题 I am unable to select the rows where TestId is max for respective student, I wrote the code as follows which does not get the required output. my code is as follows, Criteria c = sessionFactory.getCurrentSession().createCriteria(student.class).setProjection(Projections.projectionList().add(Projections.property("answer"),"answer")); c.add(Restrictions.eq("surveyId",send_Survey)); //c.add(Restrictions.eq("testId", "1" )); //c.setProjection(Projection.max("testId")); c.addOrder(Order.desc(