You mentioned Bulk Update and Delete in the title of the question, but this time you really need to do batch processing.
Bulk updating and deletion are necessary if you want to update UPDATE / DELETE strings that meet the same filtering criteria that can be expressed in WHERE.
Here you need JDBC batch updates. As described in this article , you need to set the following configuration property:
<property name="hibernate.jdbc.batch_size" value="50"/>
If you do, you can just update the entities, and Hibernate will execute the UPDATE statements for you.
Option 1 is not very useful because it will generate N UPDATE statements that cannot be packaged.
Option 2 is not very useful either because it will generate a very complex query, whose execution plan is probably more complicated than doing everything in a simple batch UPDATE statement.
So do it like this:
- Retrieving objects using pagination
- Update them with Hibernate and give it a batch update for you.
If you have many of these objects, use pagination as described in this article .
source share