Class CosmosSqlQueryBuilder
java.lang.Object
io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder
io.micronaut.data.model.query.builder.sql.SqlQueryBuilder
io.micronaut.data.document.model.query.builder.CosmosSqlQueryBuilder
- All Implemented Interfaces:
QueryBuilder
,Annotation
The Azure Cosmos DB sql query builder.
- Since:
- 3.9.0
- Author:
- radovanradic
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder
AbstractSqlLikeQueryBuilder.CriteriaContext, AbstractSqlLikeQueryBuilder.CriterionHandler<T extends QueryModel.Criterion>, AbstractSqlLikeQueryBuilder.Placeholder, AbstractSqlLikeQueryBuilder.QueryPosition, AbstractSqlLikeQueryBuilder.QueryPropertyPath, AbstractSqlLikeQueryBuilder.QueryState
-
Field Summary
Fields inherited from class io.micronaut.data.model.query.builder.sql.SqlQueryBuilder
DEFAULT_POSITIONAL_PARAMETER_MARKER, SQL_SERVER_FOR_UPDATE_CLAUSE, STANDARD_FOR_UPDATE_CLAUSE
Fields inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder
ALIAS_REPLACE, ALIAS_REPLACE_QUOTED, AND, AS_CLAUSE, AVG, CLOSE_BRACKET, COMMA, COUNT_DISTINCT, DELETE_CLAUSE, DISTINCT, DOT, EQUALS, EQUALS_FALSE, EQUALS_TRUE, FROM_CLAUSE, FUNCTION_COUNT, GREATER_THAN, GREATER_THAN_OR_EQUALS, IS_EMPTY, IS_NOT_EMPTY, IS_NOT_NULL, JSON_COLUMN, LESS_THAN, LESS_THAN_OR_EQUALS, LOGICAL_AND, LOGICAL_OR, MAX, MIN, NOT, NOT_EQUALS, OPEN_BRACKET, OR, ORDER_BY_CLAUSE, queryHandlers, SELECT_CLAUSE, SPACE, SUM, UPDATE_CLAUSE, WHERE_CLAUSE
Fields inherited from interface io.micronaut.data.model.query.builder.QueryBuilder
VARIABLE_PATTERN
-
Constructor Summary
ConstructorDescriptionDefault constructor.CosmosSqlQueryBuilder
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
appendAssociationProjection
(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryString, PersistentProperty property, PersistentPropertyPath propertyPath) Appends selection projection for the property which is association.protected StringBuilder
appendDeleteClause
(StringBuilder queryString) Append the delete clause.protected void
appendProjectionRowCount
(StringBuilder queryString, String logicalName) Appends a row count projection to the query string.protected String
Convert the literal value to it's SQL representation.buildInsert
(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Builds an insert statement for the given entity.protected void
buildJoin
(String joinType, StringBuilder sb, AbstractSqlLikeQueryBuilder.QueryState queryState, List<Association> joinAssociationsPath, String joinAlias, Association association, PersistentEntity associatedEntity, PersistentEntity associationOwner, String currentJoinAlias) Builds join, adding fields and criteria.@NonNull QueryResult
buildPagination
(@NonNull Pageable pageable) Encode the pageable.buildQuery
(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query) Encode the given query for the passed annotation metadata and query.buildUpdate
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query, Map<String, Object> propertiesToUpdate) Encode the given query into the encoded query instance.protected boolean
Whether property path expressions require computation by the implementation.protected NamingStrategy
getNamingStrategy
(PersistentEntity entity) GetsNamingStrategy
for the entity.protected NamingStrategy
getNamingStrategy
(PersistentPropertyPath propertyPath) GetsNamingStrategy
for the property path.protected boolean
isAliasForBatch
(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Should aliases be used in batch statements.protected void
selectAllColumns
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer) Obtain the string that selects all columns from the entity.protected void
selectAllColumnsFromJoinPaths
(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer, Collection<JoinPath> allPaths, @Nullable Map<JoinPath, String> joinAliasOverride) protected void
traversePersistentProperties
(List<Association> associations, PersistentProperty property, BiConsumer<List<Association>, PersistentProperty> consumerProperty) Traverses persistent properties.Methods inherited from class io.micronaut.data.model.query.builder.sql.SqlQueryBuilder
annotationType, appendForUpdate, appendUpdateSetParameter, buildBatchCreateTableStatement, buildBatchDropTableStatement, buildCreateTableStatements, buildDropTableStatements, buildJoin, buildJoinTableInsert, concat, dialect, escapeQueries, formatParameter, getAliasName, getColumnName, getDialect, getTableAsKeyword, getTableName, isExpandEmbedded, isForeignKeyWithJoinTable, positionalParameterFormat, positionalParameterName, positionalParameterPattern, quote, resolveJoinType, selectAllColumns, selectAutoStrategy, shouldAliasProjections, shouldEscape, supportsForUpdate
Methods inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder
addCriterionHandler, appendOrder, appendPropertyRef, appendTransformed, asLiterals, asPath, buildAdditionalWhereClause, buildAdditionalWhereString, buildAdditionalWhereString, buildDelete, buildOrderBy, buildOrderBy, buildSelect, buildUpdate, buildWhereClause, checkDialectSupportsJsonEntity, getAliasName, getColumnAlias, getDataTransformerReadValue, getDataTransformerWriteValue, getMappedName, getMappedName, getMappedName, getPathOnlyAliasName, getUnescapedTableName, handleSubQuery, isJsonEntity, newBindingContext, resolveWhereForAnnotationMetadata, selectAllColumns, traversePersistentProperties, traversePersistentProperties, traversePersistentProperties
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.data.model.query.builder.QueryBuilder
buildDelete, buildDelete, buildOrderBy, buildUpdate, buildUpdate, buildUpdate
-
Constructor Details
-
CosmosSqlQueryBuilder
@Creator public CosmosSqlQueryBuilder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
CosmosSqlQueryBuilder
public CosmosSqlQueryBuilder()Default constructor.
-
-
Method Details
-
asLiteral
Description copied from class:AbstractSqlLikeQueryBuilder
Convert the literal value to it's SQL representation.- Overrides:
asLiteral
in classSqlQueryBuilder
- Parameters:
value
- The literal value- Returns:
- converter value
-
appendProjectionRowCount
Description copied from class:AbstractSqlLikeQueryBuilder
Appends a row count projection to the query string.- Overrides:
appendProjectionRowCount
in classSqlQueryBuilder
- Parameters:
queryString
- The query stringlogicalName
- The alias to the table name
-
getNamingStrategy
Description copied from class:AbstractSqlLikeQueryBuilder
GetsNamingStrategy
for the entity. Subclasses might override and potentially provide different strategy in some cases.- Overrides:
getNamingStrategy
in classAbstractSqlLikeQueryBuilder
- Parameters:
entity
- the persistent entity- Returns:
- naming strategy for the entity
-
getNamingStrategy
Description copied from class:AbstractSqlLikeQueryBuilder
GetsNamingStrategy
for the property path. Subclasses might override and potentially provide different strategy in some cases.- Overrides:
getNamingStrategy
in classAbstractSqlLikeQueryBuilder
- Parameters:
propertyPath
- the property path representation- Returns:
- naming strategy for the property path
-
traversePersistentProperties
protected void traversePersistentProperties(List<Association> associations, PersistentProperty property, BiConsumer<List<Association>, PersistentProperty> consumerProperty) Description copied from class:AbstractSqlLikeQueryBuilder
Traverses persistent properties.- Overrides:
traversePersistentProperties
in classAbstractSqlLikeQueryBuilder
- Parameters:
associations
- The association list being traversed with the propertyproperty
- The persistent propertyconsumerProperty
- The function to invoke on every property
-
buildQuery
public QueryResult buildQuery(@NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryModel query) Description copied from interface:QueryBuilder
Encode the given query for the passed annotation metadata and query.- Specified by:
buildQuery
in interfaceQueryBuilder
- Overrides:
buildQuery
in classAbstractSqlLikeQueryBuilder
- Parameters:
annotationMetadata
- The annotation metadataquery
- The query model- Returns:
- The query result
-
selectAllColumnsFromJoinPaths
@Internal protected void selectAllColumnsFromJoinPaths(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer, Collection<JoinPath> allPaths, @Nullable @Nullable Map<JoinPath, String> joinAliasOverride) - Overrides:
selectAllColumnsFromJoinPaths
in classSqlQueryBuilder
-
appendAssociationProjection
protected boolean appendAssociationProjection(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryString, PersistentProperty property, PersistentPropertyPath propertyPath) Description copied from class:AbstractSqlLikeQueryBuilder
Appends selection projection for the property which is association.- Overrides:
appendAssociationProjection
in classAbstractSqlLikeQueryBuilder
- Parameters:
queryState
- the query statequeryString
- the query string builderproperty
- the persistent propertypropertyPath
- the persistent property path- Returns:
- true if association projection is appended, otherwise false
-
selectAllColumns
protected void selectAllColumns(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer) Description copied from class:AbstractSqlLikeQueryBuilder
Obtain the string that selects all columns from the entity.- Overrides:
selectAllColumns
in classSqlQueryBuilder
- Parameters:
annotationMetadata
- The annotation metadataqueryState
- The query state
-
buildJoin
protected void buildJoin(String joinType, StringBuilder sb, AbstractSqlLikeQueryBuilder.QueryState queryState, List<Association> joinAssociationsPath, String joinAlias, Association association, PersistentEntity associatedEntity, PersistentEntity associationOwner, String currentJoinAlias) Description copied from class:SqlQueryBuilder
Builds join, adding fields and criteria.- Overrides:
buildJoin
in classSqlQueryBuilder
- Parameters:
joinType
- the join typesb
- string builder that join will be added toqueryState
- the query statejoinAssociationsPath
- the list of associationsjoinAlias
- the join aliasassociation
- the associationassociatedEntity
- the associated entityassociationOwner
- the association ownercurrentJoinAlias
- the current join alias
-
appendDeleteClause
Description copied from class:AbstractSqlLikeQueryBuilder
Append the delete clause.- Overrides:
appendDeleteClause
in classAbstractSqlLikeQueryBuilder
- Parameters:
queryString
- The query string- Returns:
- The delete clause
-
isAliasForBatch
protected boolean isAliasForBatch(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Description copied from class:AbstractSqlLikeQueryBuilder
Should aliases be used in batch statements.- Overrides:
isAliasForBatch
in classSqlQueryBuilder
- Parameters:
persistentEntity
- the persistent entityannotationMetadata
- the method annotation metadata- Returns:
- True if they should
-
computePropertyPaths
protected boolean computePropertyPaths()Description copied from class:AbstractSqlLikeQueryBuilder
Whether property path expressions require computation by the implementation. In a certain query dialects property paths are supported (such as JPA-QL where you can do select foo.bar) whilst for explicit SQL queries paths like this have to be computed into aliases / column name references.- Overrides:
computePropertyPaths
in classSqlQueryBuilder
- Returns:
- True if property path computation is required.
-
buildInsert
public QueryResult buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Description copied from interface:QueryBuilder
Builds an insert statement for the given entity.- Specified by:
buildInsert
in interfaceQueryBuilder
- Overrides:
buildInsert
in classSqlQueryBuilder
- Parameters:
repositoryMetadata
- The repository annotation metadataentity
- The entity- Returns:
- The insert statement or null if the implementation doesn't require insert statements
-
buildUpdate
public QueryResult buildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query, Map<String, Object> propertiesToUpdate) Description copied from interface:QueryBuilder
Encode the given query into the encoded query instance.- Specified by:
buildUpdate
in interfaceQueryBuilder
- Overrides:
buildUpdate
in classAbstractSqlLikeQueryBuilder
- Parameters:
annotationMetadata
- The annotation metadataquery
- The querypropertiesToUpdate
- The property names to update- Returns:
- The encoded query
-
buildPagination
Description copied from interface:QueryBuilder
Encode the pageable.- Specified by:
buildPagination
in interfaceQueryBuilder
- Overrides:
buildPagination
in classSqlQueryBuilder
- Parameters:
pageable
- The pageable- Returns:
- The encoded query
-