feat: DBへの保存に失敗したときロールバックを明示的にしてその後Selectできるように

This commit is contained in:
usbharu 2023-12-22 15:45:55 +09:00
parent 51837ea379
commit 9c5aaedf4d
1 changed files with 2 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package dev.usbharu.hideout.core.infrastructure.exposedrepository
import dev.usbharu.hideout.core.domain.exception.SpringDataAccessExceptionSQLExceptionTranslator
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.slf4j.Logger
import org.springframework.beans.factory.annotation.Value
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
@ -37,6 +38,7 @@ ${Throwable().stackTrace.joinToString("\n")}
if (traceQueryException) {
logger.trace("FAILED EXECUTE SQL", e)
}
TransactionManager.currentOrNull()?.rollback()
if (e.cause !is SQLException) {
throw e
}