I am unable to get max id from table. How can we get max id. My query is as follows,
Criteria tot = sessionFactory.getCurrentSession().createCriteria(student.class);
tot.add(Restrictions.eq("surveyId",send_Survey));
tot.add(Restrictions.eq("testId", "2" )); // Instead of hard coding as 2 I need to the maximum testId
//tot.addOrder(Order.desc("testId"));
ScrollableResults sc=tot.scroll();
sc.last();
int rowcount=sc.getRowNumber()+1;
System.out.println(" Here is the total count--- "+ rowcount);
How can I make a condition in query as maximum testId