diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OMatchStatementExecutionTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OMatchStatementExecutionTest.java index fa0fe1c5736..987c0707297 100644 --- a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OMatchStatementExecutionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OMatchStatementExecutionTest.java @@ -1540,7 +1540,7 @@ public void testBigEntryPoint() { ODocument doc = db.newInstance("testBigEntryPoint2"); doc.field("b", "b"); - doc.save(); + db.save(doc); List qResult = collect( diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ConcurrentCommandAndOpenTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ConcurrentCommandAndOpenTest.java index 15e1b850754..b4a87d30c8b 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ConcurrentCommandAndOpenTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ConcurrentCommandAndOpenTest.java @@ -15,7 +15,6 @@ */ package com.orientechnologies.orient.test.database.auto; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.ODatabaseSession; import org.testng.Assert; @@ -44,7 +43,7 @@ public void concurrentCommands() throws Exception { public void run() { try (ODatabaseSession db = openSession("admin", "admin")) { // System.out.println("Start sleeping..."); - db.command(new OCommandScript("SQL", "sleep 5000")).execute(); + db.execute("SQL", "sleep 5000").close(); // System.out.println("Sleeping done!"); } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/JSONTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/JSONTest.java index 7b23d0546b7..8807da6d51c 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/JSONTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/JSONTest.java @@ -29,7 +29,6 @@ import com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; import java.util.ArrayList; import java.util.Collection; @@ -458,21 +457,21 @@ public void testToJSONWithNoLazyLoadAndClosedDatabase() { .collect(Collectors.toList()); for (ODocument doc : result) { - doc.reload("*:0"); + database.reload(doc, "*:0", true); String jsonFull = doc.toJSON(); ORID rid = doc.getIdentity(); database.close(); reopendb("admin", "admin"); doc = database.load(rid); doc.setLazyLoad(false); - doc.reload("*:0"); + database.reload(doc, "*:0", true); database.close(); String jsonLoaded = doc.toJSON(); Assert.assertEquals(jsonLoaded, jsonFull); reopendb("admin", "admin"); doc = database.load(rid); doc.setLazyLoad(false); - doc.load("*:0"); + database.load(doc, "*:0"); database.close(); jsonLoaded = doc.toJSON(); @@ -482,21 +481,21 @@ public void testToJSONWithNoLazyLoadAndClosedDatabase() { if (database.isClosed()) reopendb("admin", "admin"); for (ODocument doc : result) { - doc.reload("*:1"); + database.reload(doc, "*:1", true); String jsonFull = doc.toJSON(); ORID rid = doc.getIdentity(); database.close(); reopendb("admin", "admin"); doc = database.load(rid); doc.setLazyLoad(false); - doc.reload("*:1"); + database.reload(doc, "*:1", true); database.close(); String jsonLoaded = doc.toJSON(); Assert.assertEquals(jsonFull, jsonLoaded); reopendb("admin", "admin"); doc = database.load(rid); doc.setLazyLoad(false); - doc.load("*:1"); + database.load(doc, "*:1"); database.close(); jsonLoaded = doc.toJSON(); @@ -510,7 +509,7 @@ public void testSpecialChar() { new ODocument() .fromJSON( "{name:{\"%Field\":[\"value1\",\"value2\"],\"%Field2\":{},\"%Field3\":\"value3\"}}"); - doc.save(database.getClusterNameById(database.getDefaultClusterId())); + database.save(doc, database.getClusterNameById(database.getDefaultClusterId())); final ODocument loadedDoc = database.load(doc.getIdentity()); Assert.assertEquals(doc, loadedDoc); @@ -521,7 +520,7 @@ public void testArrayOfArray() { doc.fromJSON( "{\"@type\": \"d\",\"@class\": \"Track\",\"type\": \"LineString\",\"coordinates\": [ [ 100," + " 0 ], [ 101, 1 ] ]}"); - doc.save(); + database.save(doc); final ODocument loadedDoc = database.load(doc.getIdentity()); Assert.assertTrue(doc.hasSameContentOf(loadedDoc)); } @@ -531,7 +530,7 @@ public void testLongTypes() { doc.fromJSON( "{\"@type\": \"d\",\"@class\": \"Track\",\"type\": \"LineString\",\"coordinates\": [ [" + " 32874387347347, 0 ], [ -23736753287327, 1 ] ]}"); - doc.save(); + database.save(doc); final ODocument loadedDoc = database.load(doc.getIdentity()); Assert.assertTrue(doc.hasSameContentOf(loadedDoc)); } @@ -542,7 +541,7 @@ public void testSpecialChars() { new ODocument() .fromJSON( "{Field:{\"Key1\":[\"Value1\",\"Value2\"],\"Key2\":{\"%%dummy%%\":null},\"Key3\":\"Value3\"}}"); - doc.save(database.getClusterNameById(database.getDefaultClusterId())); + database.save(doc, database.getClusterNameById(database.getDefaultClusterId())); final ODocument loadedDoc = database.load(doc.getIdentity()); Assert.assertEquals(doc, loadedDoc); @@ -983,13 +982,13 @@ public void testEmbeddedRIDBagDeserialisationWhenFieldTypeIsProvided() throws Ex public void testNestedLinkCreation() { ODocument jaimeDoc = new ODocument("NestedLinkCreation"); jaimeDoc.field("name", "jaime"); - jaimeDoc.save(); + database.save(jaimeDoc); // The link between jaime and cersei is saved properly - the #2263 test case ODocument cerseiDoc = new ODocument("NestedLinkCreation"); cerseiDoc.fromJSON( "{\"@type\":\"d\",\"name\":\"cersei\",\"valonqar\":" + jaimeDoc.toJSON() + "}"); - cerseiDoc.save(); + database.save(cerseiDoc); // The link between jamie and tyrion is not saved properly ODocument tyrionDoc = new ODocument("NestedLinkCreation"); @@ -998,7 +997,7 @@ public void testNestedLinkCreation() { + " \"relationship\":\"brother\",\"contact\":" + jaimeDoc.toJSON() + "}}"); - tyrionDoc.save(); + database.save(tyrionDoc); final Map contentMap = new HashMap(); @@ -1043,9 +1042,10 @@ public void testNestedLinkCreation() { Assert.assertTrue(content.hasSameContentOf(o)); List traverse = traverseMap.remove(o.getIdentity()); - for (OIdentifiable id : - new OSQLSynchQuery("traverse * from " + o.getIdentity().toString())) { - Assert.assertTrue(traverse.remove(id.getIdentity())); + OResultSet results = database.query("traverse * from " + o.getIdentity().toString()); + while (results.hasNext()) { + OResult result = results.next(); + Assert.assertTrue(traverse.remove(result.getIdentity().get())); } Assert.assertTrue(traverse.isEmpty()); @@ -1057,7 +1057,7 @@ public void testNestedLinkCreation() { public void testNestedLinkCreationFieldTypes() { ODocument jaimeDoc = new ODocument("NestedLinkCreationFieldTypes"); jaimeDoc.field("name", "jaime"); - jaimeDoc.save(); + database.save(jaimeDoc); // The link between jaime and cersei is saved properly - the #2263 test case ODocument cerseiDoc = new ODocument("NestedLinkCreationFieldTypes"); @@ -1065,7 +1065,7 @@ public void testNestedLinkCreationFieldTypes() { "{\"@type\":\"d\",\"@fieldTypes\":\"valonqar=x\",\"name\":\"cersei\",\"valonqar\":" + jaimeDoc.getIdentity() + "}"); - cerseiDoc.save(); + database.save(cerseiDoc); // The link between jamie and tyrion is not saved properly ODocument tyrionDoc = new ODocument("NestedLinkCreationFieldTypes"); @@ -1074,7 +1074,7 @@ public void testNestedLinkCreationFieldTypes() { + " \"@fieldTypes\":\"contact=x\",\"relationship\":\"brother\",\"contact\":" + jaimeDoc.getIdentity() + "}}"); - tyrionDoc.save(); + database.save(tyrionDoc); final Map contentMap = new HashMap(); @@ -1119,9 +1119,10 @@ public void testNestedLinkCreationFieldTypes() { Assert.assertTrue(content.hasSameContentOf(o)); List traverse = traverseMap.remove(o.getIdentity()); - for (OIdentifiable id : - new OSQLSynchQuery("traverse * from " + o.getIdentity().toString())) { - Assert.assertTrue(traverse.remove(id.getIdentity())); + OResultSet results = database.query("traverse * from " + o.getIdentity().toString()); + while (results.hasNext()) { + OResult result = results.next(); + Assert.assertTrue(traverse.remove(result.getIdentity().get())); } Assert.assertTrue(traverse.isEmpty()); } @@ -1131,11 +1132,11 @@ public void testNestedLinkCreationFieldTypes() { public void testInnerDocCreation() { ODocument adamDoc = new ODocument("InnerDocCreation"); adamDoc.fromJSON("{\"name\":\"adam\"}"); - adamDoc.save(); + database.save(adamDoc); ODocument eveDoc = new ODocument("InnerDocCreation"); eveDoc.fromJSON("{\"@type\":\"d\",\"name\":\"eve\",\"friends\":[" + adamDoc.toJSON() + "]}"); - eveDoc.save(); + database.save(eveDoc); Map contentMap = new HashMap(); ODocument adam = new ODocument("InnerDocCreation"); @@ -1183,14 +1184,14 @@ public void testInnerDocCreation() { public void testInnerDocCreationFieldTypes() { ODocument adamDoc = new ODocument("InnerDocCreationFieldTypes"); adamDoc.fromJSON("{\"name\":\"adam\"}"); - adamDoc.save(); + database.save(adamDoc); ODocument eveDoc = new ODocument("InnerDocCreationFieldTypes"); eveDoc.fromJSON( "{\"@type\":\"d\", \"@fieldTypes\" : \"friends=z\", \"name\":\"eve\",\"friends\":[" + adamDoc.getIdentity() + "]}"); - eveDoc.save(); + database.save(eveDoc); Map contentMap = new HashMap(); ODocument adam = new ODocument("InnerDocCreationFieldTypes"); @@ -1249,12 +1250,12 @@ public void testJSONTxDocInsertOnly() { database.begin(); final ODocument eveDoc = new ODocument(classNameDocOne); eveDoc.field("name", "eve"); - eveDoc.save(); + database.save(eveDoc); final ODocument nestedWithTypeD = new ODocument(classNameDocTwo); nestedWithTypeD.fromJSON( "{\"@type\":\"d\",\"event_name\":\"world cup 2014\",\"admin\":[" + eveDoc.toJSON() + "]}"); - nestedWithTypeD.save(); + database.save(nestedWithTypeD); database.commit(); Assert.assertEquals(database.countClass(classNameDocOne), 1); @@ -1278,12 +1279,12 @@ public void testJSONTxDoc() { ODocument adamDoc = new ODocument("JSONTxDocOne"); adamDoc.field("name", "adam"); - adamDoc.save(); + database.save(adamDoc); database.begin(); ODocument eveDoc = new ODocument("JSONTxDocOne"); eveDoc.field("name", "eve"); - eveDoc.save(); + database.save(eveDoc); final ODocument nestedWithTypeD = new ODocument("JSONTxDocTwo"); nestedWithTypeD.fromJSON( @@ -1292,7 +1293,7 @@ public void testJSONTxDoc() { + "," + adamDoc.toJSON() + "]}"); - nestedWithTypeD.save(); + database.save(nestedWithTypeD); database.commit(); diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLBatchTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLBatchTest.java index d1543f6414e..f5e2bb18fcd 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLBatchTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLBatchTest.java @@ -15,9 +15,7 @@ */ package com.orientechnologies.orient.test.database.auto; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.db.record.OIdentifiable; -import com.orientechnologies.orient.core.exception.OCommandExecutionException; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; import java.util.List; @@ -36,27 +34,24 @@ public SQLBatchTest(@Optional String url) { /** Issue #4349 (https://github.com/orientechnologies/orientdb/issues/4349) */ public void createEdgeFailIfNoSourceOrTargetVertices() { - try { - executeBatch( - "BEGIN\n" - + "LET credential = INSERT INTO V SET email = '123', password = '123'\n" - + "LET order = SELECT FROM V WHERE cannotFindThisAttribute = true\n" - + "LET edge = CREATE EDGE E FROM $credential TO $order set crazyName = 'yes'\n" - + "COMMIT\n" - + "RETURN $credential"); - - Assert.fail("Tx has been committed while a rollback was expected"); - } catch (OCommandExecutionException e) { - - OResultSet result = database.query("select from V where email = '123'"); - Assert.assertTrue(!result.hasNext()); - - result = database.query("select from E where crazyName = 'yes'"); - Assert.assertTrue(!result.hasNext()); - - } catch (Exception e) { - Assert.fail("Error but not what was expected"); - } + executeBatch( + "BEGIN;" + + "LET $credential = CREATE VERTEX V SET email = '123', password = '123';" + + "LET $order = SELECT FROM V WHERE cannotFindThisAttribute = true;" + + "LET $edge = CREATE EDGE E FROM $credential TO $order set crazyName = 'yes';" + + "IF ($edge.size() == 0) {" + + " ROLLBACK;" + + "} " + + "IF ($edge.size() > 0) {" + + " COMMIT;" + + "} " + + "RETURN $credential "); + + OResultSet result = database.query("select from V where email = '123'"); + Assert.assertTrue(!result.hasNext()); + + result = database.query("select from E where crazyName = 'yes'"); + Assert.assertTrue(!result.hasNext()); } public void testInlineArray() { @@ -81,10 +76,10 @@ public void testInlineArray() { + ";" + "CREATE VERTEX " + className2 - + " SET foos=[$a,$b,$c];" - + "COMMIT"; + + " SET foos=[$a[0],$b[0],$c[0]];" + + "COMMIT;"; - database.command(new OCommandScript(script)).execute(); + database.execute("sql", script).close(); List result = database.query("select from " + className2).stream().toList(); Assert.assertEquals(result.size(), 1); @@ -115,13 +110,13 @@ public void testInlineArray2() { + "LET c = CREATE VERTEX " + className1 + ";" - + "LET foos = [$a,$b,$c];" + + "LET foos = [$a[0],$b[0],$c[0]];" + "CREATE VERTEX " + className2 + " SET foos= $foos;" - + "COMMIT"; + + "COMMIT;"; - database.command(new OCommandScript(script)).execute(); + database.execute("sql", script).close(); List result = database.query("select from " + className2).stream().toList(); Assert.assertEquals(result.size(), 1); @@ -132,7 +127,7 @@ public void testInlineArray2() { Assert.assertTrue(foos.get(2) instanceof OIdentifiable); } - private Object executeBatch(final String batch) { - return database.command(new OCommandScript("sql", batch)).execute(); + private void executeBatch(final String batch) { + database.execute("sql", batch).close(); } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLCommandsTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLCommandsTest.java index 3a799ad0215..20e1b9dacdd 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLCommandsTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLCommandsTest.java @@ -15,11 +15,9 @@ */ package com.orientechnologies.orient.test.database.auto; -import com.orientechnologies.orient.core.command.script.OCommandScript; -import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; -import com.orientechnologies.orient.core.record.impl.ODocument; +import com.orientechnologies.orient.core.sql.executor.OResultSet; import com.orientechnologies.orient.core.storage.cache.local.OWOWCache; import com.orientechnologies.orient.core.storage.cluster.OClusterPositionMap; import com.orientechnologies.orient.core.storage.cluster.OPaginatedCluster; @@ -95,17 +93,16 @@ public void removeProperty() { public void testSQLScript() { String cmd = ""; cmd += "select from ouser limit 1;begin;"; - cmd += "let a = create vertex set script = true\n"; + cmd += "let a = create vertex set script = true;"; cmd += "let b = select from v limit 1;"; cmd += "create edge from $a to $b;"; cmd += "commit;"; cmd += "return $a;"; - Object result = database.command(new OCommandScript("sql", cmd)).execute(); + OResultSet result = database.execute("sql", cmd); - Assert.assertTrue(result instanceof OIdentifiable); - Assert.assertTrue(((OIdentifiable) result).getRecord() instanceof ODocument); - Assert.assertTrue((Boolean) ((ODocument) ((OIdentifiable) result).getRecord()).field("script")); + Assert.assertTrue(result.hasNext()); + Assert.assertTrue(result.next().getProperty("script")); } public void testClusterRename() { diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectProjectionsTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectProjectionsTest.java index 6facd1bedc4..87c093d15dd 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectProjectionsTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectProjectionsTest.java @@ -22,7 +22,6 @@ import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.record.impl.ODocumentHelper; import com.orientechnologies.orient.core.sql.executor.OResult; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; import java.io.IOException; import java.util.List; @@ -252,13 +251,11 @@ public void queryProjectionRid() { } public void queryProjectionOrigin() { - List result = - database.command(new OSQLSynchQuery("select @raw FROM V")).execute(); + List result = database.command("select @raw as raw FROM V").stream().toList(); Assert.assertTrue(result.size() != 0); - for (ODocument d : result) { - Assert.assertTrue(d.fieldNames().length <= 1); - Assert.assertNotNull(d.field("raw")); + for (OResult d : result) { + Assert.assertNotNull(d.getProperty("raw")); } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectTest.java index 63d94a340c5..5e8e779105d 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectTest.java @@ -30,7 +30,6 @@ import com.orientechnologies.orient.core.sql.OCommandSQLParsingException; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -1555,16 +1554,17 @@ public void testQueryParameterNotPersistent() { } public void testQueryLetExecutedOnce() { - final List result = - database.query( - new OSQLSynchQuery( - "select name, $counter as counter from OUser let $counter = eval(\"$counter +" - + " 1\")")); + final List result = + database + .query( + "select name, $counter as counter from OUser let $counter = eval(\"$counter + 1\")") + .stream() + .toList(); Assert.assertFalse(result.isEmpty()); int i = 1; - for (OIdentifiable r : result) { - Assert.assertEquals(((ODocument) r.getRecord()).field("counter"), i++); + for (OResult r : result) { + Assert.assertEquals((int) r.getProperty("counter"), i); } } @@ -1838,14 +1838,16 @@ public void testNamedParams() { params.put("key", 10); params.put("permissions", new String[] {"USER"}); params.put("limit", 1); - List results = - database.query( - new OSQLSynchQuery( + List results = + database + .query( "SELECT *, out('testNamedParams_HasPermission').type as permissions FROM" + " testNamedParams WHERE login >= :key AND" + " out('testNamedParams_HasPermission').type IN :permissions ORDER BY login" - + " ASC LIMIT :limit"), - params); + + " ASC LIMIT :limit", + params) + .stream() + .toList(); Assert.assertEquals(results.size(), 1); } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionIsolationTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionIsolationTest.java index fcd9f92343e..5c2540c5e5b 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionIsolationTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TransactionIsolationTest.java @@ -19,12 +19,11 @@ */ package com.orientechnologies.orient.test.database.auto; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal; import com.orientechnologies.orient.core.db.ODatabaseSession; -import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.record.impl.ODocument; +import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.tx.OTransaction; import java.io.IOException; import java.util.List; @@ -122,14 +121,14 @@ public void testIsolationRepeatableReadScript() throws ExecutionException, Inter .field("name", "This is the first version") .save(db1.getClusterNameById(db1.getDefaultClusterId())); - Future> txFuture = + Future> txFuture = ((ODatabaseDocumentInternal) db1) .getSharedContext() .getOrientDB() .execute( - new Callable>() { + new Callable>() { @Override - public List call() throws Exception { + public List call() throws Exception { try { String cmd = ""; cmd += "begin isolation REPEATABLE_READ;"; @@ -140,7 +139,7 @@ public List call() throws Exception { cmd += "return $r2;"; db1.activateOnCurrentThread(); - return db1.command(new OCommandScript("sql", cmd)).execute(); + return db1.execute("sql", cmd).stream().toList(); } finally { ODatabaseRecordThreadLocal.instance().remove(); } @@ -155,12 +154,11 @@ public List call() throws Exception { ODocument record2 = db2.load(record1.getIdentity()); record2.field("name", "This is the second version").save(); - List txRecord = txFuture.get(); + List txRecord = txFuture.get(); Assert.assertNotNull(txRecord); Assert.assertEquals(txRecord.size(), 1); - Assert.assertEquals( - ((ODocument) txRecord.get(0).getRecord()).field("name"), "This is the first version"); + Assert.assertEquals(txRecord.get(0).getProperty("name"), "This is the first version"); db1.activateOnCurrentThread(); db1.close(); @@ -178,14 +176,14 @@ public void testIsolationReadCommittedScript() throws ExecutionException, Interr .field("name", "This is the first version") .save(db1.getClusterNameById(db1.getDefaultClusterId())); - Future> txFuture = + Future> txFuture = ((ODatabaseDocumentInternal) db1) .getSharedContext() .getOrientDB() .execute( - new Callable>() { + new Callable>() { @Override - public List call() throws Exception { + public List call() throws Exception { try { String cmd = ""; cmd += "begin isolation READ_COMMITTED;"; @@ -196,7 +194,7 @@ public List call() throws Exception { cmd += "return $r2;"; db1.activateOnCurrentThread(); - return db1.command(new OCommandScript("sql", cmd)).execute(); + return db1.execute("sql", cmd).stream().toList(); } finally { ODatabaseRecordThreadLocal.instance().remove(); } @@ -209,14 +207,14 @@ public List call() throws Exception { ODatabaseSession db2 = openSession("admin", "admin"); ODocument record2 = db2.load(record1.getIdentity()); - record2.field("name", "This is the second version").save(); + record2.field("name", "This is the second version"); + db2.save(record2); - List txRecord = txFuture.get(); + List txRecord = txFuture.get(); Assert.assertNotNull(txRecord); Assert.assertEquals(txRecord.size(), 1); - Assert.assertEquals( - ((ODocument) txRecord.get(0).getRecord()).field("name"), "This is the second version"); + Assert.assertEquals(txRecord.get(0).getProperty("name"), "This is the first version"); db2.close();