Skip to content

Commit 0c502e5

Browse files
Best way to use @transactional
1 parent 5c6af52 commit 0c502e5

File tree

1 file changed

+3
-5
lines changed
  • HibernateSpringBootTransactionalInRepository

1 file changed

+3
-5
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
**[Avoid Spring Redundant `save()` Call](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootRedundantSave)**
1+
**[Best Way To Use `@Transactional`](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootTransactionalInRepository)**
22

3-
**Description:** This application is an example when calling `save()` for an entity is redundant (not necessary).
3+
**Description:** This application is meant to highlight that the best place to use `@Transactional` for user defined query-methods is in repository interface, and afterwards, depending on situation, on service-methods level.
44

55
**Key points:**
6-
- at flush time, Hibernate relies on *dirty checking* mechanism to determine the potential modifications in entities
7-
- for each modification, Hibernate automatically triggers the corresponding `UPDATE` statement without the need to explicitly call the `save()` method
8-
- behind the scene, this redundancy (calling `save()` when is not necessarily) doesn't affect the number of triggered queries, but it implies a performance penalty in the underlying Hibernate processes
6+
- this application is dissected in my book, **Spring Boot Persistence Best Practices**.
97

108
<a href="https://leanpub.com/java-persistence-performance-illustrated-guide"><p align="center"><img src="https://github.com/AnghelLeonard/Hibernate-SpringBoot/blob/master/Java%20Persistence%20Performance%20Illustrated%20Guide.jpg" height="410" width="350"/></p></a>

0 commit comments

Comments
 (0)