Search in sources :

Example 1 with StoredQuery

use of io.micronaut.data.model.runtime.StoredQuery in project micronaut-data by micronaut-projects.

the class AbstractQueryInterceptor method prepareCountQuery.

/**
 * Prepares a query for the given context.
 *
 * @param methodKey The method key
 * @param context   The context
 * @return The query
 */
protected final PreparedQuery<?, Number> prepareCountQuery(RepositoryMethodKey methodKey, @NonNull MethodInvocationContext<T, R> context) {
    StoredQuery storedQuery = countQueries.get(methodKey);
    if (storedQuery == null) {
        Class rootEntity = getRequiredRootEntity(context);
        storedQuery = storedQueryResolver.resolveCountQuery(context, rootEntity, Long.class);
        countQueries.put(methodKey, storedQuery);
    }
    Pageable pageable = storedQuery.hasPageable() ? getPageable(context) : Pageable.UNPAGED;
    // noinspection unchecked
    return preparedQueryResolver.resolveCountQuery(context, storedQuery, pageable);
}
Also used : StoredQuery(io.micronaut.data.model.runtime.StoredQuery) Pageable(io.micronaut.data.model.Pageable)

Aggregations

Pageable (io.micronaut.data.model.Pageable)1 StoredQuery (io.micronaut.data.model.runtime.StoredQuery)1