Spring Data JPA Implementing Bulk Updates

  Рет қаралды 10,370

Thorben Janssen

Thorben Janssen

2 жыл бұрын

Join the Persistence Hub and become a Java Persistence Expert: 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!
➜ bit.ly/2cUsid8
Read the accompanying post: thorben-janssen.com/implement...
Want to connect with me?
Blog: thorben-janssen.com/
Twitter: / thjanssen123
Facebook: / thorbenjanssenofficial
Linkedin: / thorbenjanssen

Пікірлер: 10
@Ash-ku2rz
@Ash-ku2rz 2 жыл бұрын
Your courses are just so structured, I am enjoying them.
@michaelfagundes4639
@michaelfagundes4639 2 жыл бұрын
very good, thank you, hugs from Brazil
@dskuhi12345xyz
@dskuhi12345xyz 2 жыл бұрын
Perfect mate!
@Andjoel1
@Andjoel1 2 жыл бұрын
Great video! one question tho, you mentioned is better to create our own update query than activating jdbc batching, why is that? thank you and keep up the good work!
@asashish905
@asashish905 Жыл бұрын
So can I implement this batching when a saveAll() is used to insert a large number of entities and it leads to broken pipe error during inserting in postgres DB?
@shiwendrasingh9854
@shiwendrasingh9854 Жыл бұрын
How to reduce the timing of a find jpa query for entities having joins ?
@stefanolazzari3218
@stefanolazzari3218 2 жыл бұрын
Why cant just i like it twice?? Thanks a lot
@petroniobonavides3530
@petroniobonavides3530 2 жыл бұрын
Wonderful, I was needing this exactly lecture fro my project. But... Why dont you talk about Mongo?
@eversons5659
@eversons5659 2 жыл бұрын
i guess his focus is jpa/hibernate
@hangofox1720
@hangofox1720 Жыл бұрын
Good night. I have an Oracle database with a table with 4 Clob-type fields. The CRUD (Read, Modify and Delete) works correctly except for the create shows me the following error when I use Postman. How is the correct syntax in Spring to insert clob type data without showing me the following error: 023-06-13 19:21:15.353 ERROR 6556 --- [nio-8084-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause oracle.jdbc.OracleDatabaseException: ORA-00932: tipos de dato inconsistentes: se esperaba - se ha obtenido CLOB
5 Hibernate Features You Should Use With Spring Data JPA
11:21
Thorben Janssen
Рет қаралды 5 М.
How to call native SQL queries with JPA and Hibernate
13:46
Thorben Janssen
Рет қаралды 4,3 М.
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 55 МЛН
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 15 МЛН
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 1,5 МЛН
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 37 МЛН
JPA & Hibernate: Basic Annotations You Need To Know
15:11
Thorben Janssen
Рет қаралды 30 М.
Getting Started with Flyway & Version-Based Migration
11:44
Thorben Janssen
Рет қаралды 61 М.
JDBC vs JPA: Pros and Cons
11:56
Pro Coder
Рет қаралды 30 М.
Modern Persistence with Spring Data 3
30:07
SpringDeveloper
Рет қаралды 7 М.
Spring Data JPA: Query Projections
10:10
Thorben Janssen
Рет қаралды 18 М.
The Best Mapping for Shared Technical Attributes With Hibernate
9:07
Thorben Janssen
Рет қаралды 1,6 М.
JPA & Hibernate: Entity Lifecycle Model
6:41
Thorben Janssen
Рет қаралды 13 М.
КРАХ WINDOWS 19 ИЮЛЯ 2024 | ОБЪЯСНЯЕМ
10:04
Опасность фирменной зарядки Apple
0:57
SuperCrastan
Рет қаралды 12 МЛН