Class DefaultStoredQuery<E,RT>
- java.lang.Object
-
- io.micronaut.data.model.runtime.DefaultStoredDataOperation<RT>
-
- io.micronaut.data.runtime.query.internal.DefaultStoredQuery<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.naming.Named,StoredDataOperation<RT>,StoredQuery<E,RT>
@Internal public final class DefaultStoredQuery<E,RT> extends DefaultStoredDataOperation<RT> implements StoredQuery<E,RT>
Represents a prepared query.
-
-
Field Summary
-
Fields inherited from class io.micronaut.data.model.runtime.DefaultStoredDataOperation
NO_TRANSACTION
-
-
Constructor Summary
Constructors Constructor Description DefaultStoredQuery(io.micronaut.inject.ExecutableMethod<?,?> method, java.lang.Class<RT> resultType, java.lang.Class<E> rootEntity, java.lang.String query, boolean isCount, HintsCapableRepository repositoryOperations)The default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.Class<?>[]getArgumentTypes()The argument types to the method that invokes the query.java.util.Optional<java.lang.Class<?>>getEntityIdentifierType()The type of the ID member of the entity.java.lang.String[]getExpandableQueryParts()The query to execute.int[]getIndexedParameterBinding()The parameter binding.DataType[]getIndexedParameterTypes()The compute time computed parameter data types for the query indices.java.util.Set<JoinPath>getJoinFetchPaths()io.micronaut.inject.ExecutableMethod<?,?>getMethod()java.lang.StringgetName()java.lang.StringgetQuery()The query to execute.java.util.List<QueryParameterBinding>getQueryBindings()The list of query bindings.java.util.Map<java.lang.String,java.lang.Object>getQueryHints()The parameter binding.DataTypegetResultDataType()java.lang.Class<RT>getResultType()The query result type.java.lang.Class<E>getRootEntity()The root entity type.inthashCode()booleanhasPageable()Does the query have a pageable.booleanhasResultConsumer()booleanisCount()booleanisDtoProjection()Returns whether the query returns the actual entity or a Data Transfer Object (DTO) project.booleanisNative()In cases where one needs to differentiate between at higher level query format (like JPA-QL) and a lower level format (like SQL).booleanisOptimisticLock()Is with an optimistic lock.booleanisSingleResult()Whether the query can be treated as a single result.booleanuseNumericPlaceholders()Is this a raw SQL query.-
Methods inherited from class io.micronaut.data.model.runtime.DefaultStoredDataOperation
getAnnotationMetadata, getResultArgument, getTransactionDefinition
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, 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.model.runtime.StoredDataOperation
getTransactionDefinition
-
Methods inherited from interface io.micronaut.data.model.runtime.StoredQuery
getIndexedParameterAutoPopulatedPreviousPropertyIndexes, getIndexedParameterAutoPopulatedPreviousPropertyPaths, getIndexedParameterAutoPopulatedPropertyPaths, getIndexedParameterPaths, getLastUpdatedProperty, getParameterBinding, getParameterNames, getResultArgument, hasInExpression
-
-
-
-
Constructor Detail
-
DefaultStoredQuery
public DefaultStoredQuery(@NonNull io.micronaut.inject.ExecutableMethod<?,?> method, @NonNull java.lang.Class<RT> resultType, @NonNull java.lang.Class<E> rootEntity, @NonNull java.lang.String query, boolean isCount, HintsCapableRepository repositoryOperations)The default constructor.- Parameters:
method- The target methodresultType- The result type of the queryrootEntity- The root entity of the queryquery- The query itselfisCount- Is the query a count queryrepositoryOperations- The repositoryOperations
-
-
Method Detail
-
getQueryBindings
public java.util.List<QueryParameterBinding> getQueryBindings()
Description copied from interface:StoredQueryThe list of query bindings.- Specified by:
getQueryBindingsin interfaceStoredQuery<E,RT>- Returns:
- the query bindings
-
getJoinFetchPaths
@NonNull public java.util.Set<JoinPath> getJoinFetchPaths()
- Specified by:
getJoinFetchPathsin interfaceStoredQuery<E,RT>- Returns:
- The join paths that require a fetch
-
getMethod
public io.micronaut.inject.ExecutableMethod<?,?> getMethod()
- Returns:
- The method
-
isSingleResult
public boolean isSingleResult()
Description copied from interface:StoredQueryWhether the query can be treated as a single result.- Specified by:
isSingleResultin interfaceStoredQuery<E,RT>- Returns:
- True if it can.
-
hasResultConsumer
public boolean hasResultConsumer()
- Specified by:
hasResultConsumerin interfaceStoredQuery<E,RT>- Returns:
- Whether a result consumer is present
-
isCount
public boolean isCount()
- Specified by:
isCountin interfaceStoredQuery<E,RT>- Returns:
- Is this a count query.
-
getIndexedParameterTypes
@NonNull public DataType[] getIndexedParameterTypes()
Description copied from interface:StoredQueryThe compute time computed parameter data types for the query indices.- Specified by:
getIndexedParameterTypesin interfaceStoredQuery<E,RT>- Returns:
- The indexed values
- See Also:
StoredQuery.useNumericPlaceholders()
-
getIndexedParameterBinding
@NonNull public int[] getIndexedParameterBinding()
Description copied from interface:StoredQueryThe parameter binding. That is the mapping between named query parameters and parameters of the method.- Specified by:
getIndexedParameterBindingin interfaceStoredQuery<E,RT>- Returns:
- The parameter binding.
- See Also:
StoredQuery.useNumericPlaceholders()
-
getQueryHints
@NonNull public java.util.Map<java.lang.String,java.lang.Object> getQueryHints()
Description copied from interface:StoredQueryThe parameter binding. That is the mapping between named query parameters and parameters of the method.- Specified by:
getQueryHintsin interfaceStoredQuery<E,RT>- Returns:
- The parameter binding.
-
isNative
public boolean isNative()
Description copied from interface:StoredQueryIn cases where one needs to differentiate between at higher level query format (like JPA-QL) and a lower level format (like SQL).- Specified by:
isNativein interfaceStoredQuery<E,RT>- Returns:
- Whether the query is native.
-
useNumericPlaceholders
public boolean useNumericPlaceholders()
Is this a raw SQL query.- Specified by:
useNumericPlaceholdersin interfaceStoredQuery<E,RT>- Returns:
- The raw sql query.
-
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 interfaceStoredQuery<E,RT>- Returns:
- Whether the query is a DTO query
-
getResultType
@NonNull public java.lang.Class<RT> getResultType()
Description copied from interface:StoredQueryThe query result type. This may differ from the root entity type returned byStoredQuery.getRootEntity().- Specified by:
getResultTypein interfaceStoredQuery<E,RT>- Returns:
- The result type
-
getResultDataType
@NonNull public DataType getResultDataType()
- Specified by:
getResultDataTypein interfaceStoredQuery<E,RT>- Returns:
- The result data type.
-
getEntityIdentifierType
public java.util.Optional<java.lang.Class<?>> getEntityIdentifierType()
Description copied from interface:StoredQueryThe type of the ID member of the entity.- Specified by:
getEntityIdentifierTypein interfaceStoredQuery<E,RT>- Returns:
- The ID type
-
getRootEntity
@NonNull public java.lang.Class<E> getRootEntity()
Description copied from interface:StoredQueryThe root entity type.- Specified by:
getRootEntityin interfaceStoredQuery<E,RT>- Returns:
- The root entity type
-
hasPageable
public boolean hasPageable()
Description copied from interface:StoredQueryDoes the query have a pageable.- Specified by:
hasPageablein interfaceStoredQuery<E,RT>- Returns:
- True if it does
-
getQuery
@NonNull public java.lang.String getQuery()
Description copied from interface:StoredQueryThe query to execute.- Specified by:
getQueryin interfaceStoredQuery<E,RT>- Returns:
- The query to execute
-
getExpandableQueryParts
public java.lang.String[] getExpandableQueryParts()
Description copied from interface:StoredQueryThe query to execute.- Specified by:
getExpandableQueryPartsin interfaceStoredQuery<E,RT>- Returns:
- The query to execute
-
getName
@NonNull public java.lang.String getName()
- Specified by:
getNamein interfaceio.micronaut.core.naming.Named
-
getArgumentTypes
@NonNull public java.lang.Class<?>[] getArgumentTypes()
Description copied from interface:StoredQueryThe argument types to the method that invokes the query.- Specified by:
getArgumentTypesin interfaceStoredQuery<E,RT>- Returns:
- The argument types
-
isOptimisticLock
public boolean isOptimisticLock()
Description copied from interface:StoredQueryIs with an optimistic lock.- Specified by:
isOptimisticLockin interfaceStoredQuery<E,RT>- Returns:
- the result
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-