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_CLAUSEFields 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_CLAUSEFields inherited from interface io.micronaut.data.model.query.builder.QueryBuilder
VARIABLE_PATTERN -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.CosmosSqlQueryBuilder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanappendAssociationProjection(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryString, PersistentProperty property, PersistentPropertyPath propertyPath) Appends selection projection for the property which is association.protected StringBuilderappendDeleteClause(StringBuilder queryString) Append the delete clause.protected voidappendProjectionRowCount(StringBuilder queryString, String logicalName) Appends a row count projection to the query string.protected StringConvert 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 voidbuildJoin(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.buildPagination(Pageable pageable) Encode the pageable.buildQuery(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, 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 booleanWhether property path expressions require computation by the implementation.protected NamingStrategygetNamingStrategy(PersistentEntity entity) GetsNamingStrategyfor the entity.protected NamingStrategygetNamingStrategy(PersistentPropertyPath propertyPath) GetsNamingStrategyfor the property path.protected booleanisAliasForBatch(PersistentEntity persistentEntity, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Should aliases be used in batch statements.protected voidselectAllColumns(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer) Obtain the string that selects all columns from the entity.protected voidselectAllColumnsFromJoinPaths(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryBuffer, Collection<JoinPath> allPaths, Map<JoinPath, String> joinAliasOverride) protected voidtraversePersistentProperties(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, supportsForUpdateMethods inherited from class io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder
addCriterionHandler, appendOrder, appendPropertyRef, appendTransformed, asLiterals, asPath, buildDelete, buildOrderBy, buildOrderBy, buildSelect, buildUpdate, buildWhereClause, checkDialectSupportsJsonEntity, getAliasName, getColumnAlias, getDataTransformerReadValue, getDataTransformerWriteValue, getMappedName, getMappedName, getMappedName, getPathOnlyAliasName, getUnescapedTableName, handleSubQuery, isJsonEntity, newBindingContext, selectAllColumns, traversePersistentProperties, traversePersistentProperties, traversePersistentPropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.data.model.query.builder.QueryBuilder
buildDelete, buildDelete, buildOrderBy, buildQuery, 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:AbstractSqlLikeQueryBuilderConvert the literal value to it's SQL representation.- Overrides:
asLiteralin classSqlQueryBuilder- Parameters:
value- The literal value- Returns:
- converter value
-
appendProjectionRowCount
Description copied from class:AbstractSqlLikeQueryBuilderAppends a row count projection to the query string.- Overrides:
appendProjectionRowCountin classSqlQueryBuilder- Parameters:
queryString- The query stringlogicalName- The alias to the table name
-
getNamingStrategy
Description copied from class:AbstractSqlLikeQueryBuilderGetsNamingStrategyfor the entity. Subclasses might override and potentially provide different strategy in some cases.- Overrides:
getNamingStrategyin classAbstractSqlLikeQueryBuilder- Parameters:
entity- the persistent entity- Returns:
- naming strategy for the entity
-
getNamingStrategy
Description copied from class:AbstractSqlLikeQueryBuilderGetsNamingStrategyfor the property path. Subclasses might override and potentially provide different strategy in some cases.- Overrides:
getNamingStrategyin 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:AbstractSqlLikeQueryBuilderTraverses persistent properties.- Overrides:
traversePersistentPropertiesin 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 io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query) Description copied from interface:QueryBuilderEncode the given query for the passed annotation metadata and query.- Specified by:
buildQueryin interfaceQueryBuilder- Overrides:
buildQueryin 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 Map<JoinPath, String> joinAliasOverride) - Overrides:
selectAllColumnsFromJoinPathsin classSqlQueryBuilder
-
appendAssociationProjection
protected boolean appendAssociationProjection(AbstractSqlLikeQueryBuilder.QueryState queryState, StringBuilder queryString, PersistentProperty property, PersistentPropertyPath propertyPath) Description copied from class:AbstractSqlLikeQueryBuilderAppends selection projection for the property which is association.- Overrides:
appendAssociationProjectionin 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:AbstractSqlLikeQueryBuilderObtain the string that selects all columns from the entity.- Overrides:
selectAllColumnsin 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:SqlQueryBuilderBuilds join, adding fields and criteria.- Overrides:
buildJoinin 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:AbstractSqlLikeQueryBuilderAppend the delete clause.- Overrides:
appendDeleteClausein 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:AbstractSqlLikeQueryBuilderShould aliases be used in batch statements.- Overrides:
isAliasForBatchin classSqlQueryBuilder- Parameters:
persistentEntity- the persistent entityannotationMetadata- the method annotation metadata- Returns:
- True if they should
-
computePropertyPaths
protected boolean computePropertyPaths()Description copied from class:AbstractSqlLikeQueryBuilderWhether 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:
computePropertyPathsin 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:QueryBuilderBuilds an insert statement for the given entity.- Specified by:
buildInsertin interfaceQueryBuilder- Overrides:
buildInsertin 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:QueryBuilderEncode the given query into the encoded query instance.- Specified by:
buildUpdatein interfaceQueryBuilder- Overrides:
buildUpdatein classAbstractSqlLikeQueryBuilder- Parameters:
annotationMetadata- The annotation metadataquery- The querypropertiesToUpdate- The property names to update- Returns:
- The encoded query
-
buildPagination
Description copied from interface:QueryBuilderEncode the pageable.- Specified by:
buildPaginationin interfaceQueryBuilder- Overrides:
buildPaginationin classSqlQueryBuilder- Parameters:
pageable- The pageable- Returns:
- The encoded query
-