Transactions, Spring.
Spring uses a tiny trick. It doesn’t just instantiate the EntityService but it also creates a transactional proxy of the same bean: As we can see from the above diagram, the proxy has two jobs: Opening and closing database connections/transactions. And then delegating to the original EntityService.