-
Notifications
You must be signed in to change notification settings - Fork 22
Transactions
query.transaction().in(
() -> {
query
.update("UPDATE CUSTOMER SET NAME = ?, ADDRESS = ?")
.params("John Doe", "Dallas")
.run();
// ... other queries, method calls, etc..
}
)
Any queries executed by FluentJdbc within this callback will join this transaction - as long as they're in the same thread, and based on the same ConnectionProvider (DataSource). Connections / transactions to multiple DataSources - through multiple FluentJdbc setups/instances - are supported.
Many frameworks provide transaction-aware DataSources. If's ConnectionProvider is based on such a DataSource, all FluentJdbc operations will be executed as part of the current transaction (if any). See integration pages for concrete examples:
The underlying connection of a JPA session can be extracted from the EntityManager. See integration pages for detailed examples:
- JPA integration
- Guice Persist integration
Some frameworks provide transaction-management through Connection callbacks. The API of ConnectionProvider makes these easy to integrate with. See integration page for examples:
Guice Persist transaction-management / annotations can be used without JPA. FluentJdbc Guice Persist extension library provides a module for this:
Custom ConnectionProvider can be implemented to integrate with other transaction-management solutions.