Search in sources :

Example 1 with OrientDBResult

use of org.apache.gora.orientdb.query.OrientDBResult in project gora by apache.

the class OrientDBStore method execute.

/**
 * {@inheritDoc}
 */
@Override
public Result<K, T> execute(Query<K, T> query) throws GoraException {
    String[] fields = getFieldsToQuery(query.getFields());
    OrientDBQuery dataStoreQuery;
    if (query instanceof OrientDBQuery) {
        dataStoreQuery = ((OrientDBQuery) query);
    } else {
        dataStoreQuery = (OrientDBQuery) ((PartitionQueryImpl<K, T>) query).getBaseQuery();
    }
    dataStoreQuery.populateOrientDBQuery(orientDBMapping, fields, getFields());
    try (ODatabaseDocumentTx selectTx = connectionPool.acquire()) {
        selectTx.activateOnCurrentThread();
        OConcurrentResultSet<ODocument> result = selectTx.command(dataStoreQuery.getOrientDBQuery()).execute(dataStoreQuery.getParams());
        result.setLimit((int) query.getLimit());
        return new OrientDBResult<K, T>(this, query, result);
    } catch (Exception e) {
        throw new GoraException(e);
    }
}
Also used : OrientDBQuery(org.apache.gora.orientdb.query.OrientDBQuery) OrientDBResult(org.apache.gora.orientdb.query.OrientDBResult) GoraException(org.apache.gora.util.GoraException) PartitionQueryImpl(org.apache.gora.query.impl.PartitionQueryImpl) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) GoraException(org.apache.gora.util.GoraException) IOException(java.io.IOException) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 IOException (java.io.IOException)1 OrientDBQuery (org.apache.gora.orientdb.query.OrientDBQuery)1 OrientDBResult (org.apache.gora.orientdb.query.OrientDBResult)1 PartitionQueryImpl (org.apache.gora.query.impl.PartitionQueryImpl)1 GoraException (org.apache.gora.util.GoraException)1