mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor rename transparentPersistence to autoPersistUpdates
This commit is contained in:
@@ -60,12 +60,12 @@ public interface Transaction extends AutoCloseable {
|
||||
void register(TransactionCallback callback);
|
||||
|
||||
/**
|
||||
* EXPERIMENTAL - turn on transparent persistence and batchMode true.
|
||||
* EXPERIMENTAL - turn on automatic persistence of dirty beans and batchMode true.
|
||||
* <p>
|
||||
* With this turned on beans that are dirty in the persistence context
|
||||
* are automatically persisted on flush() and commit().
|
||||
*/
|
||||
void setTransparentPersistence(boolean transparentPersistence);
|
||||
void setAutoPersistUpdates(boolean autoPersistUpdates);
|
||||
|
||||
/**
|
||||
* Set a label on the transaction.
|
||||
|
||||
@@ -148,9 +148,9 @@ public interface SpiTransaction extends Transaction {
|
||||
int depth();
|
||||
|
||||
/**
|
||||
* Return true if transparent persistence is turned on.
|
||||
* Return true if dirty beans are automatically persisted.
|
||||
*/
|
||||
boolean isTransparentPersistence();
|
||||
boolean isAutoPersistUpdates();
|
||||
|
||||
/**
|
||||
* Return true if this transaction was created explicitly via
|
||||
|
||||
@@ -44,13 +44,13 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransparentPersistence(boolean transparentPersistence) {
|
||||
transaction.setTransparentPersistence(transparentPersistence);
|
||||
public void setAutoPersistUpdates(boolean autoPersistUpdates) {
|
||||
transaction.setAutoPersistUpdates(autoPersistUpdates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransparentPersistence() {
|
||||
return transaction.isTransparentPersistence();
|
||||
public boolean isAutoPersistUpdates() {
|
||||
return transaction.isAutoPersistUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1038,7 +1038,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
if (!publish) {
|
||||
beanDescriptor.setDraft(entityBean);
|
||||
}
|
||||
if (transaction.isTransparentPersistence() && idValue != null) {
|
||||
if (transaction.isAutoPersistUpdates() && idValue != null) {
|
||||
// with getGeneratedKeys off we will not have a idValue
|
||||
beanDescriptor.contextPut(transaction.getPersistenceContext(), idValue, entityBean);
|
||||
}
|
||||
|
||||
+2
-2
@@ -96,12 +96,12 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransparentPersistence(boolean transparentPersistence) {
|
||||
public void setAutoPersistUpdates(boolean autoPersistUpdates) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransparentPersistence() {
|
||||
public boolean isAutoPersistUpdates() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
|
||||
private final long startNanos;
|
||||
|
||||
private boolean transparentPersistence;
|
||||
private boolean autoPersistUpdates;
|
||||
|
||||
/**
|
||||
* Create a new JdbcTransaction.
|
||||
@@ -211,7 +211,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
this.batchOnCascadeMode = false;
|
||||
this.onQueryOnly = OnQueryOnly.ROLLBACK;
|
||||
} else {
|
||||
this.transparentPersistence = explicit && manager.isAutoPersistUpdates();
|
||||
this.autoPersistUpdates = explicit && manager.isAutoPersistUpdates();
|
||||
this.logSql = manager.isLogSql();
|
||||
this.logSummary = manager.isLogSummary();
|
||||
this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite();
|
||||
@@ -298,14 +298,14 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransparentPersistence(boolean transparentPersistence) {
|
||||
this.transparentPersistence = transparentPersistence;
|
||||
public void setAutoPersistUpdates(boolean autoPersistUpdates) {
|
||||
this.autoPersistUpdates = autoPersistUpdates;
|
||||
this.batchMode = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransparentPersistence() {
|
||||
return transparentPersistence;
|
||||
public boolean isAutoPersistUpdates() {
|
||||
return autoPersistUpdates;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -788,7 +788,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
* Flush the JDBC batch and execute derived relationship statements if necessary.
|
||||
*/
|
||||
private void internalBatchFlush() {
|
||||
if (transparentPersistence) {
|
||||
if (autoPersistUpdates) {
|
||||
// Experimental - flush dirty beans held by the persistence context
|
||||
manager.flushTransparent(persistenceContext, this);
|
||||
}
|
||||
@@ -1060,7 +1060,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
try {
|
||||
if (queryOnly && !transparentPersistence) {
|
||||
if (queryOnly && !autoPersistUpdates) {
|
||||
connectionEndForQueryOnly();
|
||||
} else {
|
||||
flushCommitAndNotify();
|
||||
|
||||
@@ -26,12 +26,12 @@ class NoTransaction implements SpiTransaction {
|
||||
static final NoTransaction INSTANCE = new NoTransaction();
|
||||
|
||||
@Override
|
||||
public void setTransparentPersistence(boolean transparentPersistence) {
|
||||
public void setAutoPersistUpdates(boolean autoPersistUpdates) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransparentPersistence() {
|
||||
public boolean isAutoPersistUpdates() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TestTransparentPersist extends BaseTestCase {
|
||||
|
||||
EBasicVer newBean;
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
|
||||
|
||||
newBean = new EBasicVer("insertMe");
|
||||
DB.save(newBean);
|
||||
@@ -60,7 +60,7 @@ public class TestTransparentPersist extends BaseTestCase {
|
||||
DB.save(b0);
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
|
||||
|
||||
EBasicVer found = DB.find(EBasicVer.class, b0.getId());
|
||||
// make it dirty
|
||||
@@ -88,7 +88,7 @@ public class TestTransparentPersist extends BaseTestCase {
|
||||
|
||||
EBasicVer newBean;
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
|
||||
|
||||
EBasicVer found = DB.find(EBasicVer.class, b0.getId());
|
||||
found.setName("auto dirty");
|
||||
@@ -127,7 +127,7 @@ public class TestTransparentPersist extends BaseTestCase {
|
||||
transPersist.save();
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
|
||||
|
||||
EBasicVer found = DB.find(EBasicVer.class, transPersist.getId());
|
||||
found.setName("Persisted automatically as dirty");
|
||||
@@ -152,7 +152,7 @@ public class TestTransparentPersist extends BaseTestCase {
|
||||
DB.save(order);
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
|
||||
|
||||
Order foundOrder = DB.find(Order.class, order.getId());
|
||||
foundOrder.setStatus(Order.Status.APPROVED);
|
||||
@@ -188,7 +188,7 @@ public class TestTransparentPersist extends BaseTestCase {
|
||||
LoggedSql.start();
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
|
||||
|
||||
Order foundOrder = DB.find(Order.class, order.getId());
|
||||
// we ONLY mutate the foreign key
|
||||
|
||||
Reference in New Issue
Block a user