Reputation: 1687
I'm trying to figure out Jooq 3.17 transaction semantics when used in a Spring Boot application that already uses Hibernate. I read the Jooq docs on this: https://www.jooq.org/doc/latest/manual/sql-execution/transaction-management/, and I think these are the relevant portions for me:
There are essentially five ways how you can handle transactions in Java / SQL:
- You can issue vendor-specific COMMIT, ROLLBACK and other statements directly in your database.
- You can call JDBC's Connection.commit(), Connection.rollback() and other methods on your JDBC driver, or use the equivalent methods on your R2DBC driver.
- You can use third-party transaction management libraries like Spring TX..
- You can use a JTA-compliant Java EE transaction manager from your container.
- You use jOOQ's transaction API.
By default, jOOQ ships with the org.jooq.impl.DefaultTransactionProvider, which implements nested transactions using JDBC java.sql.Savepoint. You can, however, implement your own org.jooq.TransactionProvider and supply that to your Configuration to override jOOQ's default behaviour. A simple example implementation using Spring's DataSourceTransactionManager can be seen here:
SpringTransactionProvider
? Or am I covered by bullet point 4 - maybe Hibernate provides a JTA-compliant Java EE transaction manager
?Upvotes: 1
Views: 261
Reputation: 221106
Does this mean that if I'm using Jooq within a Spring Boot + Hibernate application, I need to implement my own version of the example SpringTransactionProvider?
Not necessarily. It just means you should provide jOOQ with a transaction aware DataSource
of some sort, and not use jOOQ's own transaction API.
Is there Jooq logging I can turn on that will show me when Jooq recognizes transactions starting and stopping?
Unless you use jOOQ's transaction API, jOOQ doesn't really care about your transaction. It just works with your transaction aware JDBC resources, just like when you use JDBC directly. There's no jOOQ magic going on here, and thus, there's no jOOQ transaction logging available, as jOOQ doesn't know anything about such transactions.
Upvotes: 0