So I retrieved a List of objects directly from my database and wish to delete them. However, from the docs, it looks like I have to construct the entire SQL query in a string, and pass that string to the createQuery method in order to delete. Isn’t there a better way to do it?
List<Foo> confirm = (List<Foo>) criteria.list();
session.delete(confirm.get(0)); //Works for single object,
//what about batching?
Either you iterate over the entities and call delete for each of them, or you construct a delete query:
Make sure to understand the restrictions and caveats associated to such DML queries though. They’re described in the documentation.