You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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
Hello, according to the documentation, to allow package-private or protected methods to benefit from
@Transactional
we have to register customtransactionAttributeSource
. Previous statement based on Method visibility and@Transactional
in https://docs.spring.io/spring-framework/reference/data-access/transaction/declarative/annotations.htmlI 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 #25582The 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.
The text was updated successfully, but these errors were encountered: