sf logo

sf.qof
Interface Paging


public interface Paging

Marker interface for the code generator to implement paging.

Paging is database specific and therefore the SQL dialect needs to be defined before the query object is created.

The SQL select statement that is used will normally have an order by clause.

public interface PagedQueries extends BaseQuery, Paging { @Query(sql = "select id {%%.id}, name {%%.name} from person order by name") List<Person> listPersons() throws SQLException; ... } // use Oracle QueryObjectFactory.setSQLDialect(new OracleDialect()); // create a query object PagedQueries queries = QueryObjectFactory.createQueryObject(PagedQueries.class); // set the database connection queries.setConnection(connection); // set the first row number/offset (zero-based) queries.setFirstResult(10); // set the maximum number of results queries.setMaxResults(20); // run the query List<Person> personList = queries.listPersons(); // personList will contain the records 11 to 31 from the result set

See Also:
QueryObjectFactory.setSQLDialect(sf.qof.dialect.SQLDialect), SQLDialect

Method Summary
 Paging setFirstResult(int firstResult)
          Defines the first row of the result set to be returned.
 Paging setMaxResults(int maxResults)
          Defines the maximum number of rows that should be returned.
 

Method Detail

setFirstResult

Paging setFirstResult(int firstResult)
Defines the first row of the result set to be returned. Setting the maximum of rows and first result to zero disables paging. This is reset to 0 after each call to a query method.

Parameters:
firstResult - the zero based index of the first result row
Returns:
this

setMaxResults

Paging setMaxResults(int maxResults)
Defines the maximum number of rows that should be returned. Setting the maximum of rows and first result to zero disables paging. This is reset to 0 after each call to a query method.

Parameters:
maxResults - maximum number of rows
Returns:
this

sf logo

Copyright © 2007 brunella ltd. All Rights Reserved.