org.apache.ignite.cache.store.jdbc

## Class CacheJdbcPojoStore<K,V>

- java.lang.Object
- - org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore<K,V>
  - - org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore<K,V>

- All Implemented Interfaces:
    javax.cache.integration.CacheLoader<K,V>, javax.cache.integration.CacheWriter<K,V>, CacheStore<K,V>, LifecycleAware

      public class CacheJdbcPojoStore<K,V>
      extends CacheAbstractJdbcStore<K,V>

  Implementation of `CacheStore` backed by JDBC and POJO via reflection. This implementation stores objects in underlying database using java beans mapping description via reflection.

  Use `CacheJdbcPojoStoreFactory` factory to pass `CacheJdbcPojoStore` to `CacheConfiguration`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore

      `CacheAbstractJdbcStore.EntryMapping, CacheAbstractJdbcStore.TypeKind`

  - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore

      `ATTR_CONN_PROP, BUILT_IN_TYPES, cacheMappings, dataSrc, dialect, hasher, ignite, log, transformer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheJdbcPojoStore()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `buildBinaryObject(String typeName, JdbcTypeField[] fields, Map<String,Integer> loadColIdxs, ResultSet rs)` Construct binary object from query result.
    `protected <R> R` | `buildObject(@Nullable String cacheName, String typeName, CacheAbstractJdbcStore.TypeKind typeKind, JdbcTypeField[] flds, Map<String,Integer> loadColIdxs, ResultSet rs)` Construct object from query result.
    `protected @Nullable Object` | `extractParameter(@Nullable String cacheName, String typeName, CacheAbstractJdbcStore.TypeKind typeKind, String fldName, Object obj)` Get field value from object for use as query parameter.
    `protected void` | `prepareBuilders(@Nullable String cacheName, Collection<JdbcType> types)` Prepare internal store specific builders for provided types metadata.
    `String` | `toString()`
    `protected Object` | `typeIdForObject(Object obj)` Calculate type ID for object.
    `protected Object` | `typeIdForTypeName(CacheAbstractJdbcStore.TypeKind kind, String typeName)` Calculate type ID for given type name.

    - ### Methods inherited from class org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore

      `closeConnection, columnIndex, connection, delete, deleteAll, end, fillKeyParameters, fillKeyParameters, fillParameter, fillValueParameters, getBatchSize, getDataSource, getDialect, getHasher, getMaximumPoolSize, getMaximumWriteAttempts, getParallelLoadCacheMinimumThreshold, getTransformer, getTypes, ignite, isSqlEscapeAll, kindForName, kindForName, load, loadAll, loadCache, openConnection, resolveDialect, session, sessionEnd, setBatchSize, setDataSource, setDialect, setHasher, setMaximumPoolSize, setMaximumWriteAttempts, setParallelLoadCacheMinimumThreshold, setSqlEscapeAll, setTransformer, setTypes, start, stop, write, writeAll`

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

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

- - ### Constructor Detail

    - #### CacheJdbcPojoStore

          public CacheJdbcPojoStore()

  - ### Method Detail

    - #### extractParameter

          @Nullable
          protected @Nullable Object extractParameter(@Nullable
                                                                @Nullable String cacheName,
                                                                String typeName,
                                                                CacheAbstractJdbcStore.TypeKind typeKind,
                                                                String fldName,
                                                                Object obj)
                                                         throws javax.cache.CacheException

      Get field value from object for use as query parameter.
      Specified by:
        `extractParameter` in class `CacheAbstractJdbcStore<K,V>`
      Parameters:
        `cacheName` - Cache name.
        `typeName` - Type name.
        `fldName` - Field name.
        `obj` - Cache object.
        `typeKind` - Type kind.
      Returns:
        Field value from object.
      Throws:
        `javax.cache.CacheException` - in case of error.

    - #### buildObject

          protected <R> R buildObject(@Nullable
                                      @Nullable String cacheName,
                                      String typeName,
                                      CacheAbstractJdbcStore.TypeKind typeKind,
                                      JdbcTypeField[] flds,
                                      Map<String,Integer> loadColIdxs,
                                      ResultSet rs)
                               throws javax.cache.integration.CacheLoaderException

      Construct object from query result.
      Specified by:
        `buildObject` in class `CacheAbstractJdbcStore<K,V>`
      Type Parameters:
        `R` - Type of result object.
      Parameters:
        `cacheName` - Cache name.
        `typeName` - Type name.
        `typeKind` - Type kind.
        `flds` - Fields descriptors.
        `loadColIdxs` - Select query columns index.
        `rs` - ResultSet.
      Returns:
        Constructed object.
      Throws:
        `javax.cache.integration.CacheLoaderException` - If failed to construct cache object.

    - #### buildBinaryObject

          protected Object buildBinaryObject(String typeName,
                                             JdbcTypeField[] fields,
                                             Map<String,Integer> loadColIdxs,
                                             ResultSet rs)
                                      throws javax.cache.integration.CacheLoaderException

      Construct binary object from query result.
      Parameters:
        `typeName` - Type name.
        `fields` - Fields descriptors.
        `loadColIdxs` - Select query columns index.
        `rs` - ResultSet.
      Returns:
        Constructed binary object.
      Throws:
        `javax.cache.integration.CacheLoaderException` - If failed to construct binary object.

    - #### typeIdForObject

          protected Object typeIdForObject(Object obj)
                                    throws javax.cache.CacheException

      Calculate type ID for object.
      Specified by:
        `typeIdForObject` in class `CacheAbstractJdbcStore<K,V>`
      Parameters:
        `obj` - Object to calculate type ID for.
      Returns:
        Type ID.
      Throws:
        `javax.cache.CacheException` - If failed to calculate type ID for given object.

    - #### typeIdForTypeName

          protected Object typeIdForTypeName(CacheAbstractJdbcStore.TypeKind kind,
                                             String typeName)
                                      throws javax.cache.CacheException

      Calculate type ID for given type name.
      Specified by:
        `typeIdForTypeName` in class `CacheAbstractJdbcStore<K,V>`
      Parameters:
        `kind` - If `true` then calculate type ID for POJO otherwise for binary object .
        `typeName` - String description of type name.
      Returns:
        Type ID.
      Throws:
        `javax.cache.CacheException` - If failed to get type ID for given type name.

    - #### prepareBuilders

          protected void prepareBuilders(@Nullable
                                         @Nullable String cacheName,
                                         Collection<JdbcType> types)
                                  throws javax.cache.CacheException

      Prepare internal store specific builders for provided types metadata.
      Specified by:
        `prepareBuilders` in class `CacheAbstractJdbcStore<K,V>`
      Parameters:
        `cacheName` - Cache name to prepare builders for.
        `types` - Collection of types.
      Throws:
        `javax.cache.CacheException` - If failed to prepare internal builders for types.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022