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
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() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.