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 io.micronaut.data.model.runtime.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
int
getLimit()
int
@NonNull Pageable
Object[]
<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 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 String
getQuery()
The query to execute.The parameter binding.Class<?>
The root entity type.getSort()
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.boolean
Returns whether the query returns the actual entity or a Data Transfer Object (DTO) project.boolean
Gets an indicator telling whether underlying query is raw query.Methods inherited from class io.micronaut.data.model.runtime.DefaultStoredDataOperation
getAnnotationMetadata, getResultArgument
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getTargetAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
Methods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclared
Methods inherited from interface io.micronaut.data.runtime.query.internal.DelegateStoredQuery
getAnnotationMetadata, getArgumentTypes, getEntityIdentifierType, getExpandableQueryParts, getJoinFetchPaths, getJoinPaths, getName, getOperationType, getParameterExpressions, getQueryBindings, getResultArgument, getResultDataType, getResultType, hasPageable, hasResultConsumer, isCount, isJsonEntity, isNative, isOptimisticLock, isProcedure, isSingleResult, useNumericPlaceholders
-
Constructor Details
-
DefaultPreparedQuery
public DefaultPreparedQuery(io.micronaut.aop.MethodInvocationContext<?, ?> context, StoredQuery<E, RT> storedQuery, String finalQuery, @NonNull @NonNull Pageable pageable, @NonNull @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 @NonNull String role, @NonNull @NonNull Class<?> type, @NonNull @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull @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
@NonNull public static <RT1> @NonNull Optional<RT1> getParameterInRole(@NonNull @NonNull String role, @NonNull @NonNull Class<RT1> type, @NonNull @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull @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
@NonNull public static <RT1> @NonNull List<RT1> getParametersInRole(@NonNull @NonNull String role, @NonNull @NonNull Class<RT1> type, @NonNull @NonNull io.micronaut.aop.MethodInvocationContext<?, ?> methodContext, @NonNull @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:
getConversionService
in interfaceio.micronaut.core.convert.ConversionServiceProvider
- Specified by:
getConversionService
in interfacePreparedQuery<E,
RT>
-
getContext
public io.micronaut.aop.MethodInvocationContext<?,?> getContext()- Returns:
- The context
-
getRootEntity
Description copied from interface:StoredQuery
The root entity type.- Specified by:
getRootEntity
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getRootEntity
in interfacePagedQuery<E>
- Specified by:
getRootEntity
in interfaceStoredQuery<E,
RT> - Returns:
- The root entity type
-
getQueryHints
Description copied from interface:StoredQuery
The parameter binding. That is the mapping between named query parameters and parameters of the method.- Specified by:
getQueryHints
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getQueryHints
in interfacePagedQuery<E>
- Specified by:
getQueryHints
in interfacePreparedQuery<E,
RT> - Specified by:
getQueryHints
in interfaceStoredQuery<E,
RT> - Returns:
- The parameter binding.
-
isRawQuery
public boolean isRawQuery()Description copied from interface:StoredQuery
Gets an indicator telling whether underlying query is raw query.- Specified by:
isRawQuery
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
isRawQuery
in interfacePreparedQuery<E,
RT> - Specified by:
isRawQuery
in interfaceStoredQuery<E,
RT> - Returns:
- true if it is raw query
-
getStoredQueryDelegate
- Specified by:
getStoredQueryDelegate
in interfaceDelegateStoredQuery<E,
RT> - Returns:
- The delegate
-
getParameterInRole
public <RT1> Optional<RT1> getParameterInRole(@NonNull @NonNull String role, @NonNull @NonNull Class<RT1> type) Description copied from interface:PreparedDataOperation
Return the value of the given parameter if the given role.- Specified by:
getParameterInRole
in interfacePreparedDataOperation<E>
- Type Parameters:
RT1
- The generic type- Parameters:
role
- The roletype
- The type- Returns:
- An optional value.
-
getParametersInRole
Description copied from interface:PreparedDataOperation
Return the values of the given parameter if the given role.- Specified by:
getParametersInRole
in interfacePreparedDataOperation<E>
- Type Parameters:
RT1
- The generic type- Parameters:
role
- The roletype
- The type- Returns:
- An optional value.
-
getRepositoryType
- Specified by:
getRepositoryType
in interfacePreparedQuery<E,
RT> - Returns:
- The repository type.
-
getParameterArray
- Specified by:
getParameterArray
in interfacePreparedQuery<E,
RT> - Returns:
- The method parameters
-
getArguments
public io.micronaut.core.type.Argument[] getArguments()- Specified by:
getArguments
in interfacePreparedQuery<E,
RT> - Returns:
- The method arguments
-
getPageable
- Specified by:
getPageable
in interfacePagedQuery<E>
- Returns:
- The pageable object. Defaults to
Pageable.UNPAGED
-
isDtoProjection
public boolean isDtoProjection()Description copied from interface:StoredQuery
Returns whether the query returns the actual entity or a Data Transfer Object (DTO) project. Defaults to false.- Specified by:
isDtoProjection
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
isDtoProjection
in interfaceStoredQuery<E,
RT> - Returns:
- Whether the query is a DTO projection query
-
getQuery
Description copied from interface:StoredQuery
The query to execute.- Specified by:
getQuery
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getQuery
in interfaceStoredQuery<E,
RT> - Returns:
- The query to execute
-
getAttributes
- Specified by:
getAttributes
in interfaceio.micronaut.core.attr.AttributeHolder
-
getAttribute
- Specified by:
getAttribute
in interfaceio.micronaut.core.attr.AttributeHolder
-
getAttribute
- Specified by:
getAttribute
in interfaceio.micronaut.core.attr.AttributeHolder
-
getOffset
public int getOffset()- Specified by:
getOffset
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getOffset
in interfaceStoredQuery<E,
RT> - Returns:
- The offset of the query or 0 if none
-
getLimit
public int getLimit()- Specified by:
getLimit
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getLimit
in interfaceStoredQuery<E,
RT> - Returns:
- The limit of the query or -1 if none
-
getSort
- Specified by:
getSort
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getSort
in interfacePagedQuery<E>
- Specified by:
getSort
in interfacePreparedQuery<E,
RT> - Specified by:
getSort
in interfaceStoredQuery<E,
RT> - Returns:
- The runtime sort
-
getQueryLimit
- Specified by:
getQueryLimit
in interfaceDelegateStoredQuery<E,
RT> - Specified by:
getQueryLimit
in interfacePagedQuery<E>
- Specified by:
getQueryLimit
in interfacePreparedQuery<E,
RT> - Specified by:
getQueryLimit
in interfaceStoredQuery<E,
RT> - Returns:
- The query limit
-