diff --git a/src/main/java/net/helenus/core/AbstractSessionOperations.java b/src/main/java/net/helenus/core/AbstractSessionOperations.java index 3f8eba2..912f12f 100644 --- a/src/main/java/net/helenus/core/AbstractSessionOperations.java +++ b/src/main/java/net/helenus/core/AbstractSessionOperations.java @@ -86,11 +86,11 @@ public abstract class AbstractSessionOperations { return execute(statement, null, timer, showValues); } - public ResultSet execute(Statement statement, UnitOfWork uow, boolean showValues) { + public ResultSet execute(Statement statement, UnitOfWork uow, boolean showValues) { return execute(statement, uow, null, showValues); } - public ResultSet execute(Statement statement, UnitOfWork uow, Stopwatch timer, boolean showValues) { + public ResultSet execute(Statement statement, UnitOfWork uow, Stopwatch timer, boolean showValues) { return executeAsync(statement, uow, timer, showValues).getUninterruptibly(); } @@ -102,11 +102,11 @@ public abstract class AbstractSessionOperations { return executeAsync(statement, null, timer, showValues); } - public ResultSetFuture executeAsync(Statement statement, UnitOfWork uow, boolean showValues) { + public ResultSetFuture executeAsync(Statement statement, UnitOfWork uow, boolean showValues) { return executeAsync(statement, uow, null, showValues); } - public ResultSetFuture executeAsync(Statement statement, UnitOfWork uow, Stopwatch timer, boolean showValues) { + public ResultSetFuture executeAsync(Statement statement, UnitOfWork uow, Stopwatch timer, boolean showValues) { try { logStatement(statement, showValues); return currentSession().executeAsync(statement); diff --git a/src/main/java/net/helenus/core/ConflictingUnitOfWorkException.java b/src/main/java/net/helenus/core/ConflictingUnitOfWorkException.java index a20aad4..bd52799 100644 --- a/src/main/java/net/helenus/core/ConflictingUnitOfWorkException.java +++ b/src/main/java/net/helenus/core/ConflictingUnitOfWorkException.java @@ -2,9 +2,9 @@ package net.helenus.core; public class ConflictingUnitOfWorkException extends Exception { - final UnitOfWork uow; + final UnitOfWork uow; - ConflictingUnitOfWorkException(UnitOfWork uow) { + ConflictingUnitOfWorkException(UnitOfWork uow) { this.uow = uow; } } diff --git a/src/main/java/net/helenus/core/PostCommitFunction.java b/src/main/java/net/helenus/core/PostCommitFunction.java index a859608..f45f033 100644 --- a/src/main/java/net/helenus/core/PostCommitFunction.java +++ b/src/main/java/net/helenus/core/PostCommitFunction.java @@ -5,10 +5,10 @@ import java.util.Objects; public class PostCommitFunction implements java.util.function.Function { - private final UnitOfWork uow; + private final UnitOfWork uow; private final List postCommit; - PostCommitFunction(UnitOfWork uow, List postCommit) { + PostCommitFunction(UnitOfWork uow, List postCommit) { this.uow = uow; this.postCommit = postCommit; } diff --git a/src/main/java/net/helenus/core/operation/AbstractOperation.java b/src/main/java/net/helenus/core/operation/AbstractOperation.java index 82e8fb2..9d834d8 100644 --- a/src/main/java/net/helenus/core/operation/AbstractOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractOperation.java @@ -46,7 +46,7 @@ public abstract class AbstractOperation> ex } } - public E sync(UnitOfWork uow) {// throws TimeoutException { + public E sync(UnitOfWork uow) {// throws TimeoutException { if (uow == null) return sync(); @@ -71,7 +71,7 @@ public abstract class AbstractOperation> ex }); } - public CompletableFuture async(UnitOfWork uow) { + public CompletableFuture async(UnitOfWork uow) { if (uow == null) return async(); return CompletableFuture.supplyAsync(() -> { diff --git a/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java b/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java index fe27197..dd7907c 100644 --- a/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java @@ -154,25 +154,30 @@ public abstract class AbstractOptionalOperation again = new ArrayList<>(); + List facets = getFacets(); + resultStream.forEach(result -> { + if (result != deleted) { + if (updateCache) { + cacheUpdate(uow, result, facets); + } + again.add(result); + } + }); + resultStream = again.stream(); + } - // If we have a result and we're caching then we need to put it into the cache - // for future requests to find. - if (resultStream != null) { - List again = new ArrayList<>(); - List facets = getFacets(); - resultStream.forEach(result -> { - if (result != deleted) { - if (updateCache) { - cacheUpdate(uow, result, facets); - } - again.add(result); - } - }); - resultStream = again.stream(); - } return resultStream; } finally { context.stop(); diff --git a/src/main/java/net/helenus/core/operation/DeleteOperation.java b/src/main/java/net/helenus/core/operation/DeleteOperation.java index 5490bf2..e180ff0 100644 --- a/src/main/java/net/helenus/core/operation/DeleteOperation.java +++ b/src/main/java/net/helenus/core/operation/DeleteOperation.java @@ -182,7 +182,7 @@ public final class DeleteOperation extends AbstractFilterOperation uow) {// throws TimeoutException { if (uow == null) { return sync(); } diff --git a/src/main/java/net/helenus/core/operation/InsertOperation.java b/src/main/java/net/helenus/core/operation/InsertOperation.java index 510121c..462449c 100644 --- a/src/main/java/net/helenus/core/operation/InsertOperation.java +++ b/src/main/java/net/helenus/core/operation/InsertOperation.java @@ -245,7 +245,7 @@ public final class InsertOperation extends AbstractOperation uow) {// throws TimeoutException { if (uow == null) { return sync(); } diff --git a/src/main/java/net/helenus/core/operation/Operation.java b/src/main/java/net/helenus/core/operation/Operation.java index e63180a..61e12c4 100644 --- a/src/main/java/net/helenus/core/operation/Operation.java +++ b/src/main/java/net/helenus/core/operation/Operation.java @@ -87,8 +87,8 @@ public abstract class Operation { return query; } - public ResultSet execute(AbstractSessionOperations session, UnitOfWork uow, TraceContext traceContext, long timeout, - TimeUnit units, boolean showValues, boolean cached) { // throws TimeoutException { + public ResultSet execute(AbstractSessionOperations session, UnitOfWork uow, TraceContext traceContext, + long timeout, TimeUnit units, boolean showValues, boolean cached) { // throws TimeoutException { // Start recording in a Zipkin sub-span our execution time to perform this // operation. @@ -129,7 +129,7 @@ public abstract class Operation { } } - void log(Statement statement, UnitOfWork uow, Stopwatch timer, boolean showValues) { + void log(Statement statement, UnitOfWork uow, Stopwatch timer, boolean showValues) { if (LOG.isInfoEnabled()) { String uowString = ""; if (uow != null) { diff --git a/src/main/java/net/helenus/core/operation/UpdateOperation.java b/src/main/java/net/helenus/core/operation/UpdateOperation.java index f21133f..dfdc955 100644 --- a/src/main/java/net/helenus/core/operation/UpdateOperation.java +++ b/src/main/java/net/helenus/core/operation/UpdateOperation.java @@ -577,7 +577,7 @@ public final class UpdateOperation extends AbstractFilterOperation uow) {// throws TimeoutException { if (uow == null) { return sync(); }