Declarative transaction management

Now, let's see how we can implement Spring declarative transaction management.

Our Messages App is so simple that it works fine without transaction management. For demonstration purpose, let's add another requirement to the /messages (POST) API. Let's say we want to have a report to show the statistics of hourly posted messages. We can calculate the statistics using an SQL query. Or we can update the statistics after saving a message and save it into a table that will hold this information in the database. Let's go with the second approach so that we can use declarative transaction management.

In practice, if our Message App had traffic like Disqus (https://disqus.com), you would probably want to take a ...

Get Building Applications with Spring 5 and Vue.js 2 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.