org.hdpagination.dataaccess.jdbc
Class AbstractJdbcQueryCallback

java.lang.Object
  extended by org.hdpagination.dataaccess.jdbc.AbstractJdbcQueryCallback
All Implemented Interfaces:
java.io.Serializable, QueryCallback, JdbcQueryCallback
Direct Known Subclasses:
AbstractColumnMapJdbcQueryCallback, AbstractNoParamBindJdbcQueryCallback

public abstract class AbstractJdbcQueryCallback
extends java.lang.Object
implements JdbcQueryCallback

Abstract class which implements some methods of JdbcQueryCallback

Since:
1.0
Author:
Liangfeng Ren
See Also:
Serialized Form

Constructor Summary
AbstractJdbcQueryCallback(java.lang.String queryStmt)
           
AbstractJdbcQueryCallback(java.lang.String queryStmt, java.lang.String orderBy)
           
AbstractJdbcQueryCallback(java.lang.String queryStmt, java.lang.String orderBy, boolean ascending)
           
 
Method Summary
 java.lang.String getCountRecordsQueryStatement()
          Query statement to count total records.
 QueryOrder getQueryOrder()
          Order information used by query statement
 java.lang.String getQueryStatement()
          Query statement(e.g.
abstract  java.lang.Object processRow(java.sql.ResultSet rs)
          Implementations implement this method to fetch each row of data in the ResultSet and map the fetched data to an object of any type you wish and finally return it.
 void setCountRowsStmt(java.lang.String countRowsStmt)
          Set sql statement to count total records
 void setQueryOrder(QueryOrder aOrder)
          Set order information used by query statement
abstract  void setValues(java.sql.PreparedStatement ps)
          set values on a PreparedStatement provided by JdbcQueryTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJdbcQueryCallback

public AbstractJdbcQueryCallback(java.lang.String queryStmt)
Parameters:
queryStmt - The SQL statement to query

AbstractJdbcQueryCallback

public AbstractJdbcQueryCallback(java.lang.String queryStmt,
                                 java.lang.String orderBy)
Parameters:
queryStmt - The SQL to query
orderBy - column that will be added to the 'order by' clause of SQL statement

AbstractJdbcQueryCallback

public AbstractJdbcQueryCallback(java.lang.String queryStmt,
                                 java.lang.String orderBy,
                                 boolean ascending)
Parameters:
queryStmt - The SQL to query
orderBy - column that will be added to the 'order by' clause of SQL statement
ascending - if sorted by ascending order
Method Detail

setQueryOrder

public void setQueryOrder(QueryOrder aOrder)
Description copied from interface: QueryCallback
Set order information used by query statement

Specified by:
setQueryOrder in interface QueryCallback

setCountRowsStmt

public void setCountRowsStmt(java.lang.String countRowsStmt)
Set sql statement to count total records

Parameters:
countRowsStmt -

getQueryStatement

public java.lang.String getQueryStatement()
Description copied from interface: QueryCallback
Query statement(e.g. sql for JDBC and queryString for Hibernate)

Specified by:
getQueryStatement in interface QueryCallback
Returns:

getCountRecordsQueryStatement

public java.lang.String getCountRecordsQueryStatement()
Description copied from interface: QueryCallback
Query statement to count total records. If this property is not provided, the corresponding QueryTemplate will do some auto translation to generate the "count query statement" based on "queryStatement" property and related persistence technology or database provides (e.g. the way of translation is different between Hibernate and JDBC, Oracle and DB2).

Specified by:
getCountRecordsQueryStatement in interface QueryCallback
Returns:

getQueryOrder

public QueryOrder getQueryOrder()
Description copied from interface: QueryCallback
Order information used by query statement

Specified by:
getQueryOrder in interface QueryCallback
Returns:

setValues

public abstract void setValues(java.sql.PreparedStatement ps)
                        throws java.sql.SQLException
Description copied from interface: JdbcQueryCallback
set values on a PreparedStatement provided by JdbcQueryTemplate

Specified by:
setValues in interface JdbcQueryCallback
Throws:
java.sql.SQLException

processRow

public abstract java.lang.Object processRow(java.sql.ResultSet rs)
                                     throws java.sql.SQLException
Description copied from interface: JdbcQueryCallback
Implementations implement this method to fetch each row of data in the ResultSet and map the fetched data to an object of any type you wish and finally return it. Thus it provides the way of adding the fetched data in the type of any class you prefer to the search result(java.util.List).

Specified by:
processRow in interface JdbcQueryCallback
Returns:
Throws:
java.sql.SQLException


Copyright © 2008 HDPagination All Rights Reserved.