Class DefaultSqlPreparedQuery<E,R>
java.lang.Object
io.micronaut.data.runtime.operations.internal.query.DefaultBindableParametersPreparedQuery<E,R>
io.micronaut.data.runtime.operations.internal.sql.DefaultSqlPreparedQuery<E,R>
- Type Parameters:
E- The entity typeR- 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<R>,PreparedQuery<E,,R> StoredDataOperation<R>,StoredQuery<E,,R> BindableParametersPreparedQuery<E,,R> BindableParametersStoredQuery<E,,R> PersistentEntityAwareQuery<E>,SqlPreparedQuery<E,,R> SqlStoredQuery<E,,R> DelegatePreparedQuery<E,,R> DelegateStoredQuery<E,R>
@Internal
public class DefaultSqlPreparedQuery<E,R>
extends DefaultBindableParametersPreparedQuery<E,R>
implements SqlPreparedQuery<E,R>, DelegatePreparedQuery<E,R>
Implementation of
SqlPreparedQuery.- Since:
- 3.5.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.data.runtime.operations.internal.query.BindableParametersStoredQuery
BindableParametersStoredQuery.BinderNested classes/interfaces inherited from interface io.micronaut.data.model.runtime.StoredQuery
StoredQuery.OperationType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable List<PersistentPropertyPath> protected @Nullable List<QueryParameterBinding> protected Stringprotected final SqlStoredQuery<E, R> Fields inherited from class io.micronaut.data.runtime.operations.internal.query.DefaultBindableParametersPreparedQuery
invocationContext, preparedQuery, storedQueryFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSqlPreparedQuery(PreparedQuery<E, R> preparedQuery) DefaultSqlPreparedQuery(PreparedQuery<E, R> preparedQuery, SqlStoredQuery<E, R> sqlStoredQuery) DefaultSqlPreparedQuery(SqlStoredQuery<E, R> sqlStoredQuery) -
Method Summary
Modifier and TypeMethodDescriptionvoidattachPageable(Pageable pageable, Limit limit, Sort sort) Modify the query according to the pageable.voidbindParameters(BindableParametersStoredQuery.Binder binder, @Nullable E entity, @Nullable Map<QueryParameterBinding, Object> previousValues) Bind query parameters.@Nullable Map<QueryParameterBinding, Object> collectAutoPopulatedPreviousValues(E entity) Collect auto-populated property values before pre-actions are triggered and property values are modified.@Nullable List<Pageable.Cursor> createCursors(List<Object> results, Pageable pageable) Modify pageable based on the scan results.@Nullable List<Pageable.Cursor> createCursors(List<Object> results, Pageable pageable, RuntimePersistentEntity<Object> runtimePersistentEntity) Modify pageable based on the scan results.static SortenhanceCursoredSort(Sort sort, boolean isBackwards, PersistentEntity persistentEntity) static CursoredPageableenhancePageable(CursoredPageable cursored, PersistentEntity persistentEntity) Get dialect.@Nullable io.micronaut.aop.InvocationContext<?, ?> Returns the invocation context associated with this prepared query.getQuery()The query to execute.protected intgetQueryParameterValueSize(QueryParameterBinding parameter) Gets number of parameter values for the query parameter binding (used for IN for example).@Nullable QueryResultInfobooleanvoidCheck if query need to be modified to expand parameters.protected intCompute the size of the given object.Methods inherited from class io.micronaut.data.runtime.operations.internal.query.DefaultBindableParametersPreparedQuery
bindParameters, bindParameters, getConversionService, getQueryLimit, getSortMethods inherited from class java.lang.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 io.micronaut.data.runtime.operations.internal.query.BindableParametersPreparedQuery
bindParametersMethods inherited from interface io.micronaut.data.runtime.operations.internal.query.BindableParametersStoredQuery
bindParametersMethods inherited from interface io.micronaut.data.runtime.query.internal.DelegatePreparedQuery
getArguments, getAttribute, getAttribute, getAttributes, getConversionService, getPageable, getParameterArray, getParameterInRole, getParametersInRole, getQueryHints, getQueryLimit, getRepositoryType, getRootEntity, getSort, getStoredQueryDelegate, isDtoProjection, isRawQueryMethods inherited from interface io.micronaut.data.runtime.query.internal.DelegateStoredQuery
getAnnotationMetadata, getExpandableQueryParts, getJoinPaths, getName, getOperationType, getParameterExpressions, getQueryBindings, getResultArgument, getResultDataType, getResultType, hasPageable, hasResultConsumer, isCount, isJsonEntity, isNative, isOptimisticLock, isProcedureMethods inherited from interface io.micronaut.data.runtime.operations.internal.sql.SqlPreparedQuery
attachPageable
-
Field Details
-
cursorQueryBindings
-
cursorProperties
-
sqlStoredQuery
-
query
-
-
Constructor Details
-
DefaultSqlPreparedQuery
-
DefaultSqlPreparedQuery
public DefaultSqlPreparedQuery(PreparedQuery<E, R> preparedQuery, SqlStoredQuery<E, R> sqlStoredQuery) -
DefaultSqlPreparedQuery
-
-
Method Details
-
getPersistentEntity
- Specified by:
getPersistentEntityin interfacePersistentEntityAwareQuery<E>- Specified by:
getPersistentEntityin interfaceSqlPreparedQuery<E,R> - Overrides:
getPersistentEntityin classDefaultBindableParametersPreparedQuery<E,R> - Returns:
- The persistent entity
-
getPreparedQueryDelegate
- Specified by:
getPreparedQueryDelegatein interfaceDelegatePreparedQuery<E,R> - Overrides:
getPreparedQueryDelegatein classDefaultBindableParametersPreparedQuery<E,R> - Returns:
- The delegate
-
isExpandableQuery
public boolean isExpandableQuery()- Specified by:
isExpandableQueryin interfaceSqlStoredQuery<E,R> - Returns:
- true if query is expandable
-
getDialect
Description copied from interface:SqlStoredQueryGet dialect.- Specified by:
getDialectin interfaceSqlStoredQuery<E,R> - Returns:
- dialect
-
getQueryBuilder
- Specified by:
getQueryBuilderin interfaceSqlStoredQuery<E,R> - Returns:
- query builder for possible modification in the prepared query
-
getQuery
Description copied from interface:StoredQueryThe query to execute.- Specified by:
getQueryin interfaceDelegatePreparedQuery<E,R> - Specified by:
getQueryin interfaceDelegateStoredQuery<E,R> - Specified by:
getQueryin interfaceStoredQuery<E,R> - Returns:
- The query to execute
-
collectAutoPopulatedPreviousValues
Description copied from interface:SqlStoredQueryCollect auto-populated property values before pre-actions are triggered and property values are modified.- Specified by:
collectAutoPopulatedPreviousValuesin interfaceSqlStoredQuery<E,R> - Parameters:
entity- The entity instance- Returns:
- collected values
-
prepare
Check if query need to be modified to expand parameters.- Specified by:
preparein interfaceSqlPreparedQuery<E,R> - Parameters:
entity- The entity instance
-
getQueryParameterValueSize
Gets number of parameter values for the query parameter binding (used for IN for example).- Parameters:
parameter- the query binding parameter- Returns:
- number of parameter values in query parameter binding
-
enhanceCursoredSort
public static Sort enhanceCursoredSort(Sort sort, boolean isBackwards, PersistentEntity persistentEntity) -
enhancePageable
public static CursoredPageable enhancePageable(CursoredPageable cursored, PersistentEntity persistentEntity) -
attachPageable
Description copied from interface:SqlPreparedQueryModify the query according to the pageable.- Specified by:
attachPageablein interfaceSqlPreparedQuery<E,R> - Parameters:
pageable- The pageablelimit- The limitsort- The sort
-
createCursors
@Internal public @Nullable List<Pageable.Cursor> createCursors(List<Object> results, Pageable pageable) Modify pageable based on the scan results. This is required for cursored pageable, as cursor is created from the results.- Parameters:
results- The scanning resultspageable- The pageable sent by user- Returns:
- The updated pageable
- Since:
- 4.8.0
-
createCursors
@Internal public @Nullable List<Pageable.Cursor> createCursors(List<Object> results, Pageable pageable, RuntimePersistentEntity<Object> runtimePersistentEntity) Modify pageable based on the scan results. This is required for cursored pageable, as cursor is created from the results.- Parameters:
results- The scanning resultspageable- The pageable sent by userruntimePersistentEntity- The runtime persistent entity. Actual repository persistent entity type or custom runtime persistent entity in case of DTO projection.- Returns:
- The updated pageable
- Since:
- 4.8.0
-
bindParameters
public void bindParameters(BindableParametersStoredQuery.Binder binder, @Nullable E entity, @Nullable Map<QueryParameterBinding, Object> previousValues) Description copied from interface:BindableParametersPreparedQueryBind query parameters.- Specified by:
bindParametersin interfaceBindableParametersPreparedQuery<E,R> - Overrides:
bindParametersin classDefaultBindableParametersPreparedQuery<E,R> - Parameters:
binder- The binderentity- The entitypreviousValues- The previous auto-populated collected values
-
getQueryResultInfo
- Specified by:
getQueryResultInfoin interfaceSqlPreparedQuery<E,R> - Specified by:
getQueryResultInfoin interfaceSqlStoredQuery<E,R> - Returns:
- the query result info
-
getInvocationContext
public @Nullable io.micronaut.aop.InvocationContext<?,?> getInvocationContext()Description copied from interface:SqlPreparedQueryReturns the invocation context associated with this prepared query.- Specified by:
getInvocationContextin interfaceSqlPreparedQuery<E,R> - Returns:
- the invocation context
-
sizeOf
Compute the size of the given object.- Parameters:
value- The value- Returns:
- The size
-