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:
- 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
? Or am I covered by bullet point 4 - maybe Hibernate provides aJTA-compliant Java EE transaction manager
? - Is there Jooq logging I can turn on that will show me when Jooq recognizes transactions starting and stopping? Something along the lines of this: How to log the start and the completion of DB transactions in Hibernate but for Jooq?