Search in sources :

Example 6 with QueryEngine2

use of com.evolveum.midpoint.repo.sql.query2.QueryEngine2 in project midpoint by Evolveum.

the class ObjectRetriever method searchObjectsAttempt.

@NotNull
public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjectsAttempt(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
    LOGGER_PERFORMANCE.debug("> search objects {}", new Object[] { type.getSimpleName() });
    Session session = null;
    try {
        session = baseHelper.beginReadOnlyTransaction();
        RQuery rQuery;
        QueryEngine2 engine = new QueryEngine2(getConfiguration(), prismContext);
        rQuery = engine.interpret(query, type, options, false, session);
        List<GetObjectResult> queryResult = rQuery.list();
        LOGGER.trace("Found {} objects, translating to JAXB.", queryResult != null ? queryResult.size() : 0);
        List<PrismObject<T>> list = queryResultToPrismObjects(queryResult, type, options, session, result);
        session.getTransaction().commit();
        return new SearchResultList<>(list);
    } catch (QueryException | RuntimeException ex) {
        baseHelper.handleGeneralException(ex, session, result);
        throw new IllegalStateException("shouldn't get here");
    } finally {
        baseHelper.cleanupSessionAndResult(session, result);
    }
}
Also used : QueryException(com.evolveum.midpoint.repo.sql.query.QueryException) QueryEngine2(com.evolveum.midpoint.repo.sql.query2.QueryEngine2) RQuery(com.evolveum.midpoint.repo.sql.query.RQuery) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RQuery (com.evolveum.midpoint.repo.sql.query.RQuery)6 QueryEngine2 (com.evolveum.midpoint.repo.sql.query2.QueryEngine2)6 QueryException (com.evolveum.midpoint.repo.sql.query.QueryException)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 NotNull (org.jetbrains.annotations.NotNull)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 RQueryImpl (com.evolveum.midpoint.repo.sql.query2.RQueryImpl)1 QueryParameterValue (com.evolveum.midpoint.repo.sql.query2.hqm.QueryParameterValue)1