Search in sources :

Example 6 with ORecordAbstract

use of com.orientechnologies.orient.core.record.ORecordAbstract in project orientdb by orientechnologies.

the class CRUDDocumentPhysicalTest method nonPolymorphicQuery.

@Test(dependsOnMethods = "testCreate")
public void nonPolymorphicQuery() {
    final ORecordAbstract newAccount = new ODocument("Account").field("name", "testInheritanceName").save();
    List<ODocument> allResult = database.query(new OSQLSynchQuery<ODocument>("select from Account"));
    List<ODocument> superClassResult = database.query(new OSQLSynchQuery<ODocument>("select from Account where @class = 'Account'"));
    List<ODocument> subClassResult = database.query(new OSQLSynchQuery<ODocument>("select from Company where @class = 'Company'"));
    Assert.assertTrue(allResult.size() != 0);
    Assert.assertTrue(superClassResult.size() != 0);
    Assert.assertTrue(subClassResult.size() != 0);
    // VERIFY ALL THE SUBCLASS RESULT ARE NOT CONTAINED IN SUPERCLASS RESULT
    for (ODocument d : subClassResult) {
        Assert.assertFalse(superClassResult.contains(d));
    }
    HashSet<ODocument> browsed = new HashSet<ODocument>();
    for (ODocument d : database.browseClass("Account")) {
        Assert.assertFalse(browsed.contains(d));
        browsed.add(d);
    }
    newAccount.delete();
}
Also used : ORecordAbstract(com.orientechnologies.orient.core.record.ORecordAbstract) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

ORecordAbstract (com.orientechnologies.orient.core.record.ORecordAbstract)6 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)6 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 HashSet (java.util.HashSet)2 Test (org.testng.annotations.Test)2 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)1 ORecordLazyMap (com.orientechnologies.orient.core.db.record.ORecordLazyMap)1 OTrackedMap (com.orientechnologies.orient.core.db.record.OTrackedMap)1 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)1 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)1 OBlob (com.orientechnologies.orient.core.record.impl.OBlob)1 ORawBuffer (com.orientechnologies.orient.core.storage.ORawBuffer)1 OObjectLazyMap (com.orientechnologies.orient.object.db.OObjectLazyMap)1 OObjectEnumLazyMap (com.orientechnologies.orient.object.enumerations.OObjectEnumLazyMap)1 OObjectCustomSerializerMap (com.orientechnologies.orient.object.serialization.OObjectCustomSerializerMap)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1