diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/message/ORemoteResultSet.java b/client/src/main/java/com/orientechnologies/orient/client/remote/message/ORemoteResultSet.java index 77d027d9be7..61acccbb7a6 100644 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/message/ORemoteResultSet.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/message/ORemoteResultSet.java @@ -1,6 +1,7 @@ package com.orientechnologies.orient.client.remote.message; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentRemote; +import com.orientechnologies.orient.core.record.ORecord; import com.orientechnologies.orient.core.sql.executor.OExecutionPlan; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultInternal; @@ -63,7 +64,16 @@ public OResult next() { if (currentPage.isEmpty()) { throw new IllegalStateException(); } - return currentPage.remove(0); + OResultInternal internal = currentPage.remove(0); + + if (internal.isRecord() && db.getTransaction().isActive()) { + ORecord record = db.getTransaction().getRecord(internal.getRecord().get().getIdentity()); + if (record != null) { + internal = new OResultInternal(record); + } + } + return internal; + } @Override diff --git a/server/src/test/java/com/orientechnologies/orient/server/query/RemoteQuerySupportTest.java b/server/src/test/java/com/orientechnologies/orient/server/query/RemoteQuerySupportTest.java index 1e968df6ce0..9258376c216 100755 --- a/server/src/test/java/com/orientechnologies/orient/server/query/RemoteQuerySupportTest.java +++ b/server/src/test/java/com/orientechnologies/orient/server/query/RemoteQuerySupportTest.java @@ -9,12 +9,15 @@ import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.exception.ODatabaseException; import com.orientechnologies.orient.core.metadata.schema.OType; +import com.orientechnologies.orient.core.record.ORecord; +import com.orientechnologies.orient.core.record.OVertex; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; import com.orientechnologies.orient.server.OClientConnection; import com.orientechnologies.orient.server.OServer; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -215,6 +218,25 @@ public void testQueryEmbeddedMap() { assertEquals(((Map) item.getProperty("map")).get("key").getProperty("one"), "value"); } + @Test + public void testCommandWithTX() { + + session.begin(); + + session.command("insert into Some set prop = 'value'"); + + ORecord record; + + try (OResultSet resultSet = session.command("insert into Some set prop = 'value'")) { + record = resultSet.next().getRecord().get(); + } + + session.commit(); + + Assert.assertTrue(record.getIdentity().isPersistent()); + + } + @After public void after() { QUERY_REMOTE_RESULTSET_PAGE_SIZE.setValue(oldPageSize);