Interface QueryBuilder
- All Known Implementing Classes:
AbstractSqlLikeQueryBuilder,CosmosSqlQueryBuilder,JpaQueryBuilder,MongoQueryBuilder,SqlQueryBuilder
@Introspected
public interface QueryBuilder
An interface capable of encoding a query into a string and a set of named parameters.
- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternA pattern used to find variables in a query string. -
Method Summary
Modifier and TypeMethodDescriptionbuildDelete(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query) Encode the given query into the encoded query instance.default QueryResultbuildDelete(QueryModel query) Encode the given query into the encoded query instance.buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Builds an insert statement for the given entity.buildOrderBy(PersistentEntity entity, Sort sort) Encode the given query into the encoded query instance.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.default QueryResultbuildQuery(QueryModel query) Encode the given query into the encoded query instance.buildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query, List<String> propertiesToUpdate) Encode the given query into the encoded query instance.buildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query, Map<String, Object> propertiesToUpdate) Encode the given query into the encoded query instance.default QueryResultbuildUpdate(QueryModel query, List<String> propertiesToUpdate) Encode the given query into the encoded query instance.default QueryResultbuildUpdate(QueryModel query, Map<String, Object> propertiesToUpdate) Encode the given query into the encoded query instance.static QueryBuildernewQueryBuilder(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Build a query build from the configured annotation metadata.default booleanWhether projections should be aliased.default booleanWhether FOR UPDATE queries are supported.
-
Field Details
-
VARIABLE_PATTERN
A pattern used to find variables in a query string.
-
-
Method Details
-
buildInsert
@Nullable QueryResult buildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Builds an insert statement for the given entity.- Parameters:
repositoryMetadata- The repository annotation metadataentity- The entity- Returns:
- The insert statement or null if the implementation doesn't require insert statements
-
buildQuery
Encode the given query into the encoded query instance.- Parameters:
query- The query- Returns:
- The encoded query
-
buildQuery
QueryResult buildQuery(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query) Encode the given query for the passed annotation metadata and query.- Parameters:
annotationMetadata- The annotation metadataquery- The query model- Returns:
- The query result
-
buildUpdate
@NonNull default QueryResult buildUpdate(@NonNull QueryModel query, @NonNull List<String> propertiesToUpdate) Encode the given query into the encoded query instance.- Parameters:
query- The querypropertiesToUpdate- The property names to update- Returns:
- The encoded query
-
buildUpdate
@NonNull default QueryResult buildUpdate(@NonNull QueryModel query, @NonNull Map<String, Object> propertiesToUpdate) Encode the given query into the encoded query instance.- Parameters:
query- The querypropertiesToUpdate- The property names to update- Returns:
- The encoded query
-
buildUpdate
QueryResult buildUpdate(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query, @NonNull List<String> propertiesToUpdate) Encode the given query into the encoded query instance.- Parameters:
annotationMetadata- The annotation metadataquery- The querypropertiesToUpdate- The property names to update- Returns:
- The encoded query
-
buildUpdate
QueryResult buildUpdate(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query, @NonNull Map<String, Object> propertiesToUpdate) Encode the given query into the encoded query instance.- Parameters:
annotationMetadata- The annotation metadataquery- The querypropertiesToUpdate- The property names to update- Returns:
- The encoded query
-
buildDelete
Encode the given query into the encoded query instance.- Parameters:
query- The query- Returns:
- The encoded query
-
buildDelete
QueryResult buildDelete(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query) Encode the given query into the encoded query instance.- Parameters:
annotationMetadata- The annotation metadataquery- The query- Returns:
- The encoded query
-
buildOrderBy
Encode the given query into the encoded query instance.- Parameters:
entity- The root entitysort- The sort- Returns:
- The encoded query
-
buildPagination
Encode the pageable.- Parameters:
pageable- The pageable- Returns:
- The encoded query
-
newQueryBuilder
@NonNull static QueryBuilder newQueryBuilder(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Build a query build from the configured annotation metadata.- Parameters:
annotationMetadata- The annotation metadata.- Returns:
- The query builder
-
shouldAliasProjections
default boolean shouldAliasProjections()Whether projections should be aliased.- Returns:
- True if they should
-
supportsForUpdate
default boolean supportsForUpdate()Whether FOR UPDATE queries are supported.- Returns:
- True if FOR UPDATE queries are supported
-