org.apache.openjpa.jdbc.kernel
Class PagingResultObjectProvider

java.lang.Object
  extended by org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider
      extended by org.apache.openjpa.jdbc.kernel.PagingResultObjectProvider
All Implemented Interfaces:
ResultObjectProvider, Closeable

public class PagingResultObjectProvider
extends SelectResultObjectProvider

Object provider implementation that fetches one page of results at a a time as it scrolls. If the getPagedFields(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int, long) method returns a non-null bit set, this this provider is a good fit for your configuration. The method tests the following conditions:

To use this provider, select the candidate mapping with eager fetch mode set to join. This provider will take care of performing parallel mode batch selects for each page it reads.

Author:
Abe White

Constructor Summary
PagingResultObjectProvider(SelectExecutor sel, ClassMapping[] mappings, JDBCStore store, JDBCFetchConfiguration fetch, BitSet[] paged, long size)
          Constructor.
PagingResultObjectProvider(SelectExecutor sel, ClassMapping mapping, JDBCStore store, JDBCFetchConfiguration fetch, BitSet paged, long size)
          Constructor.
 
Method Summary
 boolean absolute(int pos)
          Move to the given 0-based position.
static BitSet getPagedFields(Select sel, ClassMapping mapping, JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode, long size)
          Return a bit set representing batch select fields that will be paged, or null if no fields need paging, which indicates that this provider should not be used.
 int getPageSize()
          Return the page size in use.
 Object getResultObject()
          Instantiate the current result object.
 boolean next()
          Advance the input to the next position.
 void open()
          Open the result.
 
Methods inherited from class org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider
close, getFetchConfiguration, getResult, getSelect, getStore, handleCheckedException, reset, setSize, size, supportsRandomAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagingResultObjectProvider

public PagingResultObjectProvider(SelectExecutor sel,
                                  ClassMapping mapping,
                                  JDBCStore store,
                                  JDBCFetchConfiguration fetch,
                                  BitSet paged,
                                  long size)
Constructor.

Parameters:
sel - the select to execute
mapping - the mapping of the result objects
store - the store manager to delegate loading to
fetch - the fetch configuration, or null for default
paged - the bit set returned from getPagedFields(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int, long)
size - the known maximum size of the result, or Long.MAX_VALUE for no known limit

PagingResultObjectProvider

public PagingResultObjectProvider(SelectExecutor sel,
                                  ClassMapping[] mappings,
                                  JDBCStore store,
                                  JDBCFetchConfiguration fetch,
                                  BitSet[] paged,
                                  long size)
Constructor.

Parameters:
sel - the select to execute
mappings - the mappings for the independent classes of the result objects
store - the store manager to delegate loading to
fetch - the fetch configuration, or null for default
paged - the bit sets returned from getPagedFields(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.jdbc.meta.ClassMapping, org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, int, long) for each select in the possible union
size - the known maximum size of the result, or Long.MAX_VALUE for no known limit
Method Detail

getPagedFields

public static BitSet getPagedFields(Select sel,
                                    ClassMapping mapping,
                                    JDBCStore store,
                                    JDBCFetchConfiguration fetch,
                                    int eagerMode,
                                    long size)
Return a bit set representing batch select fields that will be paged, or null if no fields need paging, which indicates that this provider should not be used.

See Also:
PagingResultObjectProvider(org.apache.openjpa.jdbc.sql.SelectExecutor, org.apache.openjpa.jdbc.meta.ClassMapping[], org.apache.openjpa.jdbc.kernel.JDBCStore, org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration, java.util.BitSet[], long)

getPageSize

public int getPageSize()
Return the page size in use.


open

public void open()
          throws SQLException
Description copied from interface: ResultObjectProvider
Open the result. This will be called before ResultObjectProvider.next(), ResultObjectProvider.absolute(int), or ResultObjectProvider.size().

Specified by:
open in interface ResultObjectProvider
Overrides:
open in class SelectResultObjectProvider
Throws:
SQLException

next

public boolean next()
             throws SQLException
Description copied from interface: ResultObjectProvider
Advance the input to the next position. Return true if there is more data; otherwise false.

Specified by:
next in interface ResultObjectProvider
Overrides:
next in class SelectResultObjectProvider
Throws:
SQLException

absolute

public boolean absolute(int pos)
                 throws SQLException
Description copied from interface: ResultObjectProvider
Move to the given 0-based position. This method is only called for providers that support random access. Return true if there is data at this position; otherwise false. This may be invoked in place of ResultObjectProvider.next().

Specified by:
absolute in interface ResultObjectProvider
Overrides:
absolute in class SelectResultObjectProvider
Throws:
SQLException

getResultObject

public Object getResultObject()
                       throws SQLException
Description copied from interface: ResultObjectProvider
Instantiate the current result object. This method will only be called after ResultObjectProvider.next() or ResultObjectProvider.absolute(int).

Throws:
SQLException


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.