Class CosmosSqlQueryBuilder2
java.lang.Object
io.micronaut.data.model.query.builder.sql.AbstractSqlLikeQueryBuilder2
io.micronaut.data.model.query.builder.sql.SqlQueryBuilder2
io.micronaut.data.document.model.query.builder.CosmosSqlQueryBuilder2
- All Implemented Interfaces:
QueryBuilder2
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.sql.SqlQueryBuilder2
SqlQueryBuilder2.InsertQueryDefinitionImpl, SqlQueryBuilder2.SqlSelectionVisitor
Nested classes/interfaces inherited from class io.micronaut.data.model.query.builder.sql.AbstractSqlLikeQueryBuilder2
AbstractSqlLikeQueryBuilder2.Placeholder, AbstractSqlLikeQueryBuilder2.QueryBuilder, AbstractSqlLikeQueryBuilder2.QueryPosition, AbstractSqlLikeQueryBuilder2.QueryPropertyPath, AbstractSqlLikeQueryBuilder2.QueryState, AbstractSqlLikeQueryBuilder2.SqlPredicateVisitor
Nested classes/interfaces inherited from interface io.micronaut.data.model.query.builder.QueryBuilder2
QueryBuilder2.BaseQueryDefinition, QueryBuilder2.DeleteQueryDefinition, QueryBuilder2.InsertQueryDefinition, QueryBuilder2.SelectQueryDefinition, QueryBuilder2.UpdateQueryDefinition
-
Field Summary
Fields inherited from class io.micronaut.data.model.query.builder.sql.SqlQueryBuilder2
DEFAULT_POSITIONAL_PARAMETER_MARKER, SQL_SERVER_FOR_UPDATE_CLAUSE, STANDARD_FOR_UPDATE_CLAUSE
Fields inherited from class io.micronaut.data.model.query.builder.sql.AbstractSqlLikeQueryBuilder2
ALIAS_REPLACE_QUOTED, AND, AS_CLAUSE, CANNOT_QUERY_ON_ID_WITH_ENTITY_THAT_HAS_NO_ID, CLOSE_BRACKET, COMMA, DISTINCT, DOT, FROM_CLAUSE, LOGICAL_AND, LOGICAL_OR, NOT, OPEN_BRACKET, OR, ORDER_BY_CLAUSE, RETURNING, SELECT_CLAUSE, SPACE, WHERE_CLAUSE
-
Constructor Summary
ConstructorDescriptionCosmosSqlQueryBuilder2
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringBuilder
appendDeleteClause
(StringBuilder queryString) Append the delete clause.protected String
Convert the literal value to it's SQL representation.buildInsert
(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, QueryBuilder2.InsertQueryDefinition definition) Builds an insert statement for the given entity.protected void
buildJoin
(String joinType, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, PersistentAssociationPath joinAssociation, PersistentEntity associationOwner, String currentJoinAlias, String lastJoinAlias) Build a join expression for the given alias, association, join type and builder.buildLimitAndOffset
(long limit, long offset) Generate the limit and offset query.buildSelect
(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryBuilder2.SelectQueryDefinition definition) Encode the given query for the passed annotation metadata and query.buildUpdate
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.UpdateQueryDefinition definition) Encode the given query into the encoded query instance.protected boolean
Whether property path expressions require computation by the implementation.createPredicateVisitor
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState) Create a predicate visitor.protected SqlQueryBuilder2.SqlSelectionVisitor
createSelectionVisitor
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState, boolean distinct) Create a selection visitor.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 boolean
Methods inherited from class io.micronaut.data.model.query.builder.sql.SqlQueryBuilder2
appendForUpdate, appendPaginationAndOrder, appendUpdateSetParameter, buildBatchCreateTableStatement, buildBatchDropTableStatement, buildCreateTableStatements, buildDropTableStatements, buildJoinTableInsert, formatParameter, getAliasName, getColumnName, getDialect, getTableAsKeyword, getTableName, isForeignKeyWithJoinTable, positionalParameterFormat, quote, resolveJoinType, selectAutoStrategy, shouldEscape
Methods inherited from class io.micronaut.data.model.query.builder.sql.AbstractSqlLikeQueryBuilder2
appendExpression, appendLimitAndOffset, appendOrder, appendPropertyRef, appendTransformed, asPath, asQueryPropertyPath, buildAdditionalWhereClause, buildAdditionalWhereString, buildAdditionalWhereString, buildDelete, buildOrderBy, buildPropertyByName, buildQuery, buildSelect, buildWhereClause, checkDialectSupportsJsonEntity, getAliasName, getColumnAlias, getDataTransformerReadValue, getDataTransformerWriteValue, getMappedName, getMappedName, getMappedName, getPathOnlyAliasName, getUnescapedTableName, isJsonEntity, newBindingContext, resolveWhereForAnnotationMetadata
-
Constructor Details
-
CosmosSqlQueryBuilder2
@Creator public CosmosSqlQueryBuilder2(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
-
-
Method Details
-
asLiteral
Description copied from class:AbstractSqlLikeQueryBuilder2
Convert the literal value to it's SQL representation.- Overrides:
asLiteral
in classSqlQueryBuilder2
- Parameters:
value
- The literal value- Returns:
- converter value
-
traverseEmbedded
protected boolean traverseEmbedded()- Overrides:
traverseEmbedded
in classAbstractSqlLikeQueryBuilder2
- Returns:
- True if embedded properties should be traversed
-
createSelectionVisitor
protected SqlQueryBuilder2.SqlSelectionVisitor createSelectionVisitor(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState, boolean distinct) Description copied from class:AbstractSqlLikeQueryBuilder2
Create a selection visitor.- Overrides:
createSelectionVisitor
in classSqlQueryBuilder2
- Parameters:
annotationMetadata
- The annotation metadataqueryState
- The query statedistinct
- The distinct- Returns:
- The visitor
-
createPredicateVisitor
protected AbstractSqlLikeQueryBuilder2.SqlPredicateVisitor createPredicateVisitor(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder2.QueryState queryState) Description copied from class:AbstractSqlLikeQueryBuilder2
Create a predicate visitor.- Overrides:
createPredicateVisitor
in classAbstractSqlLikeQueryBuilder2
- Parameters:
annotationMetadata
- The annotation metadataqueryState
- The query state- Returns:
- The visitor
-
getNamingStrategy
Description copied from class:AbstractSqlLikeQueryBuilder2
GetsNamingStrategy
for the entity. Subclasses might override and potentially provide different strategy in some cases.- Overrides:
getNamingStrategy
in classAbstractSqlLikeQueryBuilder2
- Parameters:
entity
- the persistent entity- Returns:
- naming strategy for the entity
-
getNamingStrategy
Description copied from class:AbstractSqlLikeQueryBuilder2
GetsNamingStrategy
for the property path. Subclasses might override and potentially provide different strategy in some cases.- Overrides:
getNamingStrategy
in classAbstractSqlLikeQueryBuilder2
- Parameters:
propertyPath
- the property path representation- Returns:
- naming strategy for the property path
-
buildSelect
public QueryResult buildSelect(@NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryBuilder2.SelectQueryDefinition definition) Description copied from interface:QueryBuilder2
Encode the given query for the passed annotation metadata and query.- Specified by:
buildSelect
in interfaceQueryBuilder2
- Overrides:
buildSelect
in classSqlQueryBuilder2
- Parameters:
annotationMetadata
- The annotation metadatadefinition
- The query model- Returns:
- The query result
-
buildJoin
protected void buildJoin(String joinType, StringBuilder query, AbstractSqlLikeQueryBuilder2.QueryState queryState, PersistentAssociationPath joinAssociation, PersistentEntity associationOwner, String currentJoinAlias, String lastJoinAlias) Description copied from class:AbstractSqlLikeQueryBuilder2
Build a join expression for the given alias, association, join type and builder.- Overrides:
buildJoin
in classSqlQueryBuilder2
- Parameters:
joinType
- The join typequery
- The query builderqueryState
- The statejoinAssociation
- The associationassociationOwner
- The associated ownercurrentJoinAlias
- The current join aliaslastJoinAlias
- The last join alias
-
appendDeleteClause
Description copied from class:AbstractSqlLikeQueryBuilder2
Append the delete clause.- Overrides:
appendDeleteClause
in classAbstractSqlLikeQueryBuilder2
- 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:AbstractSqlLikeQueryBuilder2
Should aliases be used in batch statements.- Overrides:
isAliasForBatch
in classSqlQueryBuilder2
- Parameters:
persistentEntity
- the persistent entityannotationMetadata
- the method annotation metadata- Returns:
- True if they should
-
computePropertyPaths
protected boolean computePropertyPaths()Description copied from class:AbstractSqlLikeQueryBuilder2
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 classSqlQueryBuilder2
- Returns:
- True if property path computation is required.
-
buildInsert
public QueryResult buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, QueryBuilder2.InsertQueryDefinition definition) Description copied from interface:QueryBuilder2
Builds an insert statement for the given entity.- Specified by:
buildInsert
in interfaceQueryBuilder2
- Overrides:
buildInsert
in classSqlQueryBuilder2
- Parameters:
repositoryMetadata
- The repository annotation metadatadefinition
- The definition- Returns:
- The insert statement or null if the implementation doesn't require insert statements
-
buildUpdate
public QueryResult buildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryBuilder2.UpdateQueryDefinition definition) Description copied from interface:QueryBuilder2
Encode the given query into the encoded query instance.- Specified by:
buildUpdate
in interfaceQueryBuilder2
- Overrides:
buildUpdate
in classAbstractSqlLikeQueryBuilder2
- Parameters:
annotationMetadata
- The annotation metadatadefinition
- The definition- Returns:
- The encoded query
-
buildLimitAndOffset
Description copied from interface:QueryBuilder2
Generate the limit and offset query.- Specified by:
buildLimitAndOffset
in interfaceQueryBuilder2
- Overrides:
buildLimitAndOffset
in classAbstractSqlLikeQueryBuilder2
- Parameters:
limit
- The limit (-1 of not set)offset
- The offset (0 if not set)- Returns:
- The encoded query
-