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 Details

    • VARIABLE_PATTERN

      static final Pattern 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 metadata
      entity - 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 metadata
      query - 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 query
      propertiesToUpdate - 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 query
      propertiesToUpdate - 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 metadata
      query - The query
      propertiesToUpdate - 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 metadata
      query - The query
      propertiesToUpdate - The property names to update
      Returns:
      The encoded query
    • buildDelete

      @NonNull default @NonNull QueryResult buildDelete(@NonNull @NonNull QueryModel query)
      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 metadata
      query - 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 entity
      sort - The sort
      Returns:
      The encoded query
    • buildPagination

      @NonNull @NonNull QueryResult buildPagination(@NonNull @NonNull Pageable pageable)
      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