HibernateTemplate.bulkUpdate deprecated but no replacement provided #22271
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: invalid
An issue that we don't feel is valid
I have noticed that during upgrade from Spring 4.3 to 5.1 HibernateTemplate.bulkUpdate has been deprecated
Source: https://docs.spring.io/spring-framework/docs/current/javadoc-api/deprecated-list.html
Source: https://github.com/spring-projects/spring-framework/blob/master/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java#L1058
In the docs, it is not specified how to properly replace the handy
bulkUpdate
method.Request here is to document how should one replace the deprecated bulkUpdate method in his/her code.
Comment:
I also have read #20972 but fail to understand why can lambdas be more elegant than a handy dirty method.
In my case, I am writing unit tests and I want a quick and not-too-dirty-but-dirty-is-acceptable way to clear the database or do bulk operations.
In the past, I used
new HibernateTemplate(sessionFactory).bulkUpdate("delete from Entity");
Now I have to use
new HibernateTemplate(sessionFactory).execute(session->session.createQuery("delete from Entity").executeUpdate());
In my personal opinion, the second doesn't look so better than the first. And yes, bulkUpdate runs a lambda internally.
The text was updated successfully, but these errors were encountered: