mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 14:40:46 +00:00
Revert #1263 - ENH: Make Transaction API Fluid such that we can set multiple thing like batchSize and label in a fluid fashion #1276
This commit is contained in:
1 parent
21182da793
commit
0e219a9bc6
10 files changed
+120
-174
No files matched your search
@@ -1,7 +1,5 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebean.Transaction;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@@ -23,9 +21,8 @@ public class DocStoreOnlyTransaction extends JdbcTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setReadOnly(boolean readOnly) {
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
// do nothing
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+20
-32
@@ -1,7 +1,6 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.TransactionCallback;
|
||||
import io.ebean.annotation.DocStoreMode;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
@@ -86,9 +85,8 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setLabel(String label) {
|
||||
public void setLabel(String label) {
|
||||
// do nothing
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,8 +130,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setSkipCache(boolean skipCache) {
|
||||
return this;
|
||||
public void setSkipCache(boolean skipCache) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,7 +149,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction register(TransactionCallback callback) {
|
||||
public void register(TransactionCallback callback) {
|
||||
throw new IllegalStateException(notExpectedMessage);
|
||||
}
|
||||
|
||||
@@ -162,7 +159,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setDocStoreBatchSize(int docStoreBatchSize) {
|
||||
public void setDocStoreBatchSize(int docStoreBatchSize) {
|
||||
throw new IllegalStateException(notExpectedMessage);
|
||||
}
|
||||
|
||||
@@ -172,7 +169,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setDocStoreMode(DocStoreMode docStoreMode) {
|
||||
public void setDocStoreMode(DocStoreMode docStoreMode) {
|
||||
throw new IllegalStateException(notExpectedMessage);
|
||||
}
|
||||
|
||||
@@ -247,21 +244,19 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setReadOnly(boolean readOnly) {
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
if (!isActive()) {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
try {
|
||||
connection.setReadOnly(readOnly);
|
||||
return this;
|
||||
} catch (SQLException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
return this;
|
||||
public void setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -270,13 +265,13 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchMode(boolean batchMode) {
|
||||
return this;
|
||||
public void setBatchMode(boolean batchMode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatch(PersistBatch batchMode) {
|
||||
return this;
|
||||
public void setBatch(PersistBatch batchMode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,8 +280,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchOnCascade(PersistBatch batchOnCascadeMode) {
|
||||
return this;
|
||||
public void setBatchOnCascade(PersistBatch batchOnCascadeMode) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,13 +294,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
|
||||
return this;
|
||||
public void setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchFlushOnMixed(boolean batchFlushOnMixed) {
|
||||
return this;
|
||||
public void setBatchFlushOnMixed(boolean batchFlushOnMixed) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,8 +313,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchSize(int batchSize) {
|
||||
return this;
|
||||
public void setBatchSize(int batchSize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,8 +322,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchFlushOnQuery(boolean batchFlushOnQuery) {
|
||||
return this;
|
||||
public void setBatchFlushOnQuery(boolean batchFlushOnQuery) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,7 +536,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
* Mark the transaction as rollback only.
|
||||
*/
|
||||
@Override
|
||||
public Transaction setRollbackOnly() {
|
||||
public void setRollbackOnly() {
|
||||
// expect AutoCommit so we can't really support rollbackOnly
|
||||
throw new IllegalStateException(notExpectedMessage);
|
||||
}
|
||||
@@ -596,12 +586,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setPersistCascade(boolean persistCascade) {
|
||||
return this;
|
||||
public void setPersistCascade(boolean persistCascade) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
public void addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
throw new IllegalStateException(notExpectedMessage);
|
||||
}
|
||||
|
||||
@@ -611,12 +600,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction putUserObject(String name, Object value) {
|
||||
public void putUserObject(String name, Object value) {
|
||||
if (userObjects == null) {
|
||||
userObjects = new HashMap<>();
|
||||
}
|
||||
userObjects.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.TransactionCallback;
|
||||
import io.ebean.annotation.DocStoreMode;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
@@ -218,9 +217,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setLabel(String label) {
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,9 +288,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setSkipCache(boolean skipCache) {
|
||||
public void setSkipCache(boolean skipCache) {
|
||||
this.skipCache = skipCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -321,12 +318,11 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction register(TransactionCallback callback) {
|
||||
public void register(TransactionCallback callback) {
|
||||
if (callbackList == null) {
|
||||
callbackList = new ArrayList<>(4);
|
||||
}
|
||||
callbackList.add(callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void firePreRollback() {
|
||||
@@ -389,9 +385,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setDocStoreBatchSize(int docStoreBatchSize) {
|
||||
public void setDocStoreBatchSize(int docStoreBatchSize) {
|
||||
this.docStoreBatchSize = docStoreBatchSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -400,9 +395,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setDocStoreMode(DocStoreMode docStoreMode) {
|
||||
public void setDocStoreMode(DocStoreMode docStoreMode) {
|
||||
this.docStoreMode = docStoreMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -535,23 +529,21 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setReadOnly(boolean readOnly) {
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
if (!isActive()) {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
try {
|
||||
localReadOnly = readOnly;
|
||||
connection.setReadOnly(readOnly);
|
||||
return this;
|
||||
} catch (SQLException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
public void setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
this.updateAllLoadedProperties = updateAllLoadedProperties;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -560,21 +552,19 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchMode(boolean batchMode) {
|
||||
public void setBatchMode(boolean batchMode) {
|
||||
if (!isActive()) {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
this.batchMode = (batchMode) ? PersistBatch.ALL : PersistBatch.NONE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatch(PersistBatch batchMode) {
|
||||
public void setBatch(PersistBatch batchMode) {
|
||||
if (!isActive()) {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
this.batchMode = batchMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -583,12 +573,11 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchOnCascade(PersistBatch batchOnCascadeMode) {
|
||||
public void setBatchOnCascade(PersistBatch batchOnCascadeMode) {
|
||||
if (!isActive()) {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
this.batchOnCascadeMode = batchOnCascadeMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -602,21 +591,19 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
|
||||
public void setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
|
||||
this.batchGetGeneratedKeys = getGeneratedKeys;
|
||||
if (batchControl != null) {
|
||||
batchControl.setGetGeneratedKeys(getGeneratedKeys);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchFlushOnMixed(boolean batchFlushOnMixed) {
|
||||
public void setBatchFlushOnMixed(boolean batchFlushOnMixed) {
|
||||
this.batchFlushOnMixed = batchFlushOnMixed;
|
||||
if (batchControl != null) {
|
||||
batchControl.setBatchFlushOnMixed(batchFlushOnMixed);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -631,12 +618,11 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchSize(int batchSize) {
|
||||
public void setBatchSize(int batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
if (batchControl != null) {
|
||||
batchControl.setBatchSize(batchSize);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -645,9 +631,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchFlushOnQuery(boolean batchFlushOnQuery) {
|
||||
public void setBatchFlushOnQuery(boolean batchFlushOnQuery) {
|
||||
this.batchFlushOnQuery = batchFlushOnQuery;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1128,9 +1113,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
* Mark the transaction as rollback only.
|
||||
*/
|
||||
@Override
|
||||
public Transaction setRollbackOnly() {
|
||||
public void setRollbackOnly() {
|
||||
this.rollbackOnly = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1198,15 +1182,13 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setPersistCascade(boolean persistCascade) {
|
||||
public void setPersistCascade(boolean persistCascade) {
|
||||
this.persistCascade = persistCascade;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
public void addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
getEvent().add(tableName, inserts, updates, deletes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1219,12 +1201,11 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction putUserObject(String name, Object value) {
|
||||
public void putUserObject(String name, Object value) {
|
||||
if (userObjects == null) {
|
||||
userObjects = new HashMap<>();
|
||||
}
|
||||
userObjects.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebean.ProfileLocation;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.TransactionCallback;
|
||||
import io.ebean.annotation.DocStoreMode;
|
||||
import io.ebean.annotation.PersistBatch;
|
||||
@@ -29,8 +28,8 @@ class NoTransaction implements SpiTransaction {
|
||||
static final NoTransaction INSTANCE = new NoTransaction();
|
||||
|
||||
@Override
|
||||
public Transaction setLabel(String label) {
|
||||
return this;
|
||||
public void setLabel(String label) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,8 +150,8 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction register(TransactionCallback callback) {
|
||||
return this;
|
||||
public void register(TransactionCallback callback) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,13 +160,13 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setReadOnly(boolean readOnly) {
|
||||
return this;
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setRollbackOnly() {
|
||||
return this;
|
||||
public void setRollbackOnly() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,28 +176,28 @@ class NoTransaction implements SpiTransaction {
|
||||
|
||||
|
||||
@Override
|
||||
public Transaction setDocStoreMode(DocStoreMode mode) {
|
||||
return this;
|
||||
public void setDocStoreMode(DocStoreMode mode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setDocStoreBatchSize(int batchSize) {
|
||||
return this;
|
||||
public void setDocStoreBatchSize(int batchSize) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setPersistCascade(boolean persistCascade) {
|
||||
return this;
|
||||
public void setPersistCascade(boolean persistCascade) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
return this;
|
||||
public void setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setSkipCache(boolean skipCache) {
|
||||
return this;
|
||||
public void setSkipCache(boolean skipCache) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,13 +206,13 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchMode(boolean useBatch) {
|
||||
return this;
|
||||
public void setBatchMode(boolean useBatch) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatch(PersistBatch persistBatchMode) {
|
||||
return this;
|
||||
public void setBatch(PersistBatch persistBatchMode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,8 +221,8 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchOnCascade(PersistBatch batchOnCascadeMode) {
|
||||
return this;
|
||||
public void setBatchOnCascade(PersistBatch batchOnCascadeMode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,8 +231,8 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchSize(int batchSize) {
|
||||
return this;
|
||||
public void setBatchSize(int batchSize) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,18 +241,18 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
|
||||
return this;
|
||||
public void setBatchGetGeneratedKeys(boolean getGeneratedKeys) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchFlushOnMixed(boolean batchFlushOnMixed) {
|
||||
return this;
|
||||
public void setBatchFlushOnMixed(boolean batchFlushOnMixed) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction setBatchFlushOnQuery(boolean batchFlushOnQuery) {
|
||||
return this;
|
||||
public void setBatchFlushOnQuery(boolean batchFlushOnQuery) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,13 +276,13 @@ class NoTransaction implements SpiTransaction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
return this;
|
||||
public void addModification(String tableName, boolean inserts, boolean updates, boolean deletes) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction putUserObject(String name, Object value) {
|
||||
return this;
|
||||
public void putUserObject(String name, Object value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user