|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.gigaspaces.datasource.hibernate.HibernateDataSource
@Deprecated public class HibernateDataSource
HibernateDataSource is a full Hibernate implementation of space external data source. Changing data - when space data is written/taken/removed/updated HibernateDataSource is responsible to perform the relevant changes at the external database. HibernateDataSource delegates these changes into external database via Hibernate 3.0 ORM. Reading data - when the space is queried about specific data and it is not found in the space HibernateDataSource is called to load the data from the database.DataProvider
is used for data read.DataPersister
is used for write/update/remove Bulk operations - in case of transactions and replication will invoke theBulkDataPersister
methods for persisting data. Complex queries against the space -SQLQuery
andExternalEntry
matching will invoke theSQLDataProvider
methods. See theDataProvider
,DataPersister
,SQLDataProvider
andBulkDataPersister
for full description of the methods mapping between the Space API and theHibernateDataSource
methods.
Configuration To use theHibernateDataSource
the space schema XML configuration file should include the following. <space-config> <persistent> <enabled>true</enabled> <StorageAdapterClass>com.gigaspaces.datasource.DataAdapter</StorageAdapterClass> </persistent> <external-data-source> <data-source-class>com.gigaspaces.datasource.hibernate.HibernateDataSource</data-source-class> <data-class>java.lang.Object</data-class> <supports-inheritance>true</supports-inheritance> <supports-version>false</supports-version> <usage>read-write</usage> </external-data-source> <engine> <cache_policy>0</cache_policy> </engine> </space-config> You may also use the following space properties: space-config.persistent.enabled=true<.b> space-config.persistent.StorageAdapterClass=com.j_spaces.sadapter.datasource.DataAdapter space-config.engine.cache_policy=0 space-config.external-data-source.data-source-class=com.gigaspaces.datasource.hibernate.HibernateDataSource space-config.external-data-source.init-properties-file=hibernate.properties When using theHibernateDataSource
the space-config.external-data-source.init-properties the content of this file will be passed on init to theHibernateDataSource
. You must use space-config.engine.cache_policy=0 (LRU policy) to activate the external datasource implementation. It is recommended to configure also the following to control the space memory usage and the eviction behavior: space-config.engine.memory_usage.enabled=true space-config.engine.memory_usage.high_watermark_percentage=95 space-config.engine.memory_usage.write_only_block_percentage=85 space-config.engine.memory_usage.write_only_check_percentage=76 space-config.engine.memory_usage.low_watermark_percentage=75 space-config.engine.memory_usage.eviction_batch_size=500
Field Summary | |
---|---|
protected Hashtable<String,org.hibernate.metadata.ClassMetadata> |
_metaDataTable
Deprecated. |
protected org.hibernate.SessionFactory |
_sessionFactory
Deprecated. |
Constructor Summary | |
---|---|
HibernateDataSource()
Deprecated. |
Method Summary | |
---|---|
int |
count(Object template)
Deprecated. |
void |
executeBulk(List<BulkItem> bulk)
Deprecated. This method is called in the following scenarios: 1. |
protected Object |
getId(Object template)
Deprecated. Return pojo identifier |
protected org.hibernate.metadata.ClassMetadata |
getMetadata(Object entry)
Deprecated. Return pojo entry metadata |
void |
init(Properties properties)
Deprecated. Initialize and configure the data source using given properties. |
DataIterator<Object> |
initialLoad()
Deprecated.
Creates and returns an iterator over all the entries that should be loaded into space. |
DataIterator<Object> |
iterator(Object template)
Deprecated. Create an iterator over all objects that match the given template. |
DataIterator<Object> |
iterator(SQLQuery<Object> query)
Deprecated. Create an iterator over all objects that match the given SQLQuery . |
Object |
read(Object template)
Deprecated. Read one object that matches the given template. |
void |
remove(Object object)
Deprecated. Remove the given object from the data store |
void |
setDataClass(Class dataClass)
Deprecated. |
void |
setSessionFactory(org.hibernate.SessionFactory _sessionFactory)
Deprecated. Injects a Hibernate session factory into the data source to be used |
void |
shutdown()
Deprecated. Close the data source and clean any used resources. |
void |
update(Object object)
Deprecated. Update the given object in the data store |
protected void |
validateKey(Serializable key,
Object entity)
Deprecated. Validate provided key and update the value key to be the provided key |
void |
write(Object object)
Deprecated. Write given new object to the data store |
void |
writeBatch(List<Object> objects)
Deprecated. Write given new objects to the data store. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.hibernate.SessionFactory _sessionFactory
protected Hashtable<String,org.hibernate.metadata.ClassMetadata> _metaDataTable
Constructor Detail |
---|
public HibernateDataSource()
Method Detail |
---|
public void init(Properties properties) throws DataSourceException
ManagedDataSource
init
in interface ManagedDataSource<Object>
properties
- - contains user defined param and Partition data
DataSourceException
public void setSessionFactory(org.hibernate.SessionFactory _sessionFactory)
public void setDataClass(Class dataClass)
public void shutdown() throws DataSourceException
ManagedDataSource
shutdown
in interface ManagedDataSource<Object>
DataSourceException
public Object read(Object template) throws DataSourceException
DataProvider
read
in interface DataProvider<Object>
DataSourceException
public void remove(Object object) throws DataSourceException
DataPersister
remove
in interface DataPersister<Object>
DataSourceException
public void update(Object object) throws DataSourceException
DataPersister
update
in interface DataPersister<Object>
DataSourceException
public void write(Object object) throws DataSourceException
DataPersister
write
in interface DataPersister<Object>
DataSourceException
public void writeBatch(List<Object> objects) throws DataSourceException
DataPersister
writeBatch
in interface DataPersister<Object>
DataSourceException
public void executeBulk(List<BulkItem> bulk) throws DataSourceException
1. Transaction commit
2. Asynchronize persistency mode This method can throw DataSourceException.
This exception will be delivered to the client application wrapped by
com.j_spaces.javax.cache.CacheException
executeBulk
in interface BulkDataPersister
bulk
- This bulkSet contains set of BulkItem
DataSourceException
- when the data store fails to persist the given list of objectspublic int count(Object template) throws DataSourceException
DataSourceException
public DataIterator<Object> iterator(Object template) throws DataSourceException
DataProvider
SQLDataProvider
interface is also implemented - the space will use SQLDataProvider
.iterator instead.
iterator
in interface DataProvider<Object>
DataIterator
or null if no data was found that match the given template
DataSourceException
public DataIterator<Object> iterator(SQLQuery<Object> query) throws DataSourceException
SQLDataProvider
Create an iterator over all objects that match the givenSQLQuery
. SQLQuery contains a string representation of SQL 'where' clause. The format matches thePreparedStatement
format(field1 = ? and field2 > ? and ....). The prepared values are accessible bySQLQuery
.getPreparedValues() method Example implementation with SQL PreparedStatement:PreparedStatement st = con.prepareStatement(query.getSelectAllQuery()); int index = 0; if(query.hasPreparedValues()) { for(Iterator iter = query.getPreparedValues().iterator();iter.hasNext()) { st.setObject(++index,iter.next()); } } ResultSet rs = st.executeQuery(); return new ResultSetIterator(rs);
iterator
in interface SQLDataProvider<Object>
DataIterator
or null if no data was found that match the given template
DataSourceException
protected void validateKey(Serializable key, Object entity)
key
- entity
- protected Object getId(Object template)
template
-
protected org.hibernate.metadata.ClassMetadata getMetadata(Object entry)
entry
-
public DataIterator<Object> initialLoad() throws DataSourceException
ManagedDataSource
Creates and returns an iterator over all the entries that should be loaded into space.
initialLoad
in interface ManagedDataSource<Object>
DataIterator
or null if no data should be loaded into space
DataSourceException
|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |