Class CacheJdbcPojoStoreFactory<K,V>
- java.lang.Object
-
- org.apache.ignite.cache.store.jdbc.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>>
Factoryimplementation forCacheJdbcPojoStore. Use this factory to passCacheJdbcPojoStoretoCacheConfiguration.Please note, that
setDataSource(DataSource)is deprecated andsetDataSourceFactory(Factory)orsetDataSourceBean(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 Summary
Fields Modifier and Type Field Description static intDFLT_BATCH_SIZEDefault batch size for put and remove operations.static intDFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLDDefault batch size for put and remove operations.static intDFLT_WRITE_ATTEMPTSDefault value for write attempts.
-
Constructor Summary
Constructors Constructor Description CacheJdbcPojoStoreFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CacheJdbcPojoStore<K,V>create()intgetBatchSize()Get maximum batch size for write and delete operations.StringgetDataSourceBean()Gets name of the data source bean.javax.cache.configuration.Factory<DataSource>getDataSourceFactory()Gets factory for underlying datasource.JdbcDialectgetDialect()Get database dialect.JdbcTypeHashergetHasher()Gets hash code calculator.intgetMaximumPoolSize()Get maximum workers thread count.intgetMaximumWriteAttempts()Gets maximum number of write attempts in case of database error.intgetParallelLoadCacheMinimumThreshold()Parallel load cache minimum row count threshold.JdbcTypesTransformergetTransformer()Gets types transformer.JdbcType[]getTypes()Gets types known by store.booleanisSqlEscapeAll()Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName").CacheJdbcPojoStoreFactorysetBatchSize(int batchSize)Set maximum batch size for write and delete operations.CacheJdbcPojoStoreFactory<K,V>setDataSource(DataSource dataSrc)Deprecated.CacheJdbcPojoStoreFactorysetDataSourceBean(String dataSrcBean)Sets name of the data source bean.CacheJdbcPojoStoreFactory<K,V>setDataSourceFactory(javax.cache.configuration.Factory<DataSource> dataSrcFactory)Sets factory for underlying datasource.CacheJdbcPojoStoreFactorysetDialect(JdbcDialect dialect)Set database dialect.CacheJdbcPojoStoreFactorysetHasher(JdbcTypeHasher hasher)Sets hash code calculator.CacheJdbcPojoStoreFactorysetMaximumPoolSize(int maxPoolSize)Set Maximum workers thread count.CacheJdbcPojoStoreFactorysetMaximumWriteAttempts(int maxWrtAttempts)Sets maximum number of write attempts in case of database error.CacheJdbcPojoStoreFactorysetParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold)Parallel load cache minimum row count threshold.CacheJdbcPojoStoreFactory<K,V>setSqlEscapeAll(boolean sqlEscapeAll)Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName").CacheJdbcPojoStoreFactorysetTransformer(JdbcTypesTransformer transformer)Sets types transformer.CacheJdbcPojoStoreFactorysetTypes(JdbcType... types)Sets store configurations.StringtoString()
-
-
-
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
-
-
Method Detail
-
create
public CacheJdbcPojoStore<K,V> create()
- Specified by:
createin interfacejavax.cache.configuration.Factory<K>
-
setDataSource
@Deprecated public CacheJdbcPojoStoreFactory<K,V> setDataSource(DataSource dataSrc)
Deprecated.Sets data source. Data source should be fully configured and ready-to-use.- Parameters:
dataSrc- Data source.- Returns:
Thisfor chaining.- See Also:
CacheAbstractJdbcStore.setDataSource(DataSource)
-
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:
Thisfor 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:
Thisfor chaining.
-
getDialect
public JdbcDialect getDialect()
Get database dialect.- Returns:
- Database dialect.
-
setDialect
public CacheJdbcPojoStoreFactory setDialect(JdbcDialect dialect)
Set database dialect.- Parameters:
dialect- Database dialect.- Returns:
Thisfor chaining.
-
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:
Thisfor 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:
Thisfor chaining.
-
getParallelLoadCacheMinimumThreshold
public int getParallelLoadCacheMinimumThreshold()
Parallel load cache minimum row count threshold.- Returns:
- If
0then load sequentially.
-
setParallelLoadCacheMinimumThreshold
public CacheJdbcPojoStoreFactory setParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold)
Parallel load cache minimum row count threshold.- Parameters:
parallelLoadCacheMinThreshold- Minimum row count threshold. If0then load sequentially.- Returns:
Thisfor 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:
Thisfor chaining.
-
getHasher
public JdbcTypeHasher getHasher()
Gets hash code calculator.- Returns:
- Hash code calculator.
-
setHasher
public CacheJdbcPojoStoreFactory setHasher(JdbcTypeHasher hasher)
Sets hash code calculator.- Parameters:
hasher- Hash code calculator.- Returns:
Thisfor chaining.
-
getTransformer
public JdbcTypesTransformer getTransformer()
Gets types transformer.- Returns:
- Types transformer.
-
setTransformer
public CacheJdbcPojoStoreFactory setTransformer(JdbcTypesTransformer transformer)
Sets types transformer.- Parameters:
transformer- Types transformer.- Returns:
Thisfor chaining.
-
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:
thisfor chaining.
-
isSqlEscapeAll
public boolean isSqlEscapeAll()
Iftrueall 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)
Iftrueall 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:
thisfor chaining.
-
-