Skip to content

Commit 85a62b8

Browse files
committed
LocalTransactionManager#notSupported()でトランザクションを作成しないようにしました fix #51
1 parent 643a97b commit 85a62b8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main/java/org/seasar/doma/jdbc/tx/LocalTransactionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ protected <RESULT> RESULT notSupportedInternal(
200200
if (transaction.isActive()) {
201201
LocalTransactionContext context = transaction.suspend();
202202
try {
203-
return executeInTransaction(isolationLevel, supplier);
203+
return supplier.get();
204204
} finally {
205205
transaction.resume(context);
206206
}

src/test/java/org/seasar/doma/jdbc/tx/LocalTransactionManagerTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,20 @@ public void testNotSupported_supplier() throws Exception {
134134
assertEquals("aaa", result);
135135
}
136136

137+
public void testNotSupported_in_tx() throws Exception {
138+
LocalTransactionManager manager = new LocalTransactionManager(
139+
transaction);
140+
StringBuilder log = new StringBuilder();
141+
log.append(LocalTransactionManagerTest.counter);
142+
manager.required(() -> {
143+
log.append(LocalTransactionManagerTest.counter);
144+
manager.notSupported(() -> {
145+
log.append(LocalTransactionManagerTest.counter);
146+
});
147+
log.append(LocalTransactionManagerTest.counter);
148+
});
149+
log.append(LocalTransactionManagerTest.counter);
150+
assertEquals("01110", log.toString());
151+
}
152+
137153
}

0 commit comments

Comments
 (0)