Search in sources :

Example 91 with ODocument

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

the class OCommandSQLPojoWrapper method execute.

@SuppressWarnings("unchecked")
public <RET> RET execute(Object... iArgs) {
    database.convertParameters(iArgs);
    Object result = command.execute(iArgs);
    if (result instanceof Collection<?>) {
        final List<Object> resultPojo = new ArrayList<Object>();
        Object obj;
        Collection<ODocument> coll = (Collection<ODocument>) result;
        for (ODocument doc : coll) {
            // GET THE ASSOCIATED DOCUMENT
            if (doc.getClassName() == null)
                obj = doc;
            else
                // CONVERT THE DOCUMENT INSIDE THE LIST
                obj = database.getUserObjectByRecord(doc, getFetchPlan(), true);
            resultPojo.add(obj);
        }
        result = resultPojo;
    } else if (result instanceof ODocument) {
        if (((ODocument) result).getClassName() != null)
            // CONVERT THE SINGLE DOCUMENT
            result = database.getUserObjectByRecord((ODocument) result, getFetchPlan(), true);
    }
    return (RET) result;
}
Also used : ArrayList(java.util.ArrayList) Collection(java.util.Collection) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 92 with ODocument

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

the class ODatabasePojoAbstract method unsetDirty.

/**
   * Sets as not dirty a POJO. This is useful when you change some other object and need to tell to the engine to treat this one as
   * not dirty.
   * 
   * @param iPojo
   *          User object
   */
public void unsetDirty(final Object iPojo) {
    if (iPojo == null)
        return;
    final ODocument record = getRecordByUserObject(iPojo, false);
    if (record == null)
        return;
    ORecordInternal.unsetDirty(record);
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 93 with ODocument

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

the class ODatabasePojoAbstract method attach.

public void attach(final Object iPojo) {
    checkOpeness();
    final ODocument record = objects2Records.get(iPojo);
    if (record != null)
        return;
    if (OObjectSerializerHelper.hasObjectID(iPojo)) {
    } else {
        throw new OObjectNotDetachedException("Cannot attach a non-detached object");
    }
}
Also used : ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 94 with ODocument

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

the class DocumentEmbeddedTest method embeddedTx.

@Test
public void embeddedTx() {
    ODocument doc = new ODocument("City");
    db.begin();
    doc.field("name", "Berlin");
    db.save(doc);
    db.commit();
    List<ODocument> results = db.command(new OCommandSQL("select from City where name lucene 'Berlin'")).execute();
    Assert.assertEquals(results.size(), 1);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 95 with ODocument

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

the class DocumentEmbeddedTest method embeddedNoTx.

@Test
public void embeddedNoTx() {
    ODocument doc = new ODocument("City");
    doc.field("name", "London");
    db.save(doc);
    doc = new ODocument("City");
    doc.field("name", "Rome");
    db.save(doc);
    List<ODocument> results = db.command(new OCommandSQL("select from City where name lucene 'London'")).execute();
    Assert.assertEquals(results.size(), 1);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2200 Test (org.testng.annotations.Test)651 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)426 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)422 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)277 Test (org.junit.Test)267 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)257 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)244 ORID (com.orientechnologies.orient.core.id.ORID)196 ORecordId (com.orientechnologies.orient.core.id.ORecordId)139 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)122 ArrayList (java.util.ArrayList)118 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)103 HashMap (java.util.HashMap)103 HashSet (java.util.HashSet)96 ORecord (com.orientechnologies.orient.core.record.ORecord)80 Set (java.util.Set)76 OETLBaseTest (com.orientechnologies.orient.etl.OETLBaseTest)75 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)68 Collection (java.util.Collection)55