io.micronaut.data.runtime.query.DefaultStoredQueryResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micronaut-data-runtime Show documentation
Show all versions of micronaut-data-runtime Show documentation
Data Repository Support for Micronaut
/*
* Copyright 2017-2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.data.runtime.query;
import io.micronaut.aop.MethodInvocationContext;
import io.micronaut.core.annotation.AnnotationMetadata;
import io.micronaut.core.annotation.AnnotationValue;
import io.micronaut.core.annotation.Internal;
import io.micronaut.core.type.Argument;
import io.micronaut.data.annotation.DataAnnotationUtils;
import io.micronaut.data.annotation.Query;
import io.micronaut.data.annotation.RepositoryConfiguration;
import io.micronaut.data.intercept.annotation.DataMethod;
import io.micronaut.data.model.DataType;
import io.micronaut.data.model.query.builder.sql.SqlQueryBuilder;
import io.micronaut.data.model.runtime.QueryParameterBinding;
import io.micronaut.data.model.runtime.StoredQuery;
import io.micronaut.data.operations.HintsCapableRepository;
import io.micronaut.data.runtime.query.internal.DefaultStoredQuery;
import io.micronaut.inject.ExecutableMethod;
import java.lang.annotation.Annotation;
import java.util.List;
import static io.micronaut.data.model.runtime.StoredQuery.OperationType;
/**
* Default stored query resolver.
*
* @author Denis Stepanov
* @since 3.3
*/
@Internal
public abstract class DefaultStoredQueryResolver implements StoredQueryResolver {
@Override
public StoredQuery resolveQuery(MethodInvocationContext, ?> context) {
return new DefaultStoredQuery<>(
context.getExecutableMethod(),
false,
getHintsCapableRepository()
);
}
@Override
public StoredQuery resolveCountQuery(MethodInvocationContext, ?> context) {
AnnotationValue dataMethodQuery = context.getAnnotation(DataMethod.NAME);
AnnotationValue countQuery = dataMethodQuery.getAnnotation(DataMethod.META_MEMBER_COUNT_QUERY).orElse(null);
if (countQuery != null) {
return new DefaultStoredQuery<>(
context.getExecutableMethod(),
countQuery,
getHintsCapableRepository()
);
}
// Previous way
return new DefaultStoredQuery<>(
context.getExecutableMethod(),
true,
getHintsCapableRepository()
);
}
@Override
public StoredQuery createStoredQuery(ExecutableMethod, ?> executableMethod,
OperationType operationType,
String name,
AnnotationMetadata annotationMetadata,
Class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy