javahibernatehibernate-criteriahibernate-sessionhibernate-restrictions

I want to remove completed orders from a list


In my App I have List of Orders. I want to remove completed orders from that list. that means the status = Completed.There are more two status. so I try this.

Session s = HibernateSession.getSession();
Criteria c = HibernateSession.createCriteria(s, Orders.class);
c.add(Restrictions.not(
Restrictions.in("status","Completed")));  //compile error...
List<Orders> orders = c.list();

But above line I got Compile error.


Solution

  • It would be much easier to add .ne()

    Apply a "not equal" constraint to the named property
    ~Java doc~


    c.add(Restrictions.ne("status", "Completed"));