简体   繁体   中英

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.

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"})));

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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM