-
Notifications
You must be signed in to change notification settings - Fork 42
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
Outdated documentation for JDBC Transaction management #558
Comments
It looks like the annotation processor isn't generating the |
so Spring is no longer needed for transaction management so this documentation is indeed out of date. If you do want Spring transaction management I believe you need to add |
Thanks, I'd be more than happy to use Miconaut's transaction management and remove Spring. Is there a particular annotation/dependency required to use Micronaut transactions for a plain JDBC project? I can only see Spring-based docs in the Today I was able to get Spring transactions working in a v2->v3 project migration so it's no longer urgent for me. |
I'm guessing this is pretty straightforward to answer and close this issue. I'm wondering the same thing.
@graemerocher I keep seeing similar comments about what to do if you want to use |
@matt-snider This PR seems to address this issue #557 |
@graemerocher But again, that shows how to set up transactions with Spring. Is it not possible without? |
If you don't want to use Spring then just add |
@graemerocher Thanks so much. Both of those examples are for
|
@burtbeckwith could you add some docs on using Micronaut SQL with Micronaut TX without Micronaut Data to address this issue. |
@graemerocher @burtbeckwith Very much appreciated 🙏 |
Some of these problems were reported in issue #555, in which case I sent an MR with the correction of part of the mentioned problems. |
@burtbeckwith Do you have any guidance here? Haven't found a way to get |
Okay I've been struggling with this one for awhile and it turns out the
So obviously I'm doing something wrong here because the Transactions Guide doesn't mention anything about all methods requiring the annotation (that wouldn't make sense?), In fact it even says:
You can see the |
I was able to get transactions working without Spring by adding the dependencies This issue was about outdated docs, so I hope I didn't derail the discussion too much. Still I wonder if the documentation should be improved here. There is a main section under JDBC about how to use Spring Transactions, but no such section about how to add Micronaut Transactions. Unless there is some reason |
For me, personally, it was also confusing the first time, because we don't use |
I just ran into this again because I was trying to get JOOQ set up properly such that I have the I think what I will try is to remove Spring Transaction management and switch to Micronaut and then implement my own JOOQ exception handler. I think the documentation would be more clear with a subsection in JOOQ explaining how to set up Transaction management for each scenario (with Spring, without Spring) as well as how to get the |
This documentation is definitely missing. I'm currently trying to read through some tests that use transactions in this project; if the transactions work in the test, then the build.gradle must sufficiently add the right dependencies for transactions to work. |
Looks like, at minimum, you need to add:
So, for Kotlin, assuming hikari: dependencies {
kapt("io.micronaut.data:micronaut-data-processor")
implementation("io.micronaut.data:micronaut-data-tx")
implementation("io.micronaut.data:micronaut-data-tx-jdbc")
implementation("io.micronaut.sql:micronaut-jdbi")
runtimeOnly("io.micronaut.sql:micronaut-jdbc-hikari")
} In short, you must include some Micronaut Data dependencies to get transaction management working in Micronaut SQL if you're not using Micronaut Spring. |
Oh interesting! So Spring support was recently removed: |
The documentation is still out of date. Regrettably, it looks like Micronaut 4 has made the docs even more out of date - my instructions are no longer accurate. Can we have someone with a bit more Micronaut SQL expertise provide some direction on how to properly use transactions when not using Micronaut Data, assuming that's still supported? |
Here's the new dependency that's now needed: implementation("io.micronaut.data:micronaut-data-tx-jdbc") |
Expected Behavior
Create a new project using https://launch.micronaut.io. Default settings, but with
jdbc-hikari
added:Follow https://micronaut-projects.github.io/micronaut-sql/latest/guide/#jdbc to get transactions working.
Actual Behaviour
The docs are outdated around the "Using Spring Transaction Management" section.
Issue 1
Gradle is unable to resolve
implementation("io.micronaut:micronaut-spring")
. I changed this toimplementation("io.micronaut.spring:micronaut-spring-annotation")
, but not sure if this is correct as I don't have access to any variant of@Transactional
.Issue 2
The
runtime
scope has been removed from Gradle, soruntime("org.springframework:spring-jdbc")
becomesruntimeOnly("org.springframework:spring-jdbc")
.Changing
runtimeOnly("org.springframework:spring-jdbc")
toimplementation("org.springframework:spring-jdbc")
placesorg.springframework.transaction.annotation.Transactional
onto my compile-time classpath, but I can't get the transaction interceptor to trigger.Issue 3
The
@Transactional
link in the docs redirects to https://docs.micronaut.io/latest/api/io/micronaut/spring/tx/annotation/Transactional.html, which doesn't exist.Issue 4
Not sure if limited to this page, but clicking the
Improve this doc
buttons yield a JS error, as the button link contains an unescaped newline:Thanks!
Steps To Reproduce
GET http://localhost:8080/test
GET http://localhost:8080/test
If transactions were working, the table creation would be rolled back each time.
I've also debugged into
io.micronaut.spring.tx.annotation.TransactionInterceptor#intercept
and can confirm that it's not being fired. The datasource is, however, wrapped in aTransactionAwareDataSourceProxy
.Environment Information
Example Application
https://github.com/chrisparton1991/micronaut-transaction-test
Version
3.0.1 (also reproducible in 2.5.11)
The text was updated successfully, but these errors were encountered: