Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the count of deleted entities

I use the following method to delete a set of objects based on a certain where condition, but in reality the number of removed objects could be lesser than the passed collection. How do I get the actual count of deleted entities

http://docs.spring.io/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/HibernateTemplate.html#deleteAll(java.util.Collection)

like image 980
SST Avatar asked Jul 08 '14 07:07

SST


1 Answers

You can build a query based on primary keys DELETE FROM ... WHERE id IN (1, 2, 3) or something similar and then use executeUpdate() method which returns the number of affected rows.

like image 134
Laurynas Tretjakovas Avatar answered Sep 21 '22 23:09

Laurynas Tretjakovas