-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Update the reference documentation with limitation related to @Bean
return type
#29944
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
Comments
I understand it could be surprising, but the behavior you observe is expected because the type exposed but the If you change the return type to I will update the reference documentation to mention that limitation. |
@Bean
return type
Hello, thanks for a quick reply. This is just an example the issue is actually in a framework that I am maintaining and uses autoconfiguration to register default implementations. I am injecting interfaces to allow users to override default behaviour by providing another implementation. I've tried to annotate the interface with
And if I register hints for DefaultDemoEntityService$$SpringCGLIB$$0 transaction is not started. For me it seems that Springs default registration of |
@Bean
return type@Transactional
doesn't seem to work in native run on beans registered in @Configuration
classes
Indeed I can reproduce, I will have a deeper look. |
Ok, thanks. |
You can make it work by moving the |
@Transactional
doesn't seem to work in native run on beans registered in @Configuration
classes@Bean
return type
It seems that the "type: bug" label can be dropped as there's no bug fix here. |
Done and I have updated the release notes accordingly. |
Affects: 6.0.4
When class annotated with
@Transactional
annotation is registered in@Configuration
class no actual transaction is started when calling methods while running in native image. When the same class is registered with@Service
annotation everything works as expected. Both cases work fine in standard (non-native) run. This used to work in experimental version of spring-native but required manual registration of@Transactional
beans.Provided example uses Spring Boot 3.0.2 for ease of configuration and when run in native mode the following exception occurs:
jakarta.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'merge' call
The class implements an interface and the interface is injected in CommandLineRunner and a method is called to save the entity.
spring-transactional-issue.zip
The text was updated successfully, but these errors were encountered: