org.openspaces.persistency.patterns
Class SQLDataProviderSplitter
java.lang.Object
org.openspaces.persistency.patterns.AbstractManagedDataSourceSplitter
org.openspaces.persistency.patterns.BulkDataPersisterSplitter
org.openspaces.persistency.patterns.SQLDataProviderSplitter
- All Implemented Interfaces:
- BulkDataPersister, ManagedDataSource, SQLDataProvider
public class SQLDataProviderSplitter
- extends BulkDataPersisterSplitter
- implements SQLDataProvider
A sql data provider that redirects the sql basded operatinos to the given data source that
can handle the given type.
- Author:
- kimchy
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SQLDataProviderSplitter
public SQLDataProviderSplitter(ManagedDataSourceEntriesProvider[] dataSources)
iterator
public DataIterator iterator(SQLQuery sqlQuery)
throws DataSourceException
- 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
- Returns:
- a
DataIterator
or null if no data was found that match the given template
- Throws:
DataSourceException
Copyright © GigaSpaces.