GigaSpaces XAP 7.0 API

com.gigaspaces.datasource.hibernate
Class HibernateDataSource

java.lang.Object
  extended by com.gigaspaces.datasource.hibernate.HibernateDataSource
All Implemented Interfaces:
BulkDataPersister, DataPersister<Object>, DataProvider<Object>, ExternalDataSource<Object>, ManagedDataSource<Object>, SQLDataProvider<Object>

Deprecated. use org.openspaces.persistency.hibernate package instead

@Deprecated
public class HibernateDataSource
extends Object
implements ExternalDataSource<Object>

 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 the BulkDataPersister methods for persisting data.
 Complex queries against the space - SQLQuery and ExternalEntry matching will invoke the SQLDataProvider methods.

 See the DataProvider, DataPersister, SQLDataProvider  and BulkDataPersister for full description of the methods mapping between the Space API and the HibernateDataSource methods.
Configuration To use the HibernateDataSource 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 the HibernateDataSource the space-config.external-data-source.init-properties the content of this file will be passed on init to the HibernateDataSource. 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

Since:
6.0
Author:
anna

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

_sessionFactory

protected org.hibernate.SessionFactory _sessionFactory
Deprecated. 

_metaDataTable

protected Hashtable<String,org.hibernate.metadata.ClassMetadata> _metaDataTable
Deprecated. 
Constructor Detail

HibernateDataSource

public HibernateDataSource()
Deprecated. 
Method Detail

init

public void init(Properties properties)
          throws DataSourceException
Deprecated. 
Description copied from interface: ManagedDataSource
Initialize and configure the data source using given properties.
Called when space is started.
The properties are loaded from a file that can be defined in the space schema or as a property named:

space-config.ExternalDataSource.properties-file partitionId and number of partitions are also in the Properties - can be read with STATIC_PARTITION_NUMBER and NUMBER_OF_PARTITIONS

Specified by:
init in interface ManagedDataSource<Object>
Parameters:
properties - - contains user defined param and Partition data
Throws:
DataSourceException

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory _sessionFactory)
Deprecated. 
Injects a Hibernate session factory into the data source to be used


setDataClass

public void setDataClass(Class dataClass)
Deprecated. 

shutdown

public void shutdown()
              throws DataSourceException
Deprecated. 
Description copied from interface: ManagedDataSource
Close the data source and clean any used resources.
Called before space shutdown.

Specified by:
shutdown in interface ManagedDataSource<Object>
Throws:
DataSourceException

read

public Object read(Object template)
            throws DataSourceException
Deprecated. 
Description copied from interface: DataProvider
Read one object that matches the given template.
Used by the space for read templates with UID.

Specified by:
read in interface DataProvider<Object>
Returns:
matched object or null
Throws:
DataSourceException

remove

public void remove(Object object)
            throws DataSourceException
Deprecated. 
Description copied from interface: DataPersister
Remove the given object from the data store

Specified by:
remove in interface DataPersister<Object>
Throws:
DataSourceException

update

public void update(Object object)
            throws DataSourceException
Deprecated. 
Description copied from interface: DataPersister
Update the given object in the data store

Specified by:
update in interface DataPersister<Object>
Throws:
DataSourceException

write

public void write(Object object)
           throws DataSourceException
Deprecated. 
Description copied from interface: DataPersister
Write given new object to the data store

Specified by:
write in interface DataPersister<Object>
Throws:
DataSourceException

writeBatch

public void writeBatch(List<Object> objects)
                throws DataSourceException
Deprecated. 
Description copied from interface: DataPersister
Write given new objects to the data store.

If the implementation uses transactions,
all the objects must be written in one transaction.

Specified by:
writeBatch in interface DataPersister<Object>
Throws:
DataSourceException

executeBulk

public void executeBulk(List<BulkItem> bulk)
                 throws DataSourceException
Deprecated. 
This method is called in the following scenarios:

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

Specified by:
executeBulk in interface BulkDataPersister
Parameters:
bulk - This bulkSet contains set of BulkItem
Throws:
DataSourceException - when the data store fails to persist the given list of objects

count

public int count(Object template)
          throws DataSourceException
Deprecated. 
Throws:
DataSourceException

iterator

public DataIterator<Object> iterator(Object template)
                              throws DataSourceException
Deprecated. 
Description copied from interface: DataProvider
Create an iterator over all objects that match the given template.
Note: null value can be passed - in case of a null template or at initial space load. If SQLDataProvider interface is also implemented - the space will use SQLDataProvider.iterator instead.

Specified by:
iterator in interface DataProvider<Object>
Returns:
a DataIterator or null if no data was found that match the given template
Throws:
DataSourceException

iterator

public DataIterator<Object> iterator(SQLQuery<Object> query)
                              throws DataSourceException
Deprecated. 
Description copied from interface: SQLDataProvider
 Create an iterator over all objects that match the given SQLQuery.
 SQLQuery contains a string representation of SQL 'where' clause.
 The format matches the PreparedStatement format(field1 = ? and field2 > ? and ....).
 The prepared values are accessible by SQLQuery.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);
 
 

Specified by:
iterator in interface SQLDataProvider<Object>
Returns:
a DataIterator or null if no data was found that match the given template
Throws:
DataSourceException

validateKey

protected void validateKey(Serializable key,
                           Object entity)
Deprecated. 
Validate provided key and update the value key to be the provided key

Parameters:
key -
entity -

getId

protected Object getId(Object template)
Deprecated. 
Return pojo identifier

Parameters:
template -
Returns:

getMetadata

protected org.hibernate.metadata.ClassMetadata getMetadata(Object entry)
Deprecated. 
Return pojo entry metadata

Parameters:
entry -
Returns:
returns the ClassMetadata associated with the given entity name; may return null.

initialLoad

public DataIterator<Object> initialLoad()
                                 throws DataSourceException
Deprecated. 
Description copied from interface: ManagedDataSource
Creates and returns an iterator over all the entries that should be loaded into space.

Specified by:
initialLoad in interface ManagedDataSource<Object>
Returns:
a DataIterator or null if no data should be loaded into space
Throws:
DataSourceException

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.