Spring Data JPA Implementing Bulk Updates

Pubblicato il: 16 dicembre 2021
sul canale di: Thorben Janssen
12,110
331

Join the Persistence Hub and become a Java Persistence Expert: https://thorben-janssen.com/join-pers...

When using Spring Data JPA, most developers are used to letting Spring handle almost all database operations. That’s especially the case for all update operations. Thanks to JPA’s entity mappings and the managed lifecycle of all entity objects, you only need to change an attribute of an entity object. Everything else happens automatically.

But having a good, automated solution for the most common use cases doesn’t mean it’s the ideal solution for all use cases. JPA’s and Spring Data JPA’s handling of update operations is a good example of that. The default handling is great if you only need to update a few entities. Your persistence provider automatically detects changes to all managed entity objects. For each changed object, it then executes an SQL UPDATE statement. Unfortunately, this is a very inefficient approach if you need to update a huge number of entities. It often causes the execution of several dozen or even hundreds of SQL UPDATE statements.

This is a general problem when using JPA. Still, especially users of Spring Data JPA are surprised when I tell them about this and show them that even a call of the saveAll method on their repository doesn’t avoid these statements.
But there are 2 easy-to-use options to reduce or avoid the performance impact entirely.


Like my channel? Subscribe!
➜ http://bit.ly/2cUsid8

Read the accompanying post: https://thorben-janssen.com/implement...

Want to connect with me?
Blog: https://thorben-janssen.com/
Twitter:   / thjanssen123  
Facebook:   / thorbenjanssenofficial  
Linkedin:   / thorbenjanssen  


In questa pagina del sito puoi guardare il video online Spring Data JPA Implementing Bulk Updates della durata di 16 minuti 40 seconda in buona qualità , che l'utente ha caricato Thorben Janssen 16 dicembre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 12,110 volte e gli è piaciuto 331 spettatori. Buona visione!