diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 4fe1468ec..cb8c1d67e 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -50,7 +50,7 @@
io.ebean
ebean-annotation
- 6.15
+ 7.0
diff --git a/ebean-api/src/main/java/io/ebean/TxScope.java b/ebean-api/src/main/java/io/ebean/TxScope.java
index ee9fdca7b..59d9f6971 100644
--- a/ebean-api/src/main/java/io/ebean/TxScope.java
+++ b/ebean-api/src/main/java/io/ebean/TxScope.java
@@ -2,6 +2,7 @@ package io.ebean;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.TxIsolation;
+import io.ebean.annotation.TxOption;
import io.ebean.annotation.TxType;
import java.util.ArrayList;
@@ -33,6 +34,8 @@ public final class TxScope {
private TxIsolation isolation;
+ private TxOption autoPersistUpdates;
+
private PersistBatch batch;
private PersistBatch batchOnCascade;
@@ -123,6 +126,13 @@ public final class TxScope {
+ "] serverName[" + serverName + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]";
}
+ /**
+ * Return the AutoPersistUpdates mode as a nullable Boolean.
+ */
+ public Boolean getAutoPersistUpdates() {
+ return autoPersistUpdates == null ? null : autoPersistUpdates.asBoolean();
+ }
+
/**
* Return true if PersistBatch has been set.
*/
@@ -176,6 +186,14 @@ public final class TxScope {
return this;
}
+ /**
+ * Set the autoPersistUpdates mode.
+ */
+ public TxScope setAutoPersistUpdates(TxOption autoPersistUpdates) {
+ this.autoPersistUpdates = autoPersistUpdates;
+ return this;
+ }
+
/**
* Return the transaction profile id.
*/
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 3652ba9a3..4b37905a9 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java b/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java
index 5fbb03f25..631b6dfb8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java
@@ -73,6 +73,10 @@ public class ScopeTrans {
restoreBatchGeneratedKeys = transaction.getBatchGetGeneratedKeys();
restoreBatchFlushOnQuery = transaction.isFlushOnQuery();
}
+ Boolean autoPersistUpdates = txScope.getAutoPersistUpdates();
+ if (autoPersistUpdates != null) {
+ transaction.setAutoPersistUpdates(autoPersistUpdates);
+ }
if (txScope.isBatchSet()) {
transaction.setBatchMode(txScope.isBatchMode());
}
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
index 963cc1dcb..a169145eb 100644
--- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -1,9 +1,7 @@
package org.tests.transparentpersist;
-import io.ebean.BaseTestCase;
-import io.ebean.DB;
-import io.ebean.Database;
-import io.ebean.Transaction;
+import io.ebean.*;
+import io.ebean.annotation.*;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeantest.LoggedSql;
import org.junit.Test;
@@ -219,6 +217,43 @@ public class TestTransparentPersist extends BaseTestCase {
DB.delete(Customer.class, c0.getId());
}
+ @Test
+ public void txScope_setAutoPersistUpdates() {
+
+ EBasicVer b0 = new EBasicVer("txScopeUpdate");
+ b0.save();
+
+ DB.execute(TxScope.required().setAutoPersistUpdates(TxOption.ON), () -> {
+ EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+ found.setName("mutable txScope bean");
+ });
+
+ EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+ assertThat(after.getName()).isEqualTo("mutable txScope bean");
+
+ DB.delete(after);
+ }
+
+// @Test
+// public void txn_setAutoPersistUpdates() {
+//
+// EBasicVer b0 = new EBasicVer("txn autoPersistUpdates ON");
+// b0.save();
+//
+// performUpdate(b0);
+//
+// EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+// assertThat(after.getName()).isEqualTo("mutated with autoPersistUpdates ON");
+//
+// DB.delete(after);
+// }
+//
+// @Transactional(autoPersistUpdates = TxOption.ON)
+// private void performUpdate(EBasicVer b0) {
+// EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+// found.setName("mutated with autoPersistUpdates ON");
+// }
+
@Test
public void simulate_transparentPersistence_forSimpleUpdate() {
diff --git a/ebean-core/src/test/resources/logback-test.xml b/ebean-core/src/test/resources/logback-test.xml
index 164ff73d3..1b8a60a9b 100644
--- a/ebean-core/src/test/resources/logback-test.xml
+++ b/ebean-core/src/test/resources/logback-test.xml
@@ -79,8 +79,8 @@
-
-
+
+