From fcbc6eda5fcdf7baa84e1310d9d0117d4d449b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Darri=20Sigur=C3=B0sson?= Date: Tue, 12 Sep 2023 20:15:30 +0200 Subject: [PATCH] Merge fix --- .../db/http/HttpEntityConnectionJdk.java | 22 +++++++++++++++++++ .../framework/servlet/EntityService.java | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/framework/db-http/src/main/java/is/codion/framework/db/http/HttpEntityConnectionJdk.java b/framework/db-http/src/main/java/is/codion/framework/db/http/HttpEntityConnectionJdk.java index c474fe9f3a..13be59aacd 100644 --- a/framework/db-http/src/main/java/is/codion/framework/db/http/HttpEntityConnectionJdk.java +++ b/framework/db-http/src/main/java/is/codion/framework/db/http/HttpEntityConnectionJdk.java @@ -275,6 +275,11 @@ public Entity.Key insert(Entity entity) throws DatabaseException { return insert(singletonList(entity)).iterator().next(); } + @Override + public Entity insertSelect(Entity entity) throws DatabaseException { + return insertSelect(singletonList(entity)).iterator().next(); + } + @Override public Collection insert(Collection entities) throws DatabaseException { Objects.requireNonNull(entities); @@ -292,6 +297,23 @@ public Collection insert(Collection entities) thro } } + @Override + public Collection insertSelect(Collection entities) throws DatabaseException { + Objects.requireNonNull(entities); + try { + synchronized (this.entities) { + return handleResponse(execute(createRequest("insertSelect", entities))); + } + } + catch (DatabaseException e) { + throw e; + } + catch (Exception e) { + LOG.error(e.getMessage(), e); + throw new RuntimeException(e); + } + } + @Override public void update(Entity entity) throws DatabaseException { update(singletonList(Objects.requireNonNull(entity, "entity"))); diff --git a/framework/servlet/src/main/java/is/codion/framework/servlet/EntityService.java b/framework/servlet/src/main/java/is/codion/framework/servlet/EntityService.java index de015c451e..0e3f44d0bb 100644 --- a/framework/servlet/src/main/java/is/codion/framework/servlet/EntityService.java +++ b/framework/servlet/src/main/java/is/codion/framework/servlet/EntityService.java @@ -681,7 +681,7 @@ private final class InsertSelectHandler implements Handler { public void handle(Context context) { try { RemoteEntityConnection connection = authenticate(context); - Collection entities = connection.insertSelect((Collection) deserialize(context.req)); + Collection entities = connection.insertSelect((Collection) deserialize(context.req())); context.status(HttpStatus.OK_200) .contentType(ContentType.APPLICATION_OCTET_STREAM) .result(Serializer.serialize(entities)); @@ -718,7 +718,7 @@ public void handle(Context context) { try { RemoteEntityConnection connection = authenticate(context); EntityObjectMapper mapper = entityObjectMapper(connection.entities()); - Collection entities = mapper.deserializeEntities(context.req.getInputStream()); + Collection entities = mapper.deserializeEntities(context.req().getInputStream()); Collection inserted = connection.insertSelect(entities); context.status(HttpStatus.OK_200) .contentType(ContentType.APPLICATION_JSON)