#1240 - ENH: Add support for @Transactional skipCache and label

This commit is contained in:
Rob Bygrave
2018-01-22 15:04:13 +13:00
parent 51d2e4c600
commit bce745e88d
2 changed files with 41 additions and 0 deletions
+34
View File
@@ -48,6 +48,10 @@ public final class TxScope {
*/
private boolean flushOnQuery = true;
private boolean skipCache;
private String label;
private ArrayList<Class<? extends Throwable>> rollbackFor;
private ArrayList<Class<? extends Throwable>> noRollbackFor;
@@ -202,6 +206,36 @@ public final class TxScope {
return this;
}
/**
* Return true if the L2 cache should be skipped for this transaction.
*/
public boolean isSkipCache() {
return skipCache;
}
/**
* Set to true if the transaction should skip L2 cache access.
*/
public TxScope setSkipCache(boolean skipCache) {
this.skipCache = skipCache;
return this;
}
/**
* Return the label for the transaction.
*/
public String getLabel() {
return label;
}
/**
* Set a label for the transaction.
*/
public TxScope setLabel(String label) {
this.label = label;
return this;
}
/**
* Return the batch mode.
*/
@@ -849,6 +849,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
private void initNewTransaction(SpiTransaction transaction, TxScope txScope) {
if (txScope.isSkipCache()) {
transaction.setSkipCache(true);
}
String label = txScope.getLabel();
if (label != null) {
transaction.setLabel(label);
}
ProfileLocation profileLocation = txScope.getProfileLocation();
if (profileLocation != null) {
transaction.setProfileLocation(profileLocation);