Skip to content

Update the reference documentation with limitation related to @Bean return type #29944

@agrancaric

Description

@agrancaric

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

Metadata

Metadata

Assignees

Labels

theme: aotAn issue related to Ahead-of-time processingtype: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions