GigaSpaces XAP 7.0 API

org.openspaces.persistency.hibernate
Class DefaultHibernateExternalDataSource

java.lang.Object
  extended by org.openspaces.persistency.hibernate.AbstractHibernateExternalDataSource
      extended by org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource
All Implemented Interfaces:
BulkDataPersister, ManagedDataSource, SQLDataProvider, ManagedDataSourceEntriesProvider
Direct Known Subclasses:
CriteriaHibernateExternalDataSource

public class DefaultHibernateExternalDataSource
extends AbstractHibernateExternalDataSource
implements BulkDataPersister, SQLDataProvider

The default Hibernate external data source implementation. Based on Hibernate Session.

Author:
kimchy

Field Summary
 
Fields inherited from class org.openspaces.persistency.hibernate.AbstractHibernateExternalDataSource
HIBERNATE_CFG_PROPERTY, logger
 
Fields inherited from interface com.gigaspaces.datasource.ManagedDataSource
DATA_CLASS_PROPS, NUMBER_OF_PARTITIONS, STATIC_PARTITION_NUMBER
 
Constructor Summary
DefaultHibernateExternalDataSource()
           
 
Method Summary
 void executeBulk(List<BulkItem> bulkItems)
          Perform the given bulk changes using Hibernate Session.
protected  Serializable getIdentifier(Object o)
          Extracts and returns the hibernate object identifier
 DataIterator initialLoad()
          Performs the initial load operation.
 DataIterator iterator(SQLQuery sqlQuery)
          Returns a DefaultListQueryDataIterator for the given sql query.
 void setDeleteById(boolean deleteById)
          If set to true the object will be deleted using only its id.
 void setUseMerge(boolean useMerge)
          If set to true, will use Hibernate merge to perform the create/update, and will merge before calling delete.
 
Methods inherited from class org.openspaces.persistency.hibernate.AbstractHibernateExternalDataSource
createInitialLoadIterator, getFetchSize, getInitialLoadChunkSize, getInitialLoadEntries, getManagedEntries, getSessionFactory, init, isManagedEntry, isPerformOrderById, isUseScrollableResultSet, setFetchSize, setInitialLoadChunkSize, setInitialLoadEntries, setInitialLoadThreadPoolSize, setManagedEntries, setPerformOrderById, setSessionFactory, setUseScrollableResultSet, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.gigaspaces.datasource.ManagedDataSource
init, shutdown
 

Constructor Detail

DefaultHibernateExternalDataSource

public DefaultHibernateExternalDataSource()
Method Detail

setUseMerge

public void setUseMerge(boolean useMerge)
If set to true, will use Hibernate merge to perform the create/update, and will merge before calling delete. This might be required for complex mappings (depends on Hibernate) at the expense of slower performance. Defaults to false.


setDeleteById

public void setDeleteById(boolean deleteById)
If set to true the object will be deleted using only its id. If set to false the object will be deleted using the whole object. Defaults to true.

Parameters:
deleteById -

executeBulk

public void executeBulk(List<BulkItem> bulkItems)
                 throws DataSourceException
Perform the given bulk changes using Hibernate Session.

Note, this implementation relies on Hibernate NonUniqueObjectException in case the entity is already associated with the given session, and in such a case, will result in performing merge operation (which is more expensive).

Specified by:
executeBulk in interface BulkDataPersister
Parameters:
bulkItems - list of data object and the operation to apply on that object
Throws:
DataSourceException - when the data store fails to persist the given list of objects

iterator

public DataIterator iterator(SQLQuery sqlQuery)
                      throws DataSourceException
Returns a DefaultListQueryDataIterator for the given sql query.

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

initialLoad

public DataIterator initialLoad()
                         throws DataSourceException
Performs the initial load operation. Iterates over the AbstractHibernateExternalDataSource.setInitialLoadEntries(String[]) initial load entries. If AbstractHibernateExternalDataSource.getInitialLoadChunkSize() is set to -1, will use DefaultScrollableDataIterator for each entity. If AbstractHibernateExternalDataSource.getInitialLoadChunkSize() is set to a non -1 value, will use the DefaultChunkScrollableDataIterator.

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

getIdentifier

protected Serializable getIdentifier(Object o)
Extracts and returns the hibernate object identifier

Parameters:
o -
Returns:

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.