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);
}