org.apache.ignite.cache

## Class QueryEntity

- java.lang.Object
- - org.apache.ignite.cache.QueryEntity

- All Implemented Interfaces:
    Serializable

      public class QueryEntity
      extends Object
      implements Serializable

  Query entity is a description of `cache` entry (composed of key and value) in a way of how it must be indexed and can be queried.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryEntity()` Creates an empty query entity.
    `QueryEntity(Class<?> keyCls, Class<?> valCls)` Creates a query entity with the given key and value types.
    `QueryEntity(QueryEntity other)` Copy constructor.
    `QueryEntity(String keyType, String valType)` Creates a query entity with the given key and value types.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `QueryEntity` | `addQueryField(String fullName, String type, String alias)` Utility method for building query entities programmatically.
    `boolean` | `equals(Object o)`
    `String` | `findKeyType()` Attempts to get key type from fields in case it was not set directly.
    `String` | `findValueType()` Attempts to get value type from fields in case it was not set directly.
    `Map<String,String>` | `getAliases()` Gets aliases map.
    `Map<String,Object>` | `getDefaultFieldValues()` Gets fields default values.
    `LinkedHashMap<String,String>` | `getFields()` Gets query fields for this query pair.
    `Map<String,Integer>` | `getFieldsPrecision()`
    `Map<String,Integer>` | `getFieldsScale()`
    `@NotNull Collection<QueryIndex>` | `getIndexes()` Gets a collection of index entities.
    `String` | `getKeyFieldName()` Gets key field name.
    `Set<String>` | `getKeyFields()` Gets query fields for this query pair that belongs to the key.
    `String` | `getKeyType()` Gets key type for this query pair.
    `@Nullable Set<String>` | `getNotNullFields()` Gets names of fields that must be checked for null.
    `String` | `getTableName()` Gets table name for this query entity.
    `String` | `getValueFieldName()` Get value field name.
    `String` | `getValueType()` Gets value type for this query pair.
    `int` | `hashCode()`
    `@NotNull QueryEntityPatch` | `makePatch(QueryEntity target)` Make query entity patch.
    `QueryEntity` | `setAliases(Map<String,String> aliases)` Sets mapping from full property name in dot notation to an alias that will be used as SQL column name.
    `QueryEntity` | `setDefaultFieldValues(Map<String,Object> defaultFieldValues)` Sets fields default values.
    `QueryEntity` | `setFields(LinkedHashMap<String,String> fields)` Sets query fields for this query pair.
    `QueryEntity` | `setFieldsPrecision(Map<String,Integer> fieldsPrecision)` Sets fieldsPrecision map for a fields.
    `QueryEntity` | `setFieldsScale(Map<String,Integer> fieldsScale)` Sets fieldsScale map for a fields.
    `QueryEntity` | `setIndexes(Collection<QueryIndex> idxs)` Sets a collection of index entities.
    `QueryEntity` | `setKeyFieldName(String keyFieldName)` Sets key field name.
    `QueryEntity` | `setKeyFields(Set<String> keyFields)` Gets query fields for this query pair that belongs to the key.
    `QueryEntity` | `setKeyType(String keyType)` Sets key type for this query pair.
    `QueryEntity` | `setNotNullFields(@Nullable Set<String> notNullFields)` Sets names of fields that must checked for null.
    `QueryEntity` | `setTableName(String tableName)` Sets table name for this query entity.
    `QueryEntity` | `setValueFieldName(String valueFieldName)` Sets value field name.
    `QueryEntity` | `setValueType(String valType)` Sets value type for this query pair.
    `String` | `toString()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryEntity

          public QueryEntity()

      Creates an empty query entity.

    - #### QueryEntity

          public QueryEntity(QueryEntity other)

      Copy constructor.
      Parameters:
        `other` - Other entity.

    - #### QueryEntity

          public QueryEntity(String keyType,
                             String valType)

      Creates a query entity with the given key and value types.
      Parameters:
        `keyType` - Key type.
        `valType` - Value type.

    - #### QueryEntity

          public QueryEntity(Class<?> keyCls,
                             Class<?> valCls)

      Creates a query entity with the given key and value types.
      Parameters:
        `keyCls` - Key type.
        `valCls` - Value type.

  - ### Method Detail

    - #### makePatch

          @NotNull
          public @NotNull QueryEntityPatch makePatch(QueryEntity target)

      Make query entity patch. This patch can only add properties to entity and can't remove them. Other words, the patch will contain only add operations(e.g. add column, create index) and not remove ones.
      Parameters:
        `target` - Query entity to which this entity should be expanded.
      Returns:
        Patch which contains operations for expanding this entity.

    - #### getKeyType

          public String getKeyType()

      Gets key type for this query pair.
      Returns:
        Key type.

    - #### findKeyType

          public String findKeyType()

      Attempts to get key type from fields in case it was not set directly.
      Returns:
        Key type.

    - #### setKeyType

          public QueryEntity setKeyType(String keyType)

      Sets key type for this query pair.
      Parameters:
        `keyType` - Key type.
      Returns:
        `this` for chaining.

    - #### getValueType

          public String getValueType()

      Gets value type for this query pair.
      Returns:
        Value type.

    - #### findValueType

          public String findValueType()

      Attempts to get value type from fields in case it was not set directly.
      Returns:
        Value type.

    - #### setValueType

          public QueryEntity setValueType(String valType)

      Sets value type for this query pair.
      Parameters:
        `valType` - Value type.
      Returns:
        `this` for chaining.

    - #### getFields

          public LinkedHashMap<String,String> getFields()

      Gets query fields for this query pair. The order of fields is important as it defines the order of columns returned by the 'select *' queries.
      Returns:
        Field-to-type map.

    - #### setFields

          public QueryEntity setFields(LinkedHashMap<String,String> fields)

      Sets query fields for this query pair. The order if fields is important as it defines the order of columns returned by the 'select *' queries.
      Parameters:
        `fields` - Field-to-type map.
      Returns:
        `this` for chaining.

    - #### getKeyFields

          public Set<String> getKeyFields()

      Gets query fields for this query pair that belongs to the key. We need this for the cases when no key-value classes are present on cluster nodes, and we need to build/modify keys and values during SQL DML operations. Thus, setting this parameter in XML is not mandatory and should be based on particular use case.
      Returns:
        Set of names of key fields.

    - #### setKeyFields

          public QueryEntity setKeyFields(Set<String> keyFields)

      Gets query fields for this query pair that belongs to the key. We need this for the cases when no key-value classes are present on cluster nodes, and we need to build/modify keys and values during SQL DML operations. Thus, setting this parameter in XML is not mandatory and should be based on particular use case.
      Parameters:
        `keyFields` - Set of names of key fields.
      Returns:
        `this` for chaining.

    - #### getKeyFieldName

          public String getKeyFieldName()

      Gets key field name.
      Returns:
        Key name.

    - #### setKeyFieldName

          public QueryEntity setKeyFieldName(String keyFieldName)

      Sets key field name.
      Parameters:
        `keyFieldName` - Key name.
      Returns:
        `this` for chaining.

    - #### getValueFieldName

          public String getValueFieldName()

      Get value field name.
      Returns:
        Value name.

    - #### setValueFieldName

          public QueryEntity setValueFieldName(String valueFieldName)

      Sets value field name.
      Parameters:
        `valueFieldName` - value name.
      Returns:
        `this` for chaining.

    - #### getIndexes

          @NotNull
          public @NotNull Collection<QueryIndex> getIndexes()

      Gets a collection of index entities.
      Returns:
        Collection of index entities.

    - #### getAliases

          public Map<String,String> getAliases()

      Gets aliases map.
      Returns:
        Aliases.

    - #### setAliases

          public QueryEntity setAliases(Map<String,String> aliases)

      Sets mapping from full property name in dot notation to an alias that will be used as SQL column name. Example: {"parent.name" -> "parentName"}.
      Parameters:
        `aliases` - Aliases map.
      Returns:
        `this` for chaining.

    - #### setIndexes

          public QueryEntity setIndexes(Collection<QueryIndex> idxs)

      Sets a collection of index entities.
      Parameters:
        `idxs` - Collection of index entities.
      Returns:
        `this` for chaining.

    - #### getTableName

          public String getTableName()

      Gets table name for this query entity.
      Returns:
        table name

    - #### setTableName

          public QueryEntity setTableName(String tableName)

      Sets table name for this query entity.
      Parameters:
        `tableName` - table name
      Returns:
        `this` for chaining.

    - #### getNotNullFields

          @Nullable
          public @Nullable Set<String> getNotNullFields()

      Gets names of fields that must be checked for null.
      Returns:
        Set of names of fields that must have non-null values.

    - #### setNotNullFields

          public QueryEntity setNotNullFields(@Nullable
                                              @Nullable Set<String> notNullFields)

      Sets names of fields that must checked for null.
      Parameters:
        `notNullFields` - Set of names of fields that must have non-null values.
      Returns:
        `this` for chaining.

    - #### getFieldsPrecision

          public Map<String,Integer> getFieldsPrecision()

      Returns:
        Precision map for a fields.

    - #### setFieldsPrecision

          public QueryEntity setFieldsPrecision(Map<String,Integer> fieldsPrecision)

      Sets fieldsPrecision map for a fields.
      Parameters:
        `fieldsPrecision` - Precision map for a fields.
      Returns:
        `This` for chaining.

    - #### getFieldsScale

          public Map<String,Integer> getFieldsScale()

      Returns:
        Scale map for a fields.

    - #### setFieldsScale

          public QueryEntity setFieldsScale(Map<String,Integer> fieldsScale)

      Sets fieldsScale map for a fields.
      Parameters:
        `fieldsScale` - Scale map for a fields.
      Returns:
        `This` for chaining.

    - #### getDefaultFieldValues

          public Map<String,Object> getDefaultFieldValues()

      Gets fields default values.
      Returns:
        Field's name to default value map.

    - #### setDefaultFieldValues

          public QueryEntity setDefaultFieldValues(Map<String,Object> defaultFieldValues)

      Sets fields default values.
      Parameters:
        `defaultFieldValues` - Field's name to default value map.
      Returns:
        `this` for chaining.

    - #### addQueryField

          public QueryEntity addQueryField(String fullName,
                                           String type,
                                           String alias)

      Utility method for building query entities programmatically.
      Parameters:
        `fullName` - Full name of the field.
        `type` - Type of the field.
        `alias` - Field alias.
      Returns:
        `this` for chaining.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023