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;
}
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);
}
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");
}
}
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);
}
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);
}
Aggregations