Class CacheJdbcPojoStoreFactory<K,​V>

  • All Implemented Interfaces:
    Serializable, javax.cache.configuration.Factory<CacheAbstractJdbcStore<K,​V>>

    public class CacheJdbcPojoStoreFactory<K,​V>
    extends Object
    implements javax.cache.configuration.Factory<CacheAbstractJdbcStore<K,​V>>
    Factory implementation for CacheJdbcPojoStore. Use this factory to pass CacheJdbcPojoStore to CacheConfiguration.

    Please note, that setDataSource(DataSource) is deprecated and setDataSourceFactory(Factory) or setDataSourceBean(String) should be used instead.

    Spring Example

         <bean id= "myDataSource" class="org.h2.jdbcx.JdbcDataSource"/>
    
         <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
              ...
              <property name="cacheConfiguration">
                   <list>
                      <bean class="org.apache.ignite.configuration.CacheConfiguration">
                          <property name="name" value="myCache" />
                          ...
                          <property name="cacheStoreFactory">
                              <bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
                                  <property name="dataSourceBean" value="myDataSource" />
                                  <property name="types">
                                      <list>
                                          <bean class="org.apache.ignite.cache.store.jdbc.JdbcType">
                                              <property name="cacheName" value="myCache" />
                                              <property name="databaseSchema" value="MY_DB_SCHEMA" />
                                              <property name="databaseTable" value="PERSON" />
                                              <property name="keyType" value="java.lang.Integer" />
                                              <property name="keyFields">
                                                  <list>
                                                      <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                          <property name="databaseFieldType" >
                                                              <util:constant static-field="java.sql.Types.INTEGER"/>
                                                          </property>
                                                          <property name="databaseFieldName" value="ID" />
                                                          <property name="javaFieldType" value="java.lang.Integer" />
                                                          <property name="javaFieldName" value="id" />
                                                      </bean>
                                                  </list>
                                              </property>
                                              <property name="valueType" value="my.company.Person" />
                                              <property name="valueFields">
                                                  <list>
                                                      <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                          <property name="databaseFieldType" >
                                                              <util:constant static-field="java.sql.Types.VARCHAR"/>
                                                          </property>
                                                          <property name="databaseFieldName" value="NAME" />
                                                          <property name="javaFieldType" value="java.lang.String" />
                                                          <property name="javaFieldName" value="name" />
                                                      </bean>
                                                  </list>
                                              </property>
                                          </bean>
                                      </list>
                                  </property>
                              </bean>
                          </property>
                      </bean>
                   </list>
              </property>
         </bean>
     


    For information about Spring framework visit www.springframework.org

    See Also:
    Serialized Form
    • Field Detail

      • DFLT_WRITE_ATTEMPTS

        public static final int DFLT_WRITE_ATTEMPTS
        Default value for write attempts.
        See Also:
        Constant Field Values
      • DFLT_BATCH_SIZE

        public static final int DFLT_BATCH_SIZE
        Default batch size for put and remove operations.
        See Also:
        Constant Field Values
      • DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD

        public static final int DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD
        Default batch size for put and remove operations.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CacheJdbcPojoStoreFactory

        public CacheJdbcPojoStoreFactory()
    • Method Detail

      • create

        public CacheJdbcPojoStore<K,​V> create()
        Specified by:
        create in interface javax.cache.configuration.Factory<K>
      • getBatchSize

        public int getBatchSize()
        Get maximum batch size for write and delete operations.
        Returns:
        Maximum batch size.
      • setBatchSize

        public CacheJdbcPojoStoreFactory setBatchSize​(int batchSize)
        Set maximum batch size for write and delete operations.
        Parameters:
        batchSize - Maximum batch size.
        Returns:
        This for chaining.
      • getDataSourceBean

        public String getDataSourceBean()
        Gets name of the data source bean.
        Returns:
        Data source bean name.
      • setDataSourceBean

        public CacheJdbcPojoStoreFactory setDataSourceBean​(String dataSrcBean)
        Sets name of the data source bean.
        Parameters:
        dataSrcBean - Data source bean name.
        Returns:
        This for chaining.
      • getDialect

        public JdbcDialect getDialect()
        Get database dialect.
        Returns:
        Database dialect.
      • getMaximumPoolSize

        public int getMaximumPoolSize()
        Get maximum workers thread count. These threads are responsible for queries execution.
        Returns:
        Maximum workers thread count.
      • setMaximumPoolSize

        public CacheJdbcPojoStoreFactory setMaximumPoolSize​(int maxPoolSize)
        Set Maximum workers thread count. These threads are responsible for queries execution.
        Parameters:
        maxPoolSize - Max workers thread count.
        Returns:
        This for chaining.
      • getMaximumWriteAttempts

        public int getMaximumWriteAttempts()
        Gets maximum number of write attempts in case of database error.
        Returns:
        Maximum number of write attempts.
      • setMaximumWriteAttempts

        public CacheJdbcPojoStoreFactory setMaximumWriteAttempts​(int maxWrtAttempts)
        Sets maximum number of write attempts in case of database error.
        Parameters:
        maxWrtAttempts - Number of write attempts.
        Returns:
        This for chaining.
      • getParallelLoadCacheMinimumThreshold

        public int getParallelLoadCacheMinimumThreshold()
        Parallel load cache minimum row count threshold.
        Returns:
        If 0 then load sequentially.
      • setParallelLoadCacheMinimumThreshold

        public CacheJdbcPojoStoreFactory setParallelLoadCacheMinimumThreshold​(int parallelLoadCacheMinThreshold)
        Parallel load cache minimum row count threshold.
        Parameters:
        parallelLoadCacheMinThreshold - Minimum row count threshold. If 0 then load sequentially.
        Returns:
        This for chaining.
      • getTypes

        public JdbcType[] getTypes()
        Gets types known by store.
        Returns:
        Types known by store.
      • setTypes

        public CacheJdbcPojoStoreFactory setTypes​(JdbcType... types)
        Sets store configurations.
        Parameters:
        types - Store should process.
        Returns:
        This for chaining.
      • getHasher

        public JdbcTypeHasher getHasher()
        Gets hash code calculator.
        Returns:
        Hash code calculator.
      • getTransformer

        public JdbcTypesTransformer getTransformer()
        Gets types transformer.
        Returns:
        Types transformer.
      • getDataSourceFactory

        public javax.cache.configuration.Factory<DataSource> getDataSourceFactory()
        Gets factory for underlying datasource.
        Returns:
        Cache store factory.
      • setDataSourceFactory

        public CacheJdbcPojoStoreFactory<K,​V> setDataSourceFactory​(javax.cache.configuration.Factory<DataSource> dataSrcFactory)
        Sets factory for underlying datasource.
        Parameters:
        dataSrcFactory - Datasource factory.
        Returns:
        this for chaining.
      • isSqlEscapeAll

        public boolean isSqlEscapeAll()
        If true all the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName"). This enforces case sensitivity for field names and also allows having special characters in table and field names.
        Returns:
        Flag value.
      • setSqlEscapeAll

        public CacheJdbcPojoStoreFactory<K,​V> setSqlEscapeAll​(boolean sqlEscapeAll)
        If true all the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName"). This enforces case sensitivity for field names and also allows having special characters in table and field names.
        Parameters:
        sqlEscapeAll - Flag value.
        Returns:
        this for chaining.