When you don't know whether there are any results, use getResultList()
.
List<User> foundUsers = (List<User>) query.getResultList();
if (foundUsers == null || foundUsers.isEmpty()) {
return false;
}
User foundUser = foundUsers.get(0);