Modified query to avoid using query.getSingleResult()