From bce745e88db89b0c10071612571e2326777d753a Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 22 Jan 2018 15:04:13 +1300 Subject: [PATCH] #1240 - ENH: Add support for @Transactional skipCache and label --- src/main/java/io/ebean/TxScope.java | 34 +++++++++++++++++++ .../server/core/DefaultServer.java | 7 ++++ 2 files changed, 41 insertions(+) diff --git a/src/main/java/io/ebean/TxScope.java b/src/main/java/io/ebean/TxScope.java index bebe6a31d..b7b02d0c1 100644 --- a/src/main/java/io/ebean/TxScope.java +++ b/src/main/java/io/ebean/TxScope.java @@ -48,6 +48,10 @@ public final class TxScope { */ private boolean flushOnQuery = true; + private boolean skipCache; + + private String label; + private ArrayList> rollbackFor; private ArrayList> 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. */ diff --git a/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 13558b0d6..5e2bcc8e2 100644 --- a/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -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);