GigaSpaces XAP 9.0 API

com.gigaspaces.datasource
Interface SQLDataProvider<T>

All Superinterfaces:
ManagedDataSource<T>
All Known Subinterfaces:
ExternalDataSource<T>
All Known Implementing Classes:
CriteriaHibernateExternalDataSource, DefaultHibernateExternalDataSource, SQLDataProviderExceptionHandler, SQLDataProviderSplitter, StatelessHibernateExternalDataSource

public interface SQLDataProvider<T>
extends ManagedDataSource<T>

 SQLDataProvider should be implemented when complex queries are used 
 by the client.
 
 The space uses SQLDataProvider when the query can not be expressed as one template.
 Usually in the following scenarios:
- SQLQuery. - extended matching. - range values. SQLDataProvider is an interface that handles SQLQuery objects, generated by space. This interface This interface can be implemented instead of the DataProvider. In case that both interface are implemented - the space will choose SQLDataProvider.

Since:
6.0
Author:
anna

Field Summary
 
Fields inherited from interface com.gigaspaces.datasource.ManagedDataSource
DATA_CLASS_PROPS, NUMBER_OF_PARTITIONS, STATIC_PARTITION_NUMBER
 
Method Summary
 DataIterator<T> iterator(SQLQuery<T> query)
           Create an iterator over all objects that match the given SQLQuery.
 
Methods inherited from interface com.gigaspaces.datasource.ManagedDataSource
init, initialLoad, shutdown
 

Method Detail

iterator

DataIterator<T> iterator(SQLQuery<T> query)
                         throws DataSourceException
 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);
 
 

Returns:
a DataIterator or null if no data was found that match the given template
Throws:
DataSourceException

GigaSpaces XAP 9.0 API

Copyright © GigaSpaces.