public class GridCacheHibernateBlobStore<K,V>
extends org.gridgain.grid.cache.store.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(org.gridgain.grid.cache.GridCacheTx tx,
K key) |
void |
put(org.gridgain.grid.cache.GridCacheTx tx,
K key,
V val) |
void |
remove(org.gridgain.grid.cache.GridCacheTx tx,
K key) |
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(org.gridgain.grid.cache.GridCacheTx tx,
boolean commit) |
public static final String DFLT_CONN_URL
public static final String DFLT_SHOW_SQL
public static final String DFLT_HBM2DDL_AUTO
public V load(@Nullable org.gridgain.grid.cache.GridCacheTx tx, K key) throws org.gridgain.grid.GridException
org.gridgain.grid.GridExceptionpublic void put(@Nullable
org.gridgain.grid.cache.GridCacheTx tx,
K key,
@Nullable
V val)
throws org.gridgain.grid.GridException
org.gridgain.grid.GridExceptionpublic void remove(@Nullable
org.gridgain.grid.cache.GridCacheTx tx,
K key)
throws org.gridgain.grid.GridException
org.gridgain.grid.GridExceptionpublic void txEnd(org.gridgain.grid.cache.GridCacheTx tx,
boolean commit)
throws org.gridgain.grid.GridException
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 org.gridgain.grid.GridException
obj - Object to convert to byte array.org.gridgain.grid.GridException - If failed to convert.protected <X> X fromBytes(byte[] bytes)
throws org.gridgain.grid.GridException
X - Result object type.bytes - Bytes to deserialize.org.gridgain.grid.GridException - If failed.
GridGain Fabric : ver. 6.6.9-p1 Release Date : August 10 2016