0

I have a query to get the maximum id of a table Eg:Country. Is there any efficient way to get a singleResultObject? There is the possibility to get an Exception while getting a singleResultObject.

Query q = em.createQuery("SELECT MAX(c.countryId) FROM Country c ");

try   
{
   Integer countryId = (Integer) q.getSingleResult();    
}   
catch (Exception e)   
{
   logger.error("Exception " + e);       
}
BDL
  • 21,052
  • 22
  • 49
  • 55
muthukumar
  • 2,233
  • 3
  • 23
  • 30

0 Answers0