Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Transactional on package-private/protected methods for class-based proxies #31057

Closed
lukozog opened this issue Aug 16, 2023 · 0 comments
Closed
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: documentation A documentation task
Milestone

Comments

@lukozog
Copy link

lukozog commented Aug 16, 2023

Hello, according to the documentation, to allow package-private or protected methods to benefit from @Transactional we have to register custom transactionAttributeSource. Previous statement based on Method visibility and @Transactional in https://docs.spring.io/spring-framework/reference/data-access/transaction/declarative/annotations.html

I found that for class-based proxies I can add @Transational over package-private or protected methods without any additional action or registering specific @Bean mentioned in the documentation. Observation while using Spring Framework version 6.0.8. I assume that it may work by default from version 6.0 M1 according to #25582

The issue is created to encourage change in documentation. Currently, whatever article we may find about @Transactional, or a tool like SonarLint, each says it's necessary to have a public method to use it. It seems to me that most of them are no longer current 😸 If we have in documentation something more precise, like mentioning that for class-based proxies it's just ok to use @Transactional above package-private or protected method, but for interface-based not, it would be much more clear to understand and use. It would allow to increase the encapsulation in the projects.

Thanks.

@lukozog lukozog changed the title @Transactional on package-private/protected methods for class-based proxies @Transactional to package-private/protected methods for class-based proxies Aug 16, 2023
@lukozog lukozog changed the title @Transactional to package-private/protected methods for class-based proxies @Transactional on package-private/protected methods for class-based proxies Aug 16, 2023
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 16, 2023
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 16, 2023
@jhoeller jhoeller self-assigned this Aug 16, 2023
@jhoeller jhoeller added this to the 6.0.12 milestone Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants