Skip to content

Commit

Permalink
Change Transaction API
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed Feb 22, 2022
1 parent 0c5f316 commit 28952ca
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions content/ja/docs/Reference/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ db.withTransaction(

### 明示的なロールバック {#explicit-rollback}

`withTransaction`拡張関数に渡されたラムダ式の中で`setRollbackOnly`関数を呼び出すと`withTransaction`拡張関数終了時にロールバックが実行されます。
`setRollbackOnly`関数を呼び出すと`withTransaction`拡張関数終了時にロールバックが実行されます。

```kotlin
db.withTransaction {
db.withTransaction { tx ->
..
setRollbackOnly()
tx.setRollbackOnly()
..
}
```

すでに`setRollbackOnly`関数を呼び出したかどうかは`isRollbackOnly`関数で確認できます。

```kotlin
db.withTransaction {
db.withTransaction { tx ->
..
if (isRollbackOnly()) {
if (tx.isRollbackOnly()) {
..
}
..
Expand All @@ -121,12 +121,12 @@ db.withTransaction {

### 新規トランザクションの開始と終了 {#begin-and-end-of-new-transaction}

すでに開始されたトランザクションの中で別のトランザクションを新しく開始するには`withTransaction`拡張関数に渡されたラムダ式の中で`requiresNew`関数を呼び出します。
すでに開始されたトランザクションの中で別のトランザクションを新しく開始するには`requiresNew`関数を呼び出します。

```kotlin
db.withTransaction {
db.withTransaction { tx ->
..
requiresNew {
tx.requiresNew {
..
}
..
Expand All @@ -136,9 +136,9 @@ db.withTransaction {
`requiresNew`関数にはトランザクション分離レベルを指定できます。

```kotlin
db.withTransaction {
db.withTransaction { tx ->
..
requiresNew(isolationLevel = JdbcIsolationLevel.SERIALIZABLE) {
tx.requiresNew(isolationLevel = JdbcIsolationLevel.SERIALIZABLE) {
..
}
..
Expand Down

0 comments on commit 28952ca

Please sign in to comment.