public class GridCacheHibernateBlobStore<K,V> extends GridCacheStoreAdapter<K,V>
GridCacheStore implementation backed by Hibernate. This implementation
stores objects in underlying database in BLOB format.
setSessionFactory(SessionFactory) or
setHibernateConfigurationPath(String) or
setHibernateProperties(Properties) should be set.
If session factory is provided it should contain
GridCacheHibernateBlobStoreEntry persistent class (via provided
mapping file GridCacheHibernateStoreEntry.hbm.xml or by
adding GridCacheHibernateBlobStoreEntry to annotated classes
of session factory.
Path to hibernate configuration may be either an URL or a file path or
a classpath resource. This configuration file should include provided
mapping GridCacheHibernateStoreEntry.hbm.xml or include annotated
class GridCacheHibernateBlobStoreEntry.
If hibernate properties are provided, mapping
GridCacheHibernateStoreEntry.hbm.xml is included automatically.
...
GridCacheHibernateBlobStore<String, String> store = new GridCacheHibernateBlobStore<String, String>();
store.setSessionFactory(sesFactory);
...
...
<bean id="cache.hibernate.store"
class="org.gridgain.grid.cache.store.hibernate.GridCacheHibernateBlobStore">
<property name="sessionFactory">
<bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="hibernateProperties">
<value>
connection.url=jdbc:h2:mem:
show_sql=true
hbm2ddl.auto=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
</value>
</property>
<property name="mappingResources">
<list>
<value>
org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStoreEntry.hbm.xml
</value>
</list>
</property>
</bean>
</property>
</bean>
...
...
<bean id="cache.hibernate.store1"
class="org.gridgain.grid.cache.store.hibernate.GridCacheHibernateBlobStore">
<property name="sessionFactory">
<bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="hibernateProperties">
<value>
connection.url=jdbc:h2:mem:
show_sql=true
hbm2ddl.auto=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
</value>
</property>
<property name="annotatedClasses">
<list>
<value>
org.gridgain.grid.cache.store.hibernate.GridCacheHibernateBlobStoreEntry
</value>
</list>
</property>
</bean>
</property>
</bean>
...
...
<bean id="cache.hibernate.store2"
class="org.gridgain.grid.cache.store.hibernate.GridCacheHibernateBlobStore">
<property name="hibernateProperties">
<props>
<prop key="connection.url">jdbc:h2:mem:</prop>
<prop key="hbm2ddl.auto">update</prop>
<prop key="show_sql">true</prop>
</props>
</property>
</bean>
...
For information about Spring framework visit www.springframework.org
| Modifier and Type | Field and Description |
|---|---|
static String |
DFLT_CONN_URL
Default connection URL
(value is jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000).
|
static String |
DFLT_HBM2DDL_AUTO
Default hibernate.hbm2ddl.auto property value (value is true).
|
static String |
DFLT_SHOW_SQL
Default show SQL property value (value is true).
|
| Constructor and Description |
|---|
GridCacheHibernateBlobStore() |
| Modifier and Type | Method and Description |
|---|---|
protected <X> X |
fromBytes(byte[] bytes)
Deserialize object from byte array using marshaller.
|
V |
load(GridCacheTx tx,
K key)
Loads value for the key from underlying persistent storage.
|
void |
put(GridCacheTx tx,
K key,
V val)
Stores a given value in persistent storage.
|
void |
remove(GridCacheTx tx,
K key)
Removes the value identified by given key from persistent storage.
|
void |
setHibernateConfigurationPath(String hibernateCfgPath)
Sets hibernate configuration path.
|
void |
setHibernateProperties(Properties hibernateProps)
Sets Hibernate properties.
|
void |
setSessionFactory(org.hibernate.SessionFactory sesFactory)
Sets session factory.
|
protected byte[] |
toBytes(Object obj)
Serialize object to byte array using marshaller.
|
String |
toString() |
void |
txEnd(GridCacheTx tx,
boolean commit)
Default empty implementation for ending transactions.
|
loadAll, loadCache, putAll, removeAllpublic static final String DFLT_CONN_URL
public static final String DFLT_SHOW_SQL
public static final String DFLT_HBM2DDL_AUTO
public V load(@Nullable GridCacheTx tx, K key) throws GridException
tx - Cache transaction.key - Key to load.null if value was not found.GridException - If load failed.public void put(@Nullable
GridCacheTx tx,
K key,
@Nullable
V val)
throws GridException
null.tx - Cache transaction, if write-behind is not enabled, null otherwise.key - Key to put.val - Value to put.GridException - If put failed.public void remove(@Nullable
GridCacheTx tx,
K key)
throws GridException
null.tx - Cache transaction, if write-behind is not enabled, null otherwise.key - Key to remove.GridException - If remove failed.public void txEnd(GridCacheTx tx, boolean commit) throws GridException
txEnd in interface GridCacheStore<K,V>txEnd in class GridCacheStoreAdapter<K,V>tx - Cache transaction being ended.commit - True if transaction should commit, false for rollback.GridException - If commit or rollback failed. Note that commit failure in some cases
may bring cache transaction into GridCacheTxState.UNKNOWN which will
consequently cause all transacted entries to be invalidated.public void setSessionFactory(org.hibernate.SessionFactory sesFactory)
sesFactory - Session factory.public void setHibernateConfigurationPath(String hibernateCfgPath)
This may be either URL or file path or classpath resource.
hibernateCfgPath - URL or file path or classpath resource
pointing to hibernate configuration XML file.public void setHibernateProperties(Properties hibernateProps)
hibernateProps - Hibernate properties.protected byte[] toBytes(Object obj) throws GridException
obj - Object to convert to byte array.GridException - If failed to convert.protected <X> X fromBytes(byte[] bytes) throws GridException
X - Result object type.bytes - Bytes to deserialize.GridException - If failed.
Core Products
:
Data Grid ver. 6.0.2,
Streaming ver. 6.0.2
Accelerators
:
Hadoop Accelerator ver. 6.0.2
Release Date
:
March 24 2014