Class DefaultPreparedQuery<E,RT>
java.lang.Object
io.micronaut.data.model.runtime.DefaultStoredDataOperation<RT>
io.micronaut.data.runtime.query.internal.DefaultPreparedQuery<E,RT>
- Type Parameters:
E- The entity typeRT- The result type
- All Implemented Interfaces:
io.micronaut.core.annotation.AnnotationMetadataProvider, io.micronaut.core.annotation.AnnotationSource, io.micronaut.core.attr.AttributeHolder, io.micronaut.core.convert.ConversionServiceProvider, io.micronaut.core.naming.Named, PagedQuery<E>, PreparedDataOperation<RT>, PreparedQuery<E,RT>, StoredDataOperation<RT>, StoredQuery<E, RT>, DelegateStoredQuery<E, RT>
@Internal
public final class DefaultPreparedQuery<E,RT>
extends DefaultStoredDataOperation<RT>
implements DelegateStoredQuery<E,RT>, PreparedQuery<E,RT>
Represents a prepared query.
-
Nested Class Summary
Nested classes/interfaces inherited from interface StoredQuery
StoredQuery.OperationType -
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPreparedQuery(io.micronaut.aop.MethodInvocationContext<?, ?> context, StoredQuery<E, RT> storedQuery, String finalQuery, @NonNull Pageable pageable, @NonNull Limit limit, boolean dtoProjection, io.micronaut.core.convert.ConversionService conversionService) The default constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.core.type.Argument[]getAttribute(CharSequence name) <T> @NonNull Optional<T> getAttribute(CharSequence name, Class<T> type) @NonNull io.micronaut.core.convert.value.ConvertibleValues<Object> io.micronaut.aop.MethodInvocationContext<?, ?> io.micronaut.core.convert.ConversionService@NonNull PageableObject[]static <RT1> @NonNull Optional<RT1> getParameterInRole(@NonNull String role, @NonNull io.micronaut.core.type.Argument<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find a parameter in role from the method context.<RT1> Optional<RT1> getParameterInRole(@NonNull String role, @NonNull Class<RT1> type) Return the value of the given parameter if the given role.static <RT1> @NonNull Optional<RT1> getParameterInRole(@NonNull String role, @NonNull Class<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find a parameter in role from the method context.static <RT1> @NonNull List<RT1> getParametersInRole(@NonNull String role, @NonNull io.micronaut.core.type.Argument<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find the parameters in role from the method context.static <RT1> @NonNull List<RT1> getParametersInRole(@NonNull String role, @NonNull Class<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find the parameters in role from the method context.<RT1> List<RT1> getParametersInRole(String role, Class<RT1> type) Return the values of the given parameter if the given role.@NonNull StringgetQuery()The query to execute.The parameter binding.Class<?> The root entity type.getSort()static booleanhasReturnTypeInRole(@NonNull String role, @NonNull Class<?> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Check the return role from the method context.booleanReturns whether the query returns the actual entity or a Data Transfer Object (DTO) project.booleanGets an indicator telling whether underlying query is raw query.Methods inherited from class DefaultStoredDataOperation
getAnnotationMetadata, getResultArgumentMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getTargetAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclaredMethods inherited from interface DelegateStoredQuery
getAnnotationMetadata, getExpandableQueryParts, getJoinPaths, getName, getOperationType, getParameterExpressions, getQueryBindings, getResultArgument, getResultDataType, getResultType, hasPageable, hasResultConsumer, isCount, isJsonEntity, isNative, isOptimisticLock, isProcedure
-
Constructor Details
-
DefaultPreparedQuery
public DefaultPreparedQuery(io.micronaut.aop.MethodInvocationContext<?, ?> context, StoredQuery<E, RT> storedQuery, String finalQuery, @NonNull Pageable pageable, @NonNull Limit limit, boolean dtoProjection, io.micronaut.core.convert.ConversionService conversionService) The default constructor.- Parameters:
context- The execution contextstoredQuery- The stored queryfinalQuery- The final querypageable- The pageablelimit- The limitdtoProjection- Whether the prepared query is a dto projectionconversionService- The conversion service
-
-
Method Details
-
hasReturnTypeInRole
public static boolean hasReturnTypeInRole(@NonNull String role, @NonNull Class<?> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Check the return role from the method context.- Parameters:
role- The roletype- The typemethodContext- The method contextconversionService- The conversion service- Returns:
- The optional parameter
-
getParameterInRole
public static <RT1> @NonNull Optional<RT1> getParameterInRole(@NonNull String role, @NonNull Class<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find a parameter in role from the method context.- Type Parameters:
RT1- The type- Parameters:
role- The roletype- The type of the parameter in rolemethodContext- The method contextconversionService- The conversion service- Returns:
- The optional parameter
-
getParameterInRole
public static <RT1> @NonNull Optional<RT1> getParameterInRole(@NonNull String role, @NonNull io.micronaut.core.type.Argument<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find a parameter in role from the method context.- Type Parameters:
RT1- The type- Parameters:
role- The roletype- The type of the parameter in rolemethodContext- The method contextconversionService- The conversion service- Returns:
- The optional parameter
-
getParametersInRole
public static <RT1> @NonNull List<RT1> getParametersInRole(@NonNull String role, @NonNull Class<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find the parameters in role from the method context.- Type Parameters:
RT1- The type- Parameters:
role- The roletype- The type of the parameter in rolemethodContext- The method contextconversionService- The conversion service- Returns:
- The list of types
-
getParametersInRole
public static <RT1> @NonNull List<RT1> getParametersInRole(@NonNull String role, @NonNull io.micronaut.core.type.Argument<RT1> type, @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull io.micronaut.core.convert.ConversionService conversionService) Find the parameters in role from the method context.- Type Parameters:
RT1- The type- Parameters:
role- The roletype- The type of the parameter in rolemethodContext- The method contextconversionService- The conversion service- Returns:
- The list of types
-
getConversionService
public io.micronaut.core.convert.ConversionService getConversionService()- Specified by:
getConversionServicein interfaceio.micronaut.core.convert.ConversionServiceProvider- Specified by:
getConversionServicein interfacePreparedQuery<E,RT>
-
getContext
public io.micronaut.aop.MethodInvocationContext<?,?> getContext()- Returns:
- The context
-
getRootEntity
Description copied from interface:StoredQueryThe root entity type.- Specified by:
getRootEntityin interfaceDelegateStoredQuery<E,RT> - Specified by:
getRootEntityin interfacePagedQuery<E>- Specified by:
getRootEntityin interfaceStoredQuery<E,RT> - Returns:
- The root entity type
-
getQueryHints
Description copied from interface:StoredQueryThe parameter binding. That is the mapping between named query parameters and parameters of the method.- Specified by:
getQueryHintsin interfaceDelegateStoredQuery<E,RT> - Specified by:
getQueryHintsin interfacePagedQuery<E>- Specified by:
getQueryHintsin interfacePreparedQuery<E,RT> - Specified by:
getQueryHintsin interfaceStoredQuery<E,RT> - Returns:
- The parameter binding.
-
isRawQuery
public boolean isRawQuery()Description copied from interface:StoredQueryGets an indicator telling whether underlying query is raw query.- Specified by:
isRawQueryin interfaceDelegateStoredQuery<E,RT> - Specified by:
isRawQueryin interfacePreparedQuery<E,RT> - Specified by:
isRawQueryin interfaceStoredQuery<E,RT> - Returns:
- true if it is raw query
-
getStoredQueryDelegate
- Specified by:
getStoredQueryDelegatein interfaceDelegateStoredQuery<E,RT> - Returns:
- The delegate
-
getParameterInRole
Description copied from interface:PreparedDataOperationReturn the value of the given parameter if the given role.- Specified by:
getParameterInRolein interfacePreparedDataOperation<E>- Type Parameters:
RT1- The generic type- Parameters:
role- The roletype- The type- Returns:
- An optional value.
-
getParametersInRole
Description copied from interface:PreparedDataOperationReturn the values of the given parameter if the given role.- Specified by:
getParametersInRolein interfacePreparedDataOperation<E>- Type Parameters:
RT1- The generic type- Parameters:
role- The roletype- The type- Returns:
- An optional value.
-
getRepositoryType
- Specified by:
getRepositoryTypein interfacePreparedQuery<E,RT> - Returns:
- The repository type.
-
getParameterArray
- Specified by:
getParameterArrayin interfacePreparedQuery<E,RT> - Returns:
- The method parameters
-
getArguments
public io.micronaut.core.type.Argument[] getArguments()- Specified by:
getArgumentsin interfacePreparedQuery<E,RT> - Returns:
- The method arguments
-
getPageable
- Specified by:
getPageablein interfacePagedQuery<E>- Returns:
- The pageable object. Defaults to
Pageable.UNPAGED
-
isDtoProjection
public boolean isDtoProjection()Description copied from interface:StoredQueryReturns whether the query returns the actual entity or a Data Transfer Object (DTO) project. Defaults to false.- Specified by:
isDtoProjectionin interfaceDelegateStoredQuery<E,RT> - Specified by:
isDtoProjectionin interfaceStoredQuery<E,RT> - Returns:
- Whether the query is a DTO projection query
-
getQuery
Description copied from interface:StoredQueryThe query to execute.- Specified by:
getQueryin interfaceDelegateStoredQuery<E,RT> - Specified by:
getQueryin interfaceStoredQuery<E,RT> - Returns:
- The query to execute
-
getAttributes
- Specified by:
getAttributesin interfaceio.micronaut.core.attr.AttributeHolder
-
getAttribute
- Specified by:
getAttributein interfaceio.micronaut.core.attr.AttributeHolder
-
getAttribute
- Specified by:
getAttributein interfaceio.micronaut.core.attr.AttributeHolder
-
getSort
- Specified by:
getSortin interfaceDelegateStoredQuery<E,RT> - Specified by:
getSortin interfacePagedQuery<E>- Specified by:
getSortin interfacePreparedQuery<E,RT> - Specified by:
getSortin interfaceStoredQuery<E,RT> - Returns:
- The runtime sort
-
getQueryLimit
- Specified by:
getQueryLimitin interfaceDelegateStoredQuery<E,RT> - Specified by:
getQueryLimitin interfacePagedQuery<E>- Specified by:
getQueryLimitin interfacePreparedQuery<E,RT> - Specified by:
getQueryLimitin interfaceStoredQuery<E,RT> - Returns:
- The query limit
-