You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: HibernateSpringBootBatchInsertsEntityManager/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@
3
3
4
4
**Description:** Batch inserts via `EntityManager` in MySQL. This way you can easily control the `flush()` and `clear()` of the Persistence Context (1st Level Cache). This is not possible via SpringBoot, `saveAll(Iterable<S> entities)`. Another advantage is that you can call `persist()` instead of `merge()` - this is used behind the scene by the SpringBoot `saveAll(Iterable<S> entities)` and `save(S entity)`.
5
5
6
+
If you want to execute a batch per transaction (to avoid long-running transaction and lose all batches in case of failure) then check this [example](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootBatchInsertsEntityManagerBatchPerTransaction).
7
+
6
8
**Key points:**
7
9
- in `application.properties` set `spring.jpa.properties.hibernate.jdbc.batch_size`
8
10
- in `application.properties` set `spring.jpa.properties.hibernate.generate_statistics` (just to check that batching is working)
0 commit comments