org.apache.ignite.springdata20.repository.query

## Class IgniteRepositoryQuery

- java.lang.Object
- - org.apache.ignite.springdata20.repository.query.IgniteRepositoryQuery

- All Implemented Interfaces:
    org.springframework.data.repository.query.RepositoryQuery

      public class IgniteRepositoryQuery
      extends Object
      implements org.springframework.data.repository.query.RepositoryQuery

  Ignite query implementation.

  Features:

  1. Supports query tuning parameters
  2. Supports projections
  3. Supports Page and Stream responses
  4. Supports SqlFieldsQuery resultset transformation into the domain entity
  5. Supports named parameters (:myParam) into SQL queries, declared using @Param("myParam") annotation
  6. Supports advanced parameter binding and SpEL expressions into SQL queries
     1. Template variables:
        1. `#entityName` - the simple class name of the domain entity
     2. Method parameter expressions: Parameters are exposed for indexed access ([0] is the first query method's param) or via the name declared using @Param. The actual SpEL expression binding is triggered by '?#'. Example: ?#{[0]} or ?#{#myParamName}
     3. Advanced SpEL expressions: While advanced parameter binding is a very useful feature, the real power of SpEL stems from the fact, that the expressions can refer to framework abstractions or other application components through SpEL EvaluationContext extension model.
     Examples:

           @Query(value = "SELECT * from #{#entityName} where email = :email")
          User searchUserByEmail( @Param("email") String email);

           @Query(value = "SELECT * from #{#entityName} where country = ?#{[0]} and city = ?#{[1]}")
          List searchUsersByCity( @Param("country") String country,  @Param("city") String city,
          Pageable pageable);

           @Query(value = "SELECT * from #{#entityName} where email = ?")
          User searchUserByEmail(String email);

           @Query(value = "SELECT * from #{#entityName} where lucene = ?#{
          luceneQueryBuilder.search().refresh(true).filter(luceneQueryBuilder.match('city',#city)).build()}")
          List searchUsersByCity( @Param("city") String city, Pageable pageable);

  7. Supports SpEL expressions into Text queries (`TextQuery`). Examples:

           @Query(textQuery = true, value = "email: #{#email}")
          User searchUserByEmail( @Param("email") String email);

           @Query(textQuery = true, value = "#{#textToSearch}")
          List searchUsersByText( @Param("textToSearch") String text, Pageable pageable);

           @Query(textQuery = true, value = "#{[0]}")
          List searchUsersByText(String textToSearch, Pageable pageable);

           @Query(textQuery = true, value = "#{luceneQueryBuilder.search().refresh(true).filter(luceneQueryBuilder
          .match('city', #city)).build()}")
          List searchUserByCity( @Param("city") String city, Pageable pageable);

  8. Supports dynamic query and tuning at runtime by using `DynamicQueryConfig` method parameter. Examples:

           @Query(value = "SELECT * from #{#entityName} where email = :email")
          User searchUserByEmailWithQueryTuning( @Param("email") String email,  @Param("ignoredUsedAsQueryTuning") DynamicQueryConfig config);

           @Query(dynamicQuery = true)
          List searchUsersByCityWithDynamicQuery( @Param("country") String country,  @Param("city") String city,
           @Param("ignoredUsedAsDynamicQueryAndTuning") DynamicQueryConfig config, Pageable pageable);

          ...
          DynamicQueryConfig onlyTunning = new DynamicQueryConfig().setCollocated(true);
          repo.searchUserByEmailWithQueryTuning("user@mail.com", onlyTunning);

          DynamicQueryConfig withDynamicQuery = new DynamicQueryConfig().value("SELECT * from #{#entityName} where country = ?#{[0] and city = ?#{[1]}").setForceFieldsQuery(true).setLazy(true).setCollocated(true);
          repo.searchUsersByCityWithDynamicQuery("Spain", "Madrid", withDynamicQuery, new PageRequest(0, 100));

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `IgniteRepositoryQuery.QueryCursorWrapper<T,V>` Ignite QueryCursor wrapper.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IgniteRepositoryQuery(Ignite ignite, org.springframework.data.repository.core.RepositoryMetadata metadata, @Nullable IgniteQuery staticQuery, Method mtd, org.springframework.data.projection.ProjectionFactory factory, IgniteCache cache, @Nullable DynamicQueryConfig staticQueryConfiguration, org.springframework.data.repository.query.EvaluationContextProvider queryMethodEvaluationContextProvider)` Instantiates a new Ignite repository query.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `execute(Object[] values)` @param values the values
    `org.springframework.data.repository.query.QueryMethod` | `getQueryMethod()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IgniteRepositoryQuery

          public IgniteRepositoryQuery(Ignite ignite,
                                       org.springframework.data.repository.core.RepositoryMetadata metadata,
                                       @Nullable
                                       @Nullable IgniteQuery staticQuery,
                                       Method mtd,
                                       org.springframework.data.projection.ProjectionFactory factory,
                                       IgniteCache cache,
                                       @Nullable
                                       @Nullable DynamicQueryConfig staticQueryConfiguration,
                                       org.springframework.data.repository.query.EvaluationContextProvider queryMethodEvaluationContextProvider)

      Instantiates a new Ignite repository query.
      Parameters:
        `ignite` - the ignite
        `metadata` - Metadata.
        `staticQuery` - Query.
        `mtd` - Method.
        `factory` - Factory.
        `cache` - Cache.
        `staticQueryConfiguration` - the query configuration
        `queryMethodEvaluationContextProvider` - the query method evaluation context provider

  - ### Method Detail

    - #### execute

          public Object execute(Object[] values)

      @param values the values
      Specified by:
        `execute` in interface `org.springframework.data.repository.query.RepositoryQuery`
      Returns:
        the object

    - #### getQueryMethod

          public org.springframework.data.repository.query.QueryMethod getQueryMethod()

      Specified by:
        `getQueryMethod` in interface `org.springframework.data.repository.query.RepositoryQuery`

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020