Interface QueryBuilder
-
- All Known Implementing Classes:
AbstractSqlLikeQueryBuilder,JpaQueryBuilder,MongoQueryBuilder,SqlQueryBuilder
@Introspected public interface QueryBuilderAn interface capable of encoding a query into a string and a set of named parameters.- Since:
- 1.0
- Author:
- graemerocher
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternIN_VARIABLES_PATTERNDeprecated.static java.util.regex.PatternVARIABLE_PATTERNA pattern used to find variables in a query string.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description QueryResultbuildDelete(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.QueryResultbuildInsert(io.micronaut.core.annotation.AnnotationMetadata repositoryMetadata, PersistentEntity entity)Builds an insert statement for the given entity.QueryResultbuildOrderBy(PersistentEntity entity, Sort sort)Encode the given query into the encoded query instance.QueryResultbuildPagination(Pageable pageable)Encode the pageable.QueryResultbuildQuery(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.QueryResultbuildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query, java.util.List<java.lang.String> propertiesToUpdate)Encode the given query into the encoded query instance.QueryResultbuildUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, QueryModel query, java.util.Map<java.lang.String,java.lang.Object> propertiesToUpdate)Encode the given query into the encoded query instance.default QueryResultbuildUpdate(QueryModel query, java.util.List<java.lang.String> propertiesToUpdate)Encode the given query into the encoded query instance.default QueryResultbuildUpdate(QueryModel query, java.util.Map<java.lang.String,java.lang.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 booleanshouldAliasProjections()Whether projections should be aliased.default booleansupportsForUpdate()Whether FOR UPDATE queries are supported.
-
-
-
Method Detail
-
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
@NonNull default QueryResult buildQuery(@NonNull QueryModel query)
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 java.util.List<java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.util.List<java.lang.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 java.util.Map<java.lang.String,java.lang.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
@NonNull default QueryResult buildDelete(@NonNull QueryModel query)
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
@NonNull QueryResult buildOrderBy(@NonNull PersistentEntity entity, @NonNull Sort sort)
Encode the given query into the encoded query instance.- Parameters:
entity- The root entitysort- The sort- Returns:
- The encoded query
-
buildPagination
@NonNull QueryResult buildPagination(@NonNull Pageable pageable)
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
-
-