Originally posted by Samanth Marisetty:
try{
if(devicesQuery.getSingleResult()!= null){
result = (User) devicesQuery.getSingleResult();
}
}catch(javax.persistence.NoResultException nre){
}
As per the
Javadocs of this API:
Execute a SELECT query that returns a single result.
Returns:
the result
Throws:
NoResultException - if there is no result
NonUniqueResultException - if more than one result
IllegalStateException - if called for a Java Persistence query language UPDATE or DELETE statement
So why dont you try the other getResultList() API by setting the maxResults to 1 as follows: