Can I use Criteria to delete records from my tables?
For example,
Criteria toDelete = session.createCriteria(Car.class, "car").createAlias("car.wheel", "wheel");
toDelete.add(Restrictions.eq("brand", "Toyota"));
toDelete.add(Restrictions.eq("wheel.brand", "BBS");
toDelete.add(Restrictions.gt("date_of_purchase", someDay);
toDelete.add(Restrictions.between("cost", 3000, 5000);
How can I use toDelete criteria to delete the records that I am interested in? An inefficient way would be to query for the ids using the toDelete criteria, then delete Car objects from there. Also, can I know how many objects have I deleted?