micronaut-data
micronaut-data copied to clipboard
CannotGetJdbcConnectionException when upgrade to Micronaut 3.6.0
Expected Behavior
Hope the JdbcOperations works as before.
Actual Behaviour
The Jdbc operations prepreStatement caused the following exceptions.
Caused by: io.micronaut.transaction.jdbc.exceptions.CannotGetJdbcConnectionException:
No current JDBC Connection found. Consider wrapping this call in transactional boundaries.
Steps To Reproduce
See the test example: https://github.com/hantsy/micronaut-sandbox/blob/master/data-jdbc-kotlin/src/test/kotlin/com/example/PostRepositoryStringSpecWithTestcontainters.kt
val insertedCnt = template.prepareStatement(sql) {
it.setString(1, "test title")
it.setString(2, "test content")
it.setString(3, "DRAFT")
it.executeUpdate()
}
The prepareStatement
requires a Transaction now.
Environment Information
- Windows 10
- Java 17
Example Application
https://github.com/hantsy/micronaut-sandbox/tree/master/data-jdbc-kotlin
Version
3.7.2