public class CacheHibernateBlobStore<K,V> extends CacheStoreAdapter<K,V>
CacheStore
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
CacheHibernateBlobStoreEntry
persistent class (via provided
mapping file GridCacheHibernateStoreEntry.hbm.xml
or by
adding CacheHibernateBlobStoreEntry
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 CacheHibernateBlobStoreEntry
.
If hibernate properties are provided, mapping
GridCacheHibernateStoreEntry.hbm.xml
is included automatically.
... CacheHibernateBlobStore<String, String> store = new CacheHibernateBlobStore<String, String>(); store.setSessionFactory(sesFactory); ...
... <bean id="cache.hibernate.store" class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore"> <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/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml </value> </list> </property> </bean> </property> </bean> ...
... <bean id="cache.hibernate.store1" class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore"> <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.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry </value> </list> </property> </bean> </property> </bean> ...
... <bean id="cache.hibernate.store2" class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore"> <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 |
---|
CacheHibernateBlobStore() |
Modifier and Type | Method and Description |
---|---|
void |
delete(Object key) |
protected <X> X |
fromBytes(byte[] bytes)
Deserialize object from byte array using marshaller.
|
V |
load(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(boolean commit)
Default empty implementation for ending transactions.
|
void |
write(javax.cache.Cache.Entry<? extends K,? extends V> entry) |
deleteAll, loadAll, loadCache, writeAll
public static final String DFLT_CONN_URL
public static final String DFLT_SHOW_SQL
public static final String DFLT_HBM2DDL_AUTO
public void delete(Object key)
public void txEnd(boolean commit)
txEnd
in interface CacheStore<K,V>
txEnd
in class CacheStoreAdapter<K,V>
commit
- True
if transaction should commit, false
for rollback.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 IgniteCheckedException
obj
- Object to convert to byte array.IgniteCheckedException
- If failed to convert.protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException
X
- Result object type.bytes
- Bytes to deserialize.IgniteCheckedException
- If failed.
Follow @ApacheIgnite
Apache Ignite Fabric : ver. 1.0.0-RC3 Release Date : March 24 2015