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()) {