Skip to content

Commit

Permalink
Add Transaction to lifecycle hooks for #1530 (#1531)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Romanowski <rromanowski@figure.com>
  • Loading branch information
rsromanowski and rromanowski-figure committed Jul 16, 2022
1 parent bf64c31 commit e4d18db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ open class Transaction(private val transactionImpl: TransactionInterface) : User
}
transactionImpl.commit()
userdata.clear()
globalInterceptors.forEach { it.afterCommit() }
interceptors.forEach { it.afterCommit() }
globalInterceptors.forEach { it.afterCommit(this) }
interceptors.forEach { it.afterCommit(this) }
userdata.putAll(dataToStore)
}

override fun rollback() {
globalInterceptors.forEach { it.beforeRollback(this) }
interceptors.forEach { it.beforeRollback(this) }
transactionImpl.rollback()
globalInterceptors.forEach { it.afterRollback() }
interceptors.forEach { it.afterRollback() }
globalInterceptors.forEach { it.afterRollback(this) }
interceptors.forEach { it.afterRollback(this) }
userdata.clear()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ interface StatementInterceptor {
fun afterExecution(transaction: Transaction, contexts: List<StatementContext>, executedStatement: PreparedStatementApi) {}

fun beforeCommit(transaction: Transaction) {}
fun afterCommit() {}
fun afterCommit(transaction: Transaction) {}

fun beforeRollback(transaction: Transaction) {}
fun afterRollback() {}
fun afterRollback(transaction: Transaction) {}

fun keepUserDataInTransactionStoreOnCommit(userData: Map<Key<*>, Any?>): Map<Key<*>, Any?> = emptyMap()
}
Expand Down

0 comments on commit e4d18db

Please sign in to comment.