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.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.Binder
Nested classes/interfaces inherited from interface io.micronaut.data.model.runtime.StoredQuery
StoredQuery.OperationType
-
Field Summary
Modifier and TypeFieldDescriptionprotected List<RuntimePersistentProperty<Object>>
protected List<QueryParameterBinding>
protected String
protected final SqlStoredQuery<E,
R> Fields inherited from class io.micronaut.data.runtime.operations.internal.query.DefaultBindableParametersPreparedQuery
invocationContext, preparedQuery, storedQuery
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Constructor Summary
ConstructorDescriptionDefaultSqlPreparedQuery
(PreparedQuery<E, R> preparedQuery) DefaultSqlPreparedQuery
(PreparedQuery<E, R> preparedQuery, SqlStoredQuery<E, R> sqlStoredQuery) DefaultSqlPreparedQuery
(SqlStoredQuery<E, R> sqlStoredQuery) -
Method Summary
Modifier and TypeMethodDescriptionvoid
attachPageable
(Pageable pageable, boolean isSingleResult) Modify the query according to the pageable.void
bindParameters
(BindableParametersStoredQuery.Binder binder, E entity, Map<QueryParameterBinding, Object> previousValues) Bind query parameters.collectAutoPopulatedPreviousValues
(E entity) Collect auto-populated property values before pre-actions are triggered and property values are modified.createCursors
(List<Object> results, Pageable pageable) Modify pageable based on the scan results.createCursors
(List<Object> results, Pageable pageable, RuntimePersistentEntity<Object> runtimePersistentEntity) Modify pageable based on the scan results.static Sort
enhanceCursoredSort
(Sort sort, boolean isBackwards, PersistentEntity persistentEntity) static CursoredPageable
enhancePageable
(CursoredPageable cursored, PersistentEntity persistentEntity) Get dialect.getQuery()
The query to execute.protected int
getQueryParameterValueSize
(QueryParameterBinding parameter) Gets number of parameter values for the query parameter binding (used for IN for example).boolean
void
Check if query need to be modified to expand parameters.protected int
Compute the size of the given object.Methods inherited from class io.micronaut.data.runtime.operations.internal.query.DefaultBindableParametersPreparedQuery
bindParameters, bindParameters
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.operations.internal.query.BindableParametersPreparedQuery
bindParameters
Methods inherited from interface io.micronaut.data.runtime.operations.internal.query.BindableParametersStoredQuery
bindParameters
Methods inherited from interface io.micronaut.data.runtime.query.internal.DelegatePreparedQuery
getArguments, getAttribute, getAttribute, getAttributes, getPageable, getParameterArray, getParameterInRole, getQueryHints, getRepositoryType, getRootEntity, getStoredQueryDelegate, isDtoProjection, isRawQuery
Methods inherited from interface io.micronaut.data.runtime.query.internal.DelegateStoredQuery
getAnnotationMetadata, getArgumentTypes, getEntityIdentifierType, getExpandableQueryParts, getJoinFetchPaths, getJoinPaths, getLimit, getName, getOffset, getOperationType, getParameterExpressions, getQueryBindings, getResultArgument, getResultDataType, getResultType, hasPageable, hasResultConsumer, isCount, isJsonEntity, isNative, isOptimisticLock, isProcedure, isSingleResult, useNumericPlaceholders
-
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:
getPersistentEntity
in interfacePersistentEntityAwareQuery<E>
- Overrides:
getPersistentEntity
in classDefaultBindableParametersPreparedQuery<E,
R> - Returns:
- The persistent entity
-
getPreparedQueryDelegate
- Specified by:
getPreparedQueryDelegate
in interfaceDelegatePreparedQuery<E,
R> - Overrides:
getPreparedQueryDelegate
in classDefaultBindableParametersPreparedQuery<E,
R> - Returns:
- The delegate
-
isExpandableQuery
public boolean isExpandableQuery()- Specified by:
isExpandableQuery
in interfaceSqlStoredQuery<E,
R> - Returns:
- true if query is expandable
-
getDialect
Description copied from interface:SqlStoredQuery
Get dialect.- Specified by:
getDialect
in interfaceSqlStoredQuery<E,
R> - Returns:
- dialect
-
getQueryBuilder
- Specified by:
getQueryBuilder
in interfaceSqlStoredQuery<E,
R> - Returns:
- query builder for possible modification in the prepared query
-
getQuery
Description copied from interface:StoredQuery
The query to execute.- Specified by:
getQuery
in interfaceDelegatePreparedQuery<E,
R> - Specified by:
getQuery
in interfaceDelegateStoredQuery<E,
R> - Specified by:
getQuery
in interfaceStoredQuery<E,
R> - Returns:
- The query to execute
-
collectAutoPopulatedPreviousValues
Description copied from interface:SqlStoredQuery
Collect auto-populated property values before pre-actions are triggered and property values are modified.- Specified by:
collectAutoPopulatedPreviousValues
in interfaceSqlStoredQuery<E,
R> - Parameters:
entity
- The entity instance- Returns:
- collected values
-
prepare
Check if query need to be modified to expand parameters.- Specified by:
prepare
in 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:SqlPreparedQuery
Modify the query according to the pageable.- Specified by:
attachPageable
in interfaceSqlPreparedQuery<E,
R> - Parameters:
pageable
- The pageableisSingleResult
- is single result
-
createCursors
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 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, E entity, Map<QueryParameterBinding, Object> previousValues) Description copied from interface:BindableParametersPreparedQuery
Bind query parameters.- Specified by:
bindParameters
in interfaceBindableParametersPreparedQuery<E,
R> - Overrides:
bindParameters
in classDefaultBindableParametersPreparedQuery<E,
R> - Parameters:
binder
- The binderentity
- The entitypreviousValues
- The previous auto-populated collected values
-
getQueryResultInfo
- Specified by:
getQueryResultInfo
in interfaceSqlPreparedQuery<E,
R> - Specified by:
getQueryResultInfo
in interfaceSqlStoredQuery<E,
R> - Returns:
- the query result info
-
sizeOf
Compute the size of the given object.- Parameters:
value
- The value- Returns:
- The size
-