|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.ibatis.RollupRowHandler
public class RollupRowHandler
A RowHandler
that collapses multiple rows based on a set of properties.
The set of properties given act as a unique key. When the unique key changes, the collection
values from the nested ResultMap are coalesced and the given RowHandler
is called. It is
possible to embed several instances of this handler for deeply-nested ResultMap declarations.
Use this instance as a regular RowHandler
, but with one big exception: call RollupRowHandler.processLastResults()
after executing the SQL statement. Remove the groupBy attribute from the iBatis ResultMap
declaration.
Example iBatis:
Example usage:
<resultMap id="result_AuditQueryAllValues"
extends="alfresco.audit.result_AuditQueryNoValues"
class="AuditQueryResult">
<result property="auditValues" resultMap="alfresco.propval.result_PropertyIdSearchRow"/>
</resultMap>
RowHandler rowHandler = new RowHandler()
{
public void handleRow(Object valueObject)
{
// DO SOMETHING
}
};
RollupRowHandler rollupRowHandler = new RollupRowHandler(
new String[] {"auditEntryId"},
"auditValues",
rowHandler,
maxResults);
if (maxResults > 0)
{
// Calculate the maximum results required
int sqlMaxResults = (maxResults > 0 ? ((maxResults+1) * 20) : Integer.MAX_VALUE);
List
This class is not thread-safe; use a new instance for each use.
Constructor Summary | |
---|---|
RollupRowHandler(java.lang.String[] keyProperties,
java.lang.String collectionProperty,
com.ibatis.sqlmap.client.event.RowHandler rowHandler)
|
|
RollupRowHandler(java.lang.String[] keyProperties,
java.lang.String collectionProperty,
com.ibatis.sqlmap.client.event.RowHandler rowHandler,
int maxResults)
|
Method Summary | |
---|---|
void |
handleRow(java.lang.Object valueObject)
|
void |
processLastResults()
Client code must call this method once the query returns so that the final results can be passed to the inner RowHandler . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RollupRowHandler(java.lang.String[] keyProperties, java.lang.String collectionProperty, com.ibatis.sqlmap.client.event.RowHandler rowHandler)
keyProperties
- the properties that make up the unique keycollectionProperty
- the property mapped using a nested ResultMaprowHandler
- the row handler that will receive the rolled-up resultspublic RollupRowHandler(java.lang.String[] keyProperties, java.lang.String collectionProperty, com.ibatis.sqlmap.client.event.RowHandler rowHandler, int maxResults)
keyProperties
- the properties that make up the unique keycollectionProperty
- the property mapped using a nested ResultMaprowHandler
- the row handler that will receive the rolled-up resultsmaxResults
- the maximum number of results to retrieve (-1 for no limit).
Make sure that the query result limit is large enough to produce this
at least this number of resultsMethod Detail |
---|
public void handleRow(java.lang.Object valueObject)
handleRow
in interface com.ibatis.sqlmap.client.event.RowHandler
public void processLastResults()
RowHandler
. If a query is limited by size, then it is
possible that the unprocessed results represent an incomplete final object; in this case
it would be best to ignore the last results. If the query is complete (i.e. all results
are returned) then this method should be called.
If you want X results and each result is made up of N rows (on average), then set the query
limit to:
L = X * (N+1)
and don't call this method.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |