Class CacheJdbcBlobStore<K,V>
- java.lang.Object
- 
- org.apache.ignite.cache.store.CacheStoreAdapter<K,V>
- 
- org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStore<K,V>
 
 
- 
- All Implemented Interfaces:
- javax.cache.integration.CacheLoader<K,V>,- javax.cache.integration.CacheWriter<K,V>,- CacheStore<K,V>
 
 public class CacheJdbcBlobStore<K,V> extends CacheStoreAdapter<K,V> CacheStoreimplementation backed by JDBC. This implementation stores objects in underlying database inBLOBformat.Store will create table ENTRIESin the database to store data. Table will havekeyandvalfields.If custom DDL and DML statements are provided, table and field names have to be consistent for all statements and sequence of parameters have to be preserved. ConfigurationSections below describe mandatory and optional configuration settings as well as providing example using Java and Spring XML.MandatoryThere are no mandatory configuration parameters.Optional- Data source (see setDataSource(DataSource)
- Connection URL (see setConnectionUrl(String))
- User name (see setUser(String))
- Password (see setPassword(String))
- Create table query (see setConnectionUrl(String))
- Load entry query (see setLoadQuery(String))
- Update entry query (see setUpdateQuery(String))
- Insert entry query (see setInsertQuery(String))
- Delete entry query (see setDeleteQuery(String))
 Use CacheJdbcBlobStoreFactoryfactory to passCacheJdbcBlobStoretoCacheConfiguration.
- 
- 
Field SummaryFields Modifier and Type Field Description static StringDFLT_CONN_URLDefault connection URL (value is jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1).static StringDFLT_CREATE_TBL_QRYDefault create table query (value is create table if not exists ENTRIES (akey binary primary key, val binary)).static StringDFLT_DEL_QRYDefault delete entry query (value is delete from ENTRIES where akey=?static StringDFLT_INSERT_QRYDefault insert entry query (value is insert into ENTRIES (akey, val) values (?static StringDFLT_LOAD_QRYDefault load entry query (value is select * from ENTRIES where akey=?static StringDFLT_UPDATE_QRYDefault update entry query (value is select * from ENTRIES where akey=?
 - 
Constructor SummaryConstructors Constructor Description CacheJdbcBlobStore()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(Object key)protected <X> XfromBytes(byte[] bytes)Deserialize object from byte array using marshaller.Vload(K key)protected CacheStoreSessionsession()voidsessionEnd(boolean commit)Default empty implementation for ending transactions.voidsetConnectionUrl(String connUrl)Sets connection URL.voidsetCreateTableQuery(String createTblQry)Sets create table query.voidsetDataSource(DataSource dataSrc)Sets data source.voidsetDeleteQuery(String delQry)Sets delete entry query.voidsetInitSchema(boolean initSchema)Flag indicating whether DB schema should be initialized by Ignite (default behaviour) or was explicitly created by user.voidsetInsertQuery(String insertQry)Sets insert entry query.voidsetLoadQuery(String loadQry)Sets load query.voidsetPassword(String passwd)Sets password for database access.voidsetUpdateQuery(String updateQry)Sets update entry query.voidsetUser(String user)Sets user name for database access.protected byte[]toBytes(Object obj)Serialize object to byte array using marshaller.StringtoString()voidwrite(javax.cache.Cache.Entry<? extends K,? extends V> entry)- 
Methods inherited from class org.apache.ignite.cache.store.CacheStoreAdapterdeleteAll, loadAll, loadCache, writeAll
 
- 
 
- 
- 
- 
Field Detail- 
DFLT_CONN_URLpublic static final String DFLT_CONN_URL Default connection URL (value is jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1).- See Also:
- Constant Field Values
 
 - 
DFLT_CREATE_TBL_QRYpublic static final String DFLT_CREATE_TBL_QRY Default create table query (value is create table if not exists ENTRIES (akey binary primary key, val binary)).- See Also:
- Constant Field Values
 
 - 
DFLT_LOAD_QRYpublic static final String DFLT_LOAD_QRY Default load entry query (value is select * from ENTRIES where akey=?).- See Also:
- Constant Field Values
 
 - 
DFLT_UPDATE_QRYpublic static final String DFLT_UPDATE_QRY Default update entry query (value is select * from ENTRIES where akey=?).- See Also:
- Constant Field Values
 
 - 
DFLT_INSERT_QRYpublic static final String DFLT_INSERT_QRY Default insert entry query (value is insert into ENTRIES (akey, val) values (?, ?)).- See Also:
- Constant Field Values
 
 - 
DFLT_DEL_QRYpublic static final String DFLT_DEL_QRY Default delete entry query (value is delete from ENTRIES where akey=?).- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
sessionEndpublic void sessionEnd(boolean commit) Default empty implementation for ending transactions. Note that if explicit cache transactions are not used, then transactions do not have to be explicitly ended - for all other cases this method should be overridden with custom commit/rollback logic.- Specified by:
- sessionEndin interface- CacheStore<K,V>
- Overrides:
- sessionEndin class- CacheStoreAdapter<K,V>
- Parameters:
- commit-- Trueif transaction should commit,- falsefor rollback.
 
 - 
deletepublic void delete(Object key) 
 - 
setInitSchemapublic void setInitSchema(boolean initSchema) Flag indicating whether DB schema should be initialized by Ignite (default behaviour) or was explicitly created by user.- Parameters:
- initSchema-- Trueif DB schema should be initialized by Ignite (default behaviour), {code @false} if schema was explicitly created by user.
 
 - 
setConnectionUrlpublic void setConnectionUrl(String connUrl) Sets connection URL.- Parameters:
- connUrl- Connection URL.
 
 - 
setCreateTableQuerypublic void setCreateTableQuery(String createTblQry) Sets create table query.- Parameters:
- createTblQry- Create table query.
 
 - 
setLoadQuerypublic void setLoadQuery(String loadQry) Sets load query.- Parameters:
- loadQry- Load query
 
 - 
setUpdateQuerypublic void setUpdateQuery(String updateQry) Sets update entry query.- Parameters:
- updateQry- Update entry query.
 
 - 
setInsertQuerypublic void setInsertQuery(String insertQry) Sets insert entry query.- Parameters:
- insertQry- Insert entry query.
 
 - 
setDeleteQuerypublic void setDeleteQuery(String delQry) Sets delete entry query.- Parameters:
- delQry- Delete entry query.
 
 - 
setUserpublic void setUser(String user) Sets user name for database access.- Parameters:
- user- User name.
 
 - 
setPasswordpublic void setPassword(String passwd) Sets password for database access.- Parameters:
- passwd- Password.
 
 - 
setDataSourcepublic void setDataSource(DataSource dataSrc) Sets data source. Data source should be fully configured and ready-to-use.Note that if data source is provided, all connections will be acquired via this data source. If data source is not provided, a new connection will be created for each store call ( connectionUrl,userandpasswordparameters will be used).- Parameters:
- dataSrc- Data source.
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- CacheStoreAdapter<K,V>
 
 - 
toBytesprotected byte[] toBytes(Object obj) throws IgniteCheckedException Serialize object to byte array using marshaller.- Parameters:
- obj- Object to convert to byte array.
- Returns:
- Byte array.
- Throws:
- IgniteCheckedException- If failed to convert.
 
 - 
fromBytesprotected <X> X fromBytes(byte[] bytes) throws IgniteCheckedExceptionDeserialize object from byte array using marshaller.- Type Parameters:
- X- Result object type.
- Parameters:
- bytes- Bytes to deserialize.
- Returns:
- Deserialized object.
- Throws:
- IgniteCheckedException- If failed.
 
 - 
sessionprotected CacheStoreSession session() - Returns:
- Store session.
 
 
- 
 
-