29
29
import com .orientechnologies .orient .core .serialization .serializer .record .string .ORecordSerializerSchemaAware2CSV ;
30
30
import com .orientechnologies .orient .core .sql .executor .OResult ;
31
31
import com .orientechnologies .orient .core .sql .executor .OResultSet ;
32
- import com .orientechnologies .orient .core .sql .query .OSQLSynchQuery ;
33
32
import com .orientechnologies .orient .object .db .OObjectDatabaseTx ;
34
33
import java .util .ArrayList ;
35
34
import java .util .Collection ;
@@ -458,21 +457,21 @@ public void testToJSONWithNoLazyLoadAndClosedDatabase() {
458
457
.collect (Collectors .toList ());
459
458
460
459
for (ODocument doc : result ) {
461
- doc .reload ("*:0" );
460
+ database .reload (doc , "*:0" , true );
462
461
String jsonFull = doc .toJSON ();
463
462
ORID rid = doc .getIdentity ();
464
463
database .close ();
465
464
reopendb ("admin" , "admin" );
466
465
doc = database .load (rid );
467
466
doc .setLazyLoad (false );
468
- doc .reload ("*:0" );
467
+ database .reload (doc , "*:0" , true );
469
468
database .close ();
470
469
String jsonLoaded = doc .toJSON ();
471
470
Assert .assertEquals (jsonLoaded , jsonFull );
472
471
reopendb ("admin" , "admin" );
473
472
doc = database .load (rid );
474
473
doc .setLazyLoad (false );
475
- doc .load ("*:0" );
474
+ database .load (doc , "*:0" );
476
475
database .close ();
477
476
jsonLoaded = doc .toJSON ();
478
477
@@ -482,21 +481,21 @@ public void testToJSONWithNoLazyLoadAndClosedDatabase() {
482
481
if (database .isClosed ()) reopendb ("admin" , "admin" );
483
482
484
483
for (ODocument doc : result ) {
485
- doc .reload ("*:1" );
484
+ database .reload (doc , "*:1" , true );
486
485
String jsonFull = doc .toJSON ();
487
486
ORID rid = doc .getIdentity ();
488
487
database .close ();
489
488
reopendb ("admin" , "admin" );
490
489
doc = database .load (rid );
491
490
doc .setLazyLoad (false );
492
- doc .reload ("*:1" );
491
+ database .reload (doc , "*:1" , true );
493
492
database .close ();
494
493
String jsonLoaded = doc .toJSON ();
495
494
Assert .assertEquals (jsonFull , jsonLoaded );
496
495
reopendb ("admin" , "admin" );
497
496
doc = database .load (rid );
498
497
doc .setLazyLoad (false );
499
- doc .load ("*:1" );
498
+ database .load (doc , "*:1" );
500
499
database .close ();
501
500
jsonLoaded = doc .toJSON ();
502
501
@@ -510,7 +509,7 @@ public void testSpecialChar() {
510
509
new ODocument ()
511
510
.fromJSON (
512
511
"{name:{\" %Field\" :[\" value1\" ,\" value2\" ],\" %Field2\" :{},\" %Field3\" :\" value3\" }}" );
513
- doc .save (database .getClusterNameById (database .getDefaultClusterId ()));
512
+ database .save (doc , database .getClusterNameById (database .getDefaultClusterId ()));
514
513
515
514
final ODocument loadedDoc = database .load (doc .getIdentity ());
516
515
Assert .assertEquals (doc , loadedDoc );
@@ -521,7 +520,7 @@ public void testArrayOfArray() {
521
520
doc .fromJSON (
522
521
"{\" @type\" : \" d\" ,\" @class\" : \" Track\" ,\" type\" : \" LineString\" ,\" coordinates\" : [ [ 100,"
523
522
+ " 0 ], [ 101, 1 ] ]}" );
524
- doc .save ();
523
+ database .save (doc );
525
524
final ODocument loadedDoc = database .load (doc .getIdentity ());
526
525
Assert .assertTrue (doc .hasSameContentOf (loadedDoc ));
527
526
}
@@ -531,7 +530,7 @@ public void testLongTypes() {
531
530
doc .fromJSON (
532
531
"{\" @type\" : \" d\" ,\" @class\" : \" Track\" ,\" type\" : \" LineString\" ,\" coordinates\" : [ ["
533
532
+ " 32874387347347, 0 ], [ -23736753287327, 1 ] ]}" );
534
- doc .save ();
533
+ database .save (doc );
535
534
final ODocument loadedDoc = database .load (doc .getIdentity ());
536
535
Assert .assertTrue (doc .hasSameContentOf (loadedDoc ));
537
536
}
@@ -542,7 +541,7 @@ public void testSpecialChars() {
542
541
new ODocument ()
543
542
.fromJSON (
544
543
"{Field:{\" Key1\" :[\" Value1\" ,\" Value2\" ],\" Key2\" :{\" %%dummy%%\" :null},\" Key3\" :\" Value3\" }}" );
545
- doc .save (database .getClusterNameById (database .getDefaultClusterId ()));
544
+ database .save (doc , database .getClusterNameById (database .getDefaultClusterId ()));
546
545
547
546
final ODocument loadedDoc = database .load (doc .getIdentity ());
548
547
Assert .assertEquals (doc , loadedDoc );
@@ -983,13 +982,13 @@ public void testEmbeddedRIDBagDeserialisationWhenFieldTypeIsProvided() throws Ex
983
982
public void testNestedLinkCreation () {
984
983
ODocument jaimeDoc = new ODocument ("NestedLinkCreation" );
985
984
jaimeDoc .field ("name" , "jaime" );
986
- jaimeDoc .save ();
985
+ database .save (jaimeDoc );
987
986
988
987
// The link between jaime and cersei is saved properly - the #2263 test case
989
988
ODocument cerseiDoc = new ODocument ("NestedLinkCreation" );
990
989
cerseiDoc .fromJSON (
991
990
"{\" @type\" :\" d\" ,\" name\" :\" cersei\" ,\" valonqar\" :" + jaimeDoc .toJSON () + "}" );
992
- cerseiDoc .save ();
991
+ database .save (cerseiDoc );
993
992
994
993
// The link between jamie and tyrion is not saved properly
995
994
ODocument tyrionDoc = new ODocument ("NestedLinkCreation" );
@@ -998,7 +997,7 @@ public void testNestedLinkCreation() {
998
997
+ " \" relationship\" :\" brother\" ,\" contact\" :"
999
998
+ jaimeDoc .toJSON ()
1000
999
+ "}}" );
1001
- tyrionDoc .save ();
1000
+ database .save (tyrionDoc );
1002
1001
1003
1002
final Map <ORID , ODocument > contentMap = new HashMap <ORID , ODocument >();
1004
1003
@@ -1043,9 +1042,10 @@ public void testNestedLinkCreation() {
1043
1042
Assert .assertTrue (content .hasSameContentOf (o ));
1044
1043
1045
1044
List <ORID > traverse = traverseMap .remove (o .getIdentity ());
1046
- for (OIdentifiable id :
1047
- new OSQLSynchQuery <ODocument >("traverse * from " + o .getIdentity ().toString ())) {
1048
- Assert .assertTrue (traverse .remove (id .getIdentity ()));
1045
+ OResultSet results = database .query ("traverse * from " + o .getIdentity ().toString ());
1046
+ while (results .hasNext ()) {
1047
+ OResult result = results .next ();
1048
+ Assert .assertTrue (traverse .remove (result .getIdentity ().get ()));
1049
1049
}
1050
1050
1051
1051
Assert .assertTrue (traverse .isEmpty ());
@@ -1057,15 +1057,15 @@ public void testNestedLinkCreation() {
1057
1057
public void testNestedLinkCreationFieldTypes () {
1058
1058
ODocument jaimeDoc = new ODocument ("NestedLinkCreationFieldTypes" );
1059
1059
jaimeDoc .field ("name" , "jaime" );
1060
- jaimeDoc .save ();
1060
+ database .save (jaimeDoc );
1061
1061
1062
1062
// The link between jaime and cersei is saved properly - the #2263 test case
1063
1063
ODocument cerseiDoc = new ODocument ("NestedLinkCreationFieldTypes" );
1064
1064
cerseiDoc .fromJSON (
1065
1065
"{\" @type\" :\" d\" ,\" @fieldTypes\" :\" valonqar=x\" ,\" name\" :\" cersei\" ,\" valonqar\" :"
1066
1066
+ jaimeDoc .getIdentity ()
1067
1067
+ "}" );
1068
- cerseiDoc .save ();
1068
+ database .save (cerseiDoc );
1069
1069
1070
1070
// The link between jamie and tyrion is not saved properly
1071
1071
ODocument tyrionDoc = new ODocument ("NestedLinkCreationFieldTypes" );
@@ -1074,7 +1074,7 @@ public void testNestedLinkCreationFieldTypes() {
1074
1074
+ " \" @fieldTypes\" :\" contact=x\" ,\" relationship\" :\" brother\" ,\" contact\" :"
1075
1075
+ jaimeDoc .getIdentity ()
1076
1076
+ "}}" );
1077
- tyrionDoc .save ();
1077
+ database .save (tyrionDoc );
1078
1078
1079
1079
final Map <ORID , ODocument > contentMap = new HashMap <ORID , ODocument >();
1080
1080
@@ -1119,9 +1119,10 @@ public void testNestedLinkCreationFieldTypes() {
1119
1119
Assert .assertTrue (content .hasSameContentOf (o ));
1120
1120
1121
1121
List <ORID > traverse = traverseMap .remove (o .getIdentity ());
1122
- for (OIdentifiable id :
1123
- new OSQLSynchQuery <ODocument >("traverse * from " + o .getIdentity ().toString ())) {
1124
- Assert .assertTrue (traverse .remove (id .getIdentity ()));
1122
+ OResultSet results = database .query ("traverse * from " + o .getIdentity ().toString ());
1123
+ while (results .hasNext ()) {
1124
+ OResult result = results .next ();
1125
+ Assert .assertTrue (traverse .remove (result .getIdentity ().get ()));
1125
1126
}
1126
1127
Assert .assertTrue (traverse .isEmpty ());
1127
1128
}
@@ -1131,11 +1132,11 @@ public void testNestedLinkCreationFieldTypes() {
1131
1132
public void testInnerDocCreation () {
1132
1133
ODocument adamDoc = new ODocument ("InnerDocCreation" );
1133
1134
adamDoc .fromJSON ("{\" name\" :\" adam\" }" );
1134
- adamDoc .save ();
1135
+ database .save (adamDoc );
1135
1136
1136
1137
ODocument eveDoc = new ODocument ("InnerDocCreation" );
1137
1138
eveDoc .fromJSON ("{\" @type\" :\" d\" ,\" name\" :\" eve\" ,\" friends\" :[" + adamDoc .toJSON () + "]}" );
1138
- eveDoc .save ();
1139
+ database .save (eveDoc );
1139
1140
1140
1141
Map <ORID , ODocument > contentMap = new HashMap <ORID , ODocument >();
1141
1142
ODocument adam = new ODocument ("InnerDocCreation" );
@@ -1183,14 +1184,14 @@ public void testInnerDocCreation() {
1183
1184
public void testInnerDocCreationFieldTypes () {
1184
1185
ODocument adamDoc = new ODocument ("InnerDocCreationFieldTypes" );
1185
1186
adamDoc .fromJSON ("{\" name\" :\" adam\" }" );
1186
- adamDoc .save ();
1187
+ database .save (adamDoc );
1187
1188
1188
1189
ODocument eveDoc = new ODocument ("InnerDocCreationFieldTypes" );
1189
1190
eveDoc .fromJSON (
1190
1191
"{\" @type\" :\" d\" , \" @fieldTypes\" : \" friends=z\" , \" name\" :\" eve\" ,\" friends\" :["
1191
1192
+ adamDoc .getIdentity ()
1192
1193
+ "]}" );
1193
- eveDoc .save ();
1194
+ database .save (eveDoc );
1194
1195
1195
1196
Map <ORID , ODocument > contentMap = new HashMap <ORID , ODocument >();
1196
1197
ODocument adam = new ODocument ("InnerDocCreationFieldTypes" );
@@ -1249,12 +1250,12 @@ public void testJSONTxDocInsertOnly() {
1249
1250
database .begin ();
1250
1251
final ODocument eveDoc = new ODocument (classNameDocOne );
1251
1252
eveDoc .field ("name" , "eve" );
1252
- eveDoc .save ();
1253
+ database .save (eveDoc );
1253
1254
1254
1255
final ODocument nestedWithTypeD = new ODocument (classNameDocTwo );
1255
1256
nestedWithTypeD .fromJSON (
1256
1257
"{\" @type\" :\" d\" ,\" event_name\" :\" world cup 2014\" ,\" admin\" :[" + eveDoc .toJSON () + "]}" );
1257
- nestedWithTypeD .save ();
1258
+ database .save (nestedWithTypeD );
1258
1259
database .commit ();
1259
1260
Assert .assertEquals (database .countClass (classNameDocOne ), 1 );
1260
1261
@@ -1278,12 +1279,12 @@ public void testJSONTxDoc() {
1278
1279
1279
1280
ODocument adamDoc = new ODocument ("JSONTxDocOne" );
1280
1281
adamDoc .field ("name" , "adam" );
1281
- adamDoc .save ();
1282
+ database .save (adamDoc );
1282
1283
1283
1284
database .begin ();
1284
1285
ODocument eveDoc = new ODocument ("JSONTxDocOne" );
1285
1286
eveDoc .field ("name" , "eve" );
1286
- eveDoc .save ();
1287
+ database .save (eveDoc );
1287
1288
1288
1289
final ODocument nestedWithTypeD = new ODocument ("JSONTxDocTwo" );
1289
1290
nestedWithTypeD .fromJSON (
@@ -1292,7 +1293,7 @@ public void testJSONTxDoc() {
1292
1293
+ ","
1293
1294
+ adamDoc .toJSON ()
1294
1295
+ "]}" );
1295
- nestedWithTypeD .save ();
1296
+ database .save (nestedWithTypeD );
1296
1297
1297
1298
database .commit ();
1298
1299
0 commit comments