Entitymanager merge not updating record dating ru kovtunenko boris
You would also use a single database transaction to serve the clients request.
Once the work has been completed (and the response for the client has been prepared), the persistence context is flushed and closed, as well as the entity manager object.
This is of course an anti-pattern, a pessimistic approach, since lock contention would not allow the application to scale with the number of concurrent users.
Clearly, we have to use several database transactions to implement the application transaction.
Of course, the same is true for database transactions.
Database calls in an application are made using a planned sequence, they are grouped into atomic units of work.