OK, the relevant code is in ThreadLocalTransaction...
# exposed
k
OK, the relevant code is in ThreadLocalTransactionManager.kt
Copy code
return keepAndRestoreTransactionRefAfterRun(db) {
        run()
    }
Somehow this function (the line
run()
calls
Copy code
internal inline fun TransactionInterface.closeLoggingException(log: (Exception) -> Unit){
    try {
        close()
    } catch (e: Exception){
        log(e)
    }
}
based on the stack with the connection close having a breakpoint. Not sure how that happens, but I’m assuming when you create the connection, there should be some keepalive flag that tells the transaction not to auto-close the connection. Because the default behavior of in-memory H2 DBs (which are also supported by Exposed) also have as their default behavior to destroy all data when the connection is closed. Although with H2 you can override this by passing some flag.