mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
50 lines
1.1 KiB
Java
50 lines
1.1 KiB
Java
package org.tests.transaction;
|
|
|
|
import io.ebean.BaseTestCase;
|
|
import io.ebean.DB;
|
|
import io.ebean.Transaction;
|
|
import io.ebean.annotation.Transactional;
|
|
import io.ebean.annotation.TxType;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import javax.persistence.PersistenceException;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
public class TestTransactionalNever extends BaseTestCase {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(TestTransactionalNever.class);
|
|
|
|
private Transaction outerTxn;
|
|
|
|
@Test
|
|
public void testWithNever() {
|
|
|
|
new SomeTransactionalWithNever().doStuff();
|
|
}
|
|
|
|
@Test
|
|
public void testBarfOnExisting() {
|
|
assertThrows(PersistenceException.class, this::doWithTransaction);
|
|
}
|
|
|
|
class SomeTransactionalWithNever {
|
|
|
|
@Transactional(type = TxType.NEVER)
|
|
void doStuff() {
|
|
outerTxn = DB.currentTransaction();
|
|
log.info("currentTransaction ...{}", outerTxn);
|
|
}
|
|
}
|
|
|
|
@Transactional
|
|
private void doWithTransaction() {
|
|
|
|
// always barf
|
|
new SomeTransactionalWithNever().doStuff();
|
|
}
|
|
|
|
}
|