|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hdpagination.dataaccess.jdbc.JdbcQueryTemplate
public abstract class JdbcQueryTemplate
The type of QueryTemplate to run a pagination based query against JDBC.
Different of database providers (e.g. Oracle, MySQl, DB2, HSQLDB) have their own implementation class
which extends from this abstract class. They share common code to execute query but have different way
to translate the original sql to a pagination based sql based on their own sql syntax. Because of this,
QueryTemplate implementation class for particular database provider must implement its own method
convertPaginationSql. For some provider,it even has to override the method convertCountSql
if the default way (implemented in this class) to translate the original sql to 'count total records' sql
does not work properly in that database.
| Constructor Summary | |
|---|---|
JdbcQueryTemplate(javax.sql.DataSource dataSource)
|
|
| Method Summary | |
|---|---|
protected java.lang.String |
convertCountSql(java.lang.String querySql)
Translate original query sql to the sql which can be used to query the count of total records. |
protected abstract java.lang.String |
convertPaginationSql(java.lang.String sql,
int pageNo,
int pageSize)
Translate original query sql to pagination based sql |
int |
countRows(QueryCallback callback)
query total number of records for this search |
java.util.List |
query(QueryCallback callback,
int pageSize,
int pageNo)
execute query and return only one page of data |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JdbcQueryTemplate(javax.sql.DataSource dataSource)
dataSource - DataSource that the query is executed against| Method Detail |
|---|
public java.util.List query(QueryCallback callback,
int pageSize,
int pageNo)
QueryTemplate
query in interface QueryTemplatepageSize - number of records per pagepageNo - index of current page,index begins with 0.
public int countRows(QueryCallback callback)
QueryTemplate
countRows in interface QueryTemplate
protected abstract java.lang.String convertPaginationSql(java.lang.String sql,
int pageNo,
int pageSize)
sql - original sqlpageNo - current page number (start from 0)pageSize - how many records is displayed in one page
protected java.lang.String convertCountSql(java.lang.String querySql)
JdbcQueryTemplate should override this method.
querySql - original sql
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||