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 boolean
equals(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.String
getName()
java.lang.String
getQuery()
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.DataType
getResultDataType()
java.lang.Class<RT>
getResultType()
The query result type.java.lang.Class<E>
getRootEntity()
The root entity type.int
hashCode()
boolean
hasPageable()
Does the query have a pageable.boolean
hasResultConsumer()
boolean
isCount()
boolean
isDtoProjection()
Returns whether the query returns the actual entity or a Data Transfer Object (DTO) project.boolean
isNative()
In cases where one needs to differentiate between at higher level query format (like JPA-QL) and a lower level format (like SQL).boolean
isOptimisticLock()
Is with an optimistic lock.boolean
isSingleResult()
Whether the query can be treated as a single result.boolean
useNumericPlaceholders()
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:StoredQuery
The list of query bindings.- Specified by:
getQueryBindings
in interfaceStoredQuery<E,RT>
- Returns:
- the query bindings
-
getJoinFetchPaths
@NonNull public java.util.Set<JoinPath> getJoinFetchPaths()
- Specified by:
getJoinFetchPaths
in 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:StoredQuery
Whether the query can be treated as a single result.- Specified by:
isSingleResult
in interfaceStoredQuery<E,RT>
- Returns:
- True if it can.
-
hasResultConsumer
public boolean hasResultConsumer()
- Specified by:
hasResultConsumer
in interfaceStoredQuery<E,RT>
- Returns:
- Whether a result consumer is present
-
isCount
public boolean isCount()
- Specified by:
isCount
in interfaceStoredQuery<E,RT>
- Returns:
- Is this a count query.
-
getIndexedParameterTypes
@NonNull public DataType[] getIndexedParameterTypes()
Description copied from interface:StoredQuery
The compute time computed parameter data types for the query indices.- Specified by:
getIndexedParameterTypes
in interfaceStoredQuery<E,RT>
- Returns:
- The indexed values
- See Also:
StoredQuery.useNumericPlaceholders()
-
getIndexedParameterBinding
@NonNull public int[] getIndexedParameterBinding()
Description copied from interface:StoredQuery
The parameter binding. That is the mapping between named query parameters and parameters of the method.- Specified by:
getIndexedParameterBinding
in 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:StoredQuery
The parameter binding. That is the mapping between named query parameters and parameters of the method.- Specified by:
getQueryHints
in interfaceStoredQuery<E,RT>
- Returns:
- The parameter binding.
-
isNative
public boolean isNative()
Description copied from interface:StoredQuery
In cases where one needs to differentiate between at higher level query format (like JPA-QL) and a lower level format (like SQL).- Specified by:
isNative
in interfaceStoredQuery<E,RT>
- Returns:
- Whether the query is native.
-
useNumericPlaceholders
public boolean useNumericPlaceholders()
Is this a raw SQL query.- Specified by:
useNumericPlaceholders
in interfaceStoredQuery<E,RT>
- Returns:
- The raw sql query.
-
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 interfaceStoredQuery<E,RT>
- Returns:
- Whether the query is a DTO query
-
getResultType
@NonNull public java.lang.Class<RT> getResultType()
Description copied from interface:StoredQuery
The query result type. This may differ from the root entity type returned byStoredQuery.getRootEntity()
.- Specified by:
getResultType
in interfaceStoredQuery<E,RT>
- Returns:
- The result type
-
getResultDataType
@NonNull public DataType getResultDataType()
- Specified by:
getResultDataType
in interfaceStoredQuery<E,RT>
- Returns:
- The result data type.
-
getEntityIdentifierType
public java.util.Optional<java.lang.Class<?>> getEntityIdentifierType()
Description copied from interface:StoredQuery
The type of the ID member of the entity.- Specified by:
getEntityIdentifierType
in interfaceStoredQuery<E,RT>
- Returns:
- The ID type
-
getRootEntity
@NonNull public java.lang.Class<E> getRootEntity()
Description copied from interface:StoredQuery
The root entity type.- Specified by:
getRootEntity
in interfaceStoredQuery<E,RT>
- Returns:
- The root entity type
-
hasPageable
public boolean hasPageable()
Description copied from interface:StoredQuery
Does the query have a pageable.- Specified by:
hasPageable
in interfaceStoredQuery<E,RT>
- Returns:
- True if it does
-
getQuery
@NonNull public java.lang.String getQuery()
Description copied from interface:StoredQuery
The query to execute.- Specified by:
getQuery
in interfaceStoredQuery<E,RT>
- Returns:
- The query to execute
-
getExpandableQueryParts
public java.lang.String[] getExpandableQueryParts()
Description copied from interface:StoredQuery
The query to execute.- Specified by:
getExpandableQueryParts
in interfaceStoredQuery<E,RT>
- Returns:
- The query to execute
-
getName
@NonNull public java.lang.String getName()
- Specified by:
getName
in interfaceio.micronaut.core.naming.Named
-
getArgumentTypes
@NonNull public java.lang.Class<?>[] getArgumentTypes()
Description copied from interface:StoredQuery
The argument types to the method that invokes the query.- Specified by:
getArgumentTypes
in interfaceStoredQuery<E,RT>
- Returns:
- The argument types
-
isOptimisticLock
public boolean isOptimisticLock()
Description copied from interface:StoredQuery
Is with an optimistic lock.- Specified by:
isOptimisticLock
in interfaceStoredQuery<E,RT>
- Returns:
- the result
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-