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
Modifier and TypeFieldDescriptionstatic final Pattern
A pattern used to find variables in a query string. -
Method Summary
Modifier and TypeMethodDescriptionbuildDelete
(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query) Encode the given query into the encoded query instance.default @NonNull QueryResult
buildDelete
(@NonNull QueryModel query) Encode the given query into the encoded query instance.@Nullable QueryResult
buildInsert
(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity) Builds an insert statement for the given entity.@NonNull QueryResult
buildOrderBy
(@NonNull PersistentEntity entity, @NonNull Sort sort) Encode the given query into the encoded query instance.@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
(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull QueryModel query, @NonNull List<String> propertiesToUpdate) Encode the given query into the encoded query instance.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.default @NonNull QueryResult
buildUpdate
(@NonNull QueryModel query, @NonNull List<String> propertiesToUpdate) Encode the given query into the encoded query instance.default @NonNull QueryResult
buildUpdate
(@NonNull QueryModel query, @NonNull Map<String, Object> propertiesToUpdate) Encode the given query into the encoded query instance.static @NonNull QueryBuilder
newQueryBuilder
(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) Build a query build from the configured annotation metadata.default boolean
Whether projections should be aliased.default boolean
Whether FOR UPDATE queries are supported.
-
Field Details
-
VARIABLE_PATTERN
A pattern used to find variables in a query string.
-
-
Method Details
-
buildInsert
@Nullable @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
QueryResult buildQuery(@NonNull @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @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 @NonNull QueryResult buildUpdate(@NonNull @NonNull QueryModel query, @NonNull @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 @NonNull QueryResult buildUpdate(@NonNull @NonNull QueryModel query, @NonNull @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 @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryModel query, @NonNull @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 @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryModel query, @NonNull @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 @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull @NonNull QueryModel query) Encode the given query into the encoded query instance.- Parameters:
annotationMetadata
- The annotation metadataquery
- The query- Returns:
- The encoded query
-
buildOrderBy
@NonNull @NonNull QueryResult buildOrderBy(@NonNull @NonNull PersistentEntity entity, @NonNull @NonNull Sort sort) 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 @NonNull QueryBuilder newQueryBuilder(@NonNull @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
-