0

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.

Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
Poorna Senani Gamage
  • 1,246
  • 2
  • 19
  • 30

2 Answers2

1

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"})));
Poorna Senani Gamage
  • 1,246
  • 2
  • 19
  • 30
1

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"));
Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80