I want to remove completed orders from a list

41 Views Asked by At

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.

2

There are 2 best solutions below

0
Roshana Pitigala On BEST ANSWER

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"));
0
Poorna Senani Gamage On

According to the error it take a argument of list or collections. so it must be

c.add(Restrictions.not(Restrictions.in("status",new String[] {"Completed"})));