I want to delete from a table some entries with specific ids. I want to know the syntax of this request
delete from table where id in list_of_ids
in hql.
Assuming the id of your table is of type Long, the correct way to perform the delete is as follows:
List<Long> ids = new ArrayList<Long>();
ids.add(1L);
ids.add(2L);
Query q = session.createQuery("DELETE FROM YourEntityName ye WHERE ye.id IN (:list)");
q.setParameterList("list", ids);
q.executeUpdate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With