© Anghel Leonard 2020
A. LeonardSpring Boot Persistence Best Practiceshttps://doi.org/10.1007/978-1-4842-5626-8_9

9. Monitoring

Anghel Leonard1 
(1)
Banesti, Romania
 

Item 81: Why and How to Count and Assert SQL Statements

Assuming that you have the Author entity mapped to the table, as shown in Figure 9-1, the goal is to atomically perform the following simple scenario:
  • Load an Author from the database

  • Update the genre of this Author

../images/487471_1_En_9_Chapter/487471_1_En_9_Fig1_HTML.jpg
Figure 9-1

The Author entity table

A simple service-method can implement this scenario, as follows:
@Service
public class BookstoreService {
    private final AuthorRepository authorRepository;
    ...
    public void updateAuthor() ...

Get Spring Boot Persistence Best Practices: Optimize Java Persistence Performance in Spring Boot Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.