I know this late, but if anyone has a similar problem, you can use this:
Criteria criteria = session.createCriteria(Student.class); criteria.add(Restrictions.ne("year", year)); List<Student> result = criteria.list();
Or that:
List<Student> result = session.createQuery ("from Student where year!=:year").setParameter("year", year).list();
I'm not sure the problem is in the above example, since Samantha did not provide any information that it was never like this, but I assume that uniqueResult() is causing problems because this query returns a list, not a single result.
source share