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

javax.transaction.Transactional does nothing when using Spring Jdbc Template for database operations #651

Closed
3 of 4 tasks
runarhk opened this issue Jul 9, 2020 · 2 comments · Fixed by #775
Closed
3 of 4 tasks
Labels
status: awaiting validation Waiting to be validated as a real issue
Milestone

Comments

@runarhk
Copy link

runarhk commented Jul 9, 2020

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Use javax.transaction.Transactional annotation to mark transactional boundaries
  2. Use Spring jdbc template for persistence
  3. Notice how database changes are not rolled back in case of an error. Auto-commits each change.

Expected Behaviour

When an exception occurs, the database changes should be rolled back.

Actual Behaviour

Database changes persist

Environment Information

  • Operating System: Linux Mint 19.3 Cinnamon
  • Micronaut Version: 2.0.0
  • JDK Version: openjdk 11.0.7 2020-04-14

Example Application

https://github.com/runarhk/mn_transactions_issues

Run PersonManagerTest to verify it is not working as intended

@graemerocher graemerocher added the status: awaiting validation Waiting to be validated as a real issue label Jul 21, 2020
@graemerocher graemerocher added this to the 1.1.4 milestone Jul 21, 2020
@runarhk
Copy link
Author

runarhk commented Sep 4, 2020

@alejandropg
Copy link

alejandropg commented Oct 9, 2020

We have the same problem.

I see that when you use javax.transaction.Transactional the Micronaut Annotation processor do their job, so the proxy xxx$xxxDefinition is generated, but then in runtime the io.micronaut.transaction.interceptor.TransactionalInterceptor is never called. In fact the interceptor is not in the chain.

I suppose that the interceptor is not in the chain because with the annotation javax.transaction.Transactional they try to find the Micronaut transaction manager but, as @runarhk suggest, it doesn't exist in favor of Spring's one.

To me, the solution is doesn't mix Micronaut with Spring, and use the Micronaut's JdbcOperations instead of the Spring's JdbcTempalte. In fact micronaut-data-jdbc is much powerful and flexible than the Spring's raw JDBC support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting validation Waiting to be validated as a real issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants