mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-25 15:18:59 +00:00
#941 - @Transactional( type = TxType.MANDATORY ) creates a new transaction even if there is one available
This commit is contained in:
1 parent
3fb497b651
commit
5ad9a611f9
2 files changed
+49
-1
No files matched your search
@@ -0,0 +1,48 @@
|
||||
package org.tests.transaction;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.TxType;
|
||||
import io.ebean.annotation.Transactional;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestNestedMandatory extends BaseTestCase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TestNestedMandatory.class);
|
||||
|
||||
static Transaction outerTxn;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
new Outer().doOuter();
|
||||
}
|
||||
|
||||
class Outer {
|
||||
|
||||
@Transactional
|
||||
void doOuter() {
|
||||
outerTxn = Ebean.currentTransaction();
|
||||
|
||||
log.info("outer start ...{}", outerTxn);
|
||||
new Inner().doInner();
|
||||
log.info("outer end ...{}", outerTxn);
|
||||
}
|
||||
}
|
||||
|
||||
class Inner {
|
||||
|
||||
@Transactional(type = TxType.MANDATORY)
|
||||
void doInner() {
|
||||
Transaction innerTxn = Ebean.currentTransaction();
|
||||
log.info("inner ...{}", innerTxn);
|
||||
|
||||
assertThat(innerTxn).isSameAs(outerTxn);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user