com.sap.ip.me.api.persist.query
Interface JQueryResult


public interface JQueryResult

QueryResult is a wrapper interface wrapping results of an executed query. Don't forget to release allocated resources using release() method.

Example:

 QueryResult res = myQuery.run(pm);
 try {
 	process(res);
 } finally {
 	res.release();
 }
 // don't access res here anymore! 
 

Author:
SAP
See Also:
JQuery, JQueryFactory

Method Summary
 MeIterator iterator()
          Get iterator over the query result.
 MeIterator iterator(JQueryResultBuilder resultBuilder)
          Get iterator over the query result.
 void prefetchAllRows()
          Cache all rows in the query in memory and release underlying SQL result set.
 void release()
          Release associated resources.
 boolean setEnableCache(boolean on)
          Set cache on query result iterator current instance.
 int size()
          Deprecated.  
 

Method Detail

iterator

public MeIterator iterator()
Get iterator over the query result. Iterator returns objects built as specified in query interface. It can either automatically bind data to user-specified object or bind them manually using a callback method. If no binding is specified, iterator returns arrays of objects with instances of query attribute values (in declaration order). It is suggested to use automatic data binding to a custom class.

Note: The iterator may reuse the returned object for next next() or previous() call. If you wish to disable this caching, you may use setEnableCache(boolean) to disable it.

Returns:
iterator over the query result.

iterator

public MeIterator iterator(JQueryResultBuilder resultBuilder)
Get iterator over the query result. Iterator returns objects built as specified in query interface. It can either automatically bind data to user-specified object or bind them manually using a callback method. If no binding is specified, iterator returns arrays of objects with instances of query attribute values (in declaration order). It is suggested to use automatic data binding to a custom class.

Note: The iterator may reuse the returned object for next next() or previous() call. If you wish to disable this caching, you may use setEnableCache(boolean) to disable it.

Parameters:
resultBuilder - result builder to change result row into custom row.
Returns:
iterator over the query result.

size

public int size()
Deprecated.  

Get the size of the query result.

Note: This method needs to actually execute the whole query in order to count # of returned elements. This poses a performance problem. Use with extreme caution!

Returns:
size of the query result (how many items will be returned by the iterator).

setEnableCache

public boolean setEnableCache(boolean on)
Set cache on query result iterator current instance. Query iterator may re-use the instance returned from next() call for the next next() call, i.e., just re-fill the data instead of creating a new, short-lived object. You may enable this behavior using this method. Caching is disabled by default.

Parameters:
on - if true, turn on the cache, if false, turn it off.
Returns:
original cache settings.

prefetchAllRows

public void prefetchAllRows()
Cache all rows in the query in memory and release underlying SQL result set. This is necessary for result to live over TX boundary. It is used internally by SmartSync implementation.

This method can only be called before obtaining the iterator.


release

public void release()
Release associated resources.



Copyright © 2005 SAP AG. All Rights Reserved.