From 7dcb3e301f2fe3d4480f5adb0edfd88947d0817e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A1=EC=A7=84=ED=98=81=20=28Ivan=29?= Date: Fri, 25 Aug 2023 13:29:53 +0900 Subject: [PATCH] feat: reset outer tx manager when transaction clean up --- .../jetbrains/exposed/spring/SpringTransactionManager.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-transaction/src/main/kotlin/org/jetbrains/exposed/spring/SpringTransactionManager.kt b/spring-transaction/src/main/kotlin/org/jetbrains/exposed/spring/SpringTransactionManager.kt index 3662481e69..a3f876e5d8 100644 --- a/spring-transaction/src/main/kotlin/org/jetbrains/exposed/spring/SpringTransactionManager.kt +++ b/spring-transaction/src/main/kotlin/org/jetbrains/exposed/spring/SpringTransactionManager.kt @@ -37,11 +37,13 @@ class SpringTransactionManager( } override fun doGetTransaction(): Any { + val outerManager = TransactionManager.manager val outer = threadLocalTransactionManager.currentOrNull() return ExposedTransactionObject( manager = threadLocalTransactionManager, - outerTransaction = outer + outerManager = outerManager, + outerTransaction = outer, ) } @@ -82,7 +84,7 @@ class SpringTransactionManager( } trxObject.setCurrentToOuter() - TransactionManager.resetCurrent(null) + TransactionManager.resetCurrent(trxObject.outerManager) } private fun closeStatementsAndConnections(transaction: Transaction) { @@ -113,6 +115,7 @@ class SpringTransactionManager( private data class ExposedTransactionObject( val manager: TransactionManager, + val outerManager: TransactionManager, private val outerTransaction: Transaction?, ) : SmartTransactionObject {