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 type
RT - 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.
  • 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 context
      storedQuery - The stored query
      finalQuery - The final query
      pageable - The pageable
      limit - The limit
      dtoProjection - Whether the prepared query is a dto projection
      conversionService - 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 role
      type - The type
      methodContext - The method context
      conversionService - 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 role
      type - The type of the parameter in role
      methodContext - The method context
      conversionService - 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 role
      type - The type of the parameter in role
      methodContext - The method context
      conversionService - The conversion service
      Returns:
      The list of types
    • getConversionService

      public io.micronaut.core.convert.ConversionService getConversionService()
      Specified by:
      getConversionService in interface io.micronaut.core.convert.ConversionServiceProvider
      Specified by:
      getConversionService in interface PreparedQuery<E,RT>
    • getContext

      public io.micronaut.aop.MethodInvocationContext<?,?> getContext()
      Returns:
      The context
    • getRootEntity

      public Class<E> getRootEntity()
      Description copied from interface: StoredQuery
      The root entity type.
      Specified by:
      getRootEntity in interface DelegateStoredQuery<E,RT>
      Specified by:
      getRootEntity in interface PagedQuery<E>
      Specified by:
      getRootEntity in interface StoredQuery<E,RT>
      Returns:
      The root entity type
    • getQueryHints

      public Map<String,Object> 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 interface DelegateStoredQuery<E,RT>
      Specified by:
      getQueryHints in interface PagedQuery<E>
      Specified by:
      getQueryHints in interface PreparedQuery<E,RT>
      Specified by:
      getQueryHints in interface StoredQuery<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 interface DelegateStoredQuery<E,RT>
      Specified by:
      isRawQuery in interface PreparedQuery<E,RT>
      Specified by:
      isRawQuery in interface StoredQuery<E,RT>
      Returns:
      true if it is raw query
    • getStoredQueryDelegate

      public StoredQuery<E,RT> getStoredQueryDelegate()
      Specified by:
      getStoredQueryDelegate in interface DelegateStoredQuery<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 interface PreparedDataOperation<E>
      Type Parameters:
      RT1 - The generic type
      Parameters:
      role - The role
      type - The type
      Returns:
      An optional value.
    • getParametersInRole

      public <RT1> List<RT1> getParametersInRole(String role, Class<RT1> type)
      Description copied from interface: PreparedDataOperation
      Return the values of the given parameter if the given role.
      Specified by:
      getParametersInRole in interface PreparedDataOperation<E>
      Type Parameters:
      RT1 - The generic type
      Parameters:
      role - The role
      type - The type
      Returns:
      An optional value.
    • getRepositoryType

      public Class<?> getRepositoryType()
      Specified by:
      getRepositoryType in interface PreparedQuery<E,RT>
      Returns:
      The repository type.
    • getParameterArray

      public Object[] getParameterArray()
      Specified by:
      getParameterArray in interface PreparedQuery<E,RT>
      Returns:
      The method parameters
    • getArguments

      public io.micronaut.core.type.Argument[] getArguments()
      Specified by:
      getArguments in interface PreparedQuery<E,RT>
      Returns:
      The method arguments
    • getPageable

      @NonNull public @NonNull Pageable getPageable()
      Specified by:
      getPageable in interface PagedQuery<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 interface DelegateStoredQuery<E,RT>
      Specified by:
      isDtoProjection in interface StoredQuery<E,RT>
      Returns:
      Whether the query is a DTO projection query
    • getQuery

      @NonNull public @NonNull String getQuery()
      Description copied from interface: StoredQuery
      The query to execute.
      Specified by:
      getQuery in interface DelegateStoredQuery<E,RT>
      Specified by:
      getQuery in interface StoredQuery<E,RT>
      Returns:
      The query to execute
    • getAttributes

      @NonNull public @NonNull io.micronaut.core.convert.value.ConvertibleValues<Object> getAttributes()
      Specified by:
      getAttributes in interface io.micronaut.core.attr.AttributeHolder
    • getAttribute

      @NonNull public @NonNull Optional<Object> getAttribute(CharSequence name)
      Specified by:
      getAttribute in interface io.micronaut.core.attr.AttributeHolder
    • getAttribute

      @NonNull public <T> @NonNull Optional<T> getAttribute(CharSequence name, Class<T> type)
      Specified by:
      getAttribute in interface io.micronaut.core.attr.AttributeHolder
    • getOffset

      public int getOffset()
      Specified by:
      getOffset in interface DelegateStoredQuery<E,RT>
      Specified by:
      getOffset in interface StoredQuery<E,RT>
      Returns:
      The offset of the query or 0 if none
    • getLimit

      public int getLimit()
      Specified by:
      getLimit in interface DelegateStoredQuery<E,RT>
      Specified by:
      getLimit in interface StoredQuery<E,RT>
      Returns:
      The limit of the query or -1 if none
    • getSort

      public Sort getSort()
      Specified by:
      getSort in interface DelegateStoredQuery<E,RT>
      Specified by:
      getSort in interface PagedQuery<E>
      Specified by:
      getSort in interface PreparedQuery<E,RT>
      Specified by:
      getSort in interface StoredQuery<E,RT>
      Returns:
      The runtime sort
    • getQueryLimit

      public Limit getQueryLimit()
      Specified by:
      getQueryLimit in interface DelegateStoredQuery<E,RT>
      Specified by:
      getQueryLimit in interface PagedQuery<E>
      Specified by:
      getQueryLimit in interface PreparedQuery<E,RT>
      Specified by:
      getQueryLimit in interface StoredQuery<E,RT>
      Returns:
      The query limit