From b4dca9c710b6c3e15d237154ec9528b1523de761 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Wed, 8 Nov 2017 21:11:58 -0500 Subject: [PATCH] finish up batch feature for now --- .../core/operation/InsertOperation.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/helenus/core/operation/InsertOperation.java b/src/main/java/net/helenus/core/operation/InsertOperation.java index 8764816..4f2d0d2 100644 --- a/src/main/java/net/helenus/core/operation/InsertOperation.java +++ b/src/main/java/net/helenus/core/operation/InsertOperation.java @@ -145,9 +145,18 @@ public final class InsertOperation extends AbstractOperation entities = values.stream().map(t -> t._1.getProperty().getEntity()).distinct().collect(Collectors.toList()); - if (entities.size() == 0) { - throw new HelenusMappingException("you can insert only single entity, found: " - + entities.stream().map(e -> e.getMappingInterface().toString()).collect(Collectors.joining(", "))); + if (entities.size() != 1) { + throw new HelenusMappingException("you can insert only single entity at a time, found: " + + entities.stream().map(e -> e.getMappingInterface().toString()).collect(Collectors.joining(", "))); + } + HelenusEntity entity = entities.get(0); + if (this.entity != null) { + if (this.entity != entity) { + throw new HelenusMappingException("you can insert only single entity at a time, found: " + + this.entity.getMappingInterface().toString() + ", " + entity.getMappingInterface().toString()); + } + } else { + this.entity = entity; } if (values.isEmpty()) return null; @@ -237,6 +246,7 @@ public final class InsertOperation extends AbstractOperation extends AbstractOperation iface = entity.getMappingInterface(); if (resultType == iface) { - adjustTtlAndWriteTime((MapExportable)result); + if (entity != null && MapExportable.class.isAssignableFrom(entity.getMappingInterface())) { + adjustTtlAndWriteTime((MapExportable) result); + } cacheUpdate(uow, result, bindFacetValues()); } else { if (entity.isCacheable()) {