mardi 1 septembre 2020

How Spring uses proxy design pattern behind the scenes for @Transactional? [duplicate]

I'm learning about @Transactional in Spring Boot projects and I know that @Transactional uses proxy design pattern behind the scene. And I try to understand how. I know that a proxy is a service called by the client, that do some work (access control, caching, etc) and after that the request is send to other service. Can somebody explain me how @Transactional uses proxy design pattern in the background? Any feedback will be apreciated.

@Service
public class BookManager {
    
    @Autowired
    private BookRepository repository;
 
    @Transactional
    public Book create(String author) {
        System.out.println(repository.getClass().getName());
        return repository.create(author);
    }
}

Aucun commentaire:

Enregistrer un commentaire