mirror of https://github.com/usbharu/Hideout.git
feat: DBへの保存に失敗したときロールバックを明示的にしてその後Selectできるように
This commit is contained in:
parent
51837ea379
commit
9c5aaedf4d
|
@ -1,6 +1,7 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
package dev.usbharu.hideout.core.infrastructure.exposedrepository
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.exception.SpringDataAccessExceptionSQLExceptionTranslator
|
import dev.usbharu.hideout.core.domain.exception.SpringDataAccessExceptionSQLExceptionTranslator
|
||||||
|
import org.jetbrains.exposed.sql.transactions.TransactionManager
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
|
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
|
||||||
|
@ -37,6 +38,7 @@ ${Throwable().stackTrace.joinToString("\n")}
|
||||||
if (traceQueryException) {
|
if (traceQueryException) {
|
||||||
logger.trace("FAILED EXECUTE SQL", e)
|
logger.trace("FAILED EXECUTE SQL", e)
|
||||||
}
|
}
|
||||||
|
TransactionManager.currentOrNull()?.rollback()
|
||||||
if (e.cause !is SQLException) {
|
if (e.cause !is SQLException) {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue