org.hdpagination.dataaccess.orm.jpa
Class AbstractJPAQueryCallback

java.lang.Object
  extended by org.hdpagination.dataaccess.orm.jpa.AbstractJPAQueryCallback
All Implemented Interfaces:
java.io.Serializable, QueryCallback, JPAQueryCallback
Direct Known Subclasses:
NoParamBindJPAQueryCallback, NotProcessResultJPAQueryCallback

public abstract class AbstractJPAQueryCallback
extends java.lang.Object
implements JPAQueryCallback

Abstract class which implements some methods of JPAQueryCallback

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

Constructor Summary
AbstractJPAQueryCallback(java.lang.String queryStmt, java.lang.String countArgument)
           Please note, since version 1.3.2, this construct adds another argument countArgument to fix a design defect not complying with the JPA specification.
AbstractJPAQueryCallback(java.lang.String queryStmt, java.lang.String countArgument, java.lang.String orderBy)
           Please note, since version 1.3.2, this construct adds another argument countArgument to fix a design defect not complying with the JPA specification.
AbstractJPAQueryCallback(java.lang.String queryStmt, java.lang.String countArgument, java.lang.String orderBy, boolean ascending)
           Please note, since version 1.3.2, this construct adds another argument countArgument to fix a design defect not complying with the JPA specification.
 
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.util.List processQueriedResult(java.util.List queriedResult)
          process the result from calling javax.persistence.Query.list() method in JPAQueryTemplate.query(QueryCallback callback, int pageSize, int pageNo), and the value(java.util.List) returned by current method will be used as the return value of JPAQueryTemplate.query(QueryCallback callback, int pageSize, int pageNo).
 void setCountRecordsQueryStatement(java.lang.String countRowsStmt)
          Set EJB QL statement to count total records
 void setQueryOrder(QueryOrder aOrder)
          Set order information used by query statement
abstract  void setValues(javax.persistence.Query query)
          Operate on Query instance to bind parameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJPAQueryCallback

public AbstractJPAQueryCallback(java.lang.String queryStmt,
                                java.lang.String countArgument)

Please note, since version 1.3.2, this construct adds another argument countArgument to fix a design defect not complying with the JPA specification. So if you upgrade from previous versions, you may find a compilation error.

Parameters:
queryStmt - JP QL (Java Persistence Query Language) query statement
countArgument - to query the total number of records, the "SELECT COUNT([countArgument]) FROM ..." statement (generated based on the query statement) needs to be executed. As specified by JPA Specification, the COUNT function takes either an identification variable or a path expression as its argument. This argument will be used as the COUNT function's argument. This argument can not be null or empty, unless the property countRecordsQueryStatement is set explicitly by calling the method AbstractJPAQueryCallback.setCountRecordsQueryStatement(java.lang.String) (in this case, it will be ignored).

AbstractJPAQueryCallback

public AbstractJPAQueryCallback(java.lang.String queryStmt,
                                java.lang.String countArgument,
                                java.lang.String orderBy)

Please note, since version 1.3.2, this construct adds another argument countArgument to fix a design defect not complying with the JPA specification. So if you upgrade from previous versions, you may find a compilation error.

Parameters:
queryStmt - JP QL (Java Persistence Query Language) query statement
countArgument - to query the total number of records, the "SELECT COUNT([countArgument]) FROM ..." statement (generated based on the query statement) needs to be executed. As specified by JPA Specification, the COUNT function takes either an identification variable or a path expression as its argument. This argument will be used as the COUNT function's argument. This argument can not be null or empty, unless the property countRecordsQueryStatement is set explicitly by calling the method AbstractJPAQueryCallback.setCountRecordsQueryStatement(java.lang.String) (in this case, it will be ignored).
orderBy - column that will be added to the 'ORDER BY' clause of JP QL query statement

AbstractJPAQueryCallback

public AbstractJPAQueryCallback(java.lang.String queryStmt,
                                java.lang.String countArgument,
                                java.lang.String orderBy,
                                boolean ascending)

Please note, since version 1.3.2, this construct adds another argument countArgument to fix a design defect not complying with the JPA specification. So if you upgrade from previous versions, you may find a compilation error.

Parameters:
queryStmt - JP QL (Java Persistence Query Language) query statement
countArgument - to query the total number of records, the "SELECT COUNT([countArgument]) FROM ..." statement (generated based on the query statement) needs to be executed. As specified by JPA Specification, the COUNT function takes either an identification variable or a path expression as its argument. This argument will be used as the COUNT function's argument. This argument can not be null or empty, unless the property countRecordsQueryStatement is set explicitly by calling the method AbstractJPAQueryCallback.setCountRecordsQueryStatement(java.lang.String) (in this case, it will be ignored).
orderBy - column that will be added to the 'ORDER BY' clause of JP QL query statement
ascending - if sorted by ascending order
Method Detail

setCountRecordsQueryStatement

public void setCountRecordsQueryStatement(java.lang.String countRowsStmt)
Set EJB QL 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:

setQueryOrder

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

Specified by:
setQueryOrder in interface QueryCallback

setValues

public abstract void setValues(javax.persistence.Query query)
Description copied from interface: JPAQueryCallback
Operate on Query instance to bind parameters

Specified by:
setValues in interface JPAQueryCallback

processQueriedResult

public abstract java.util.List processQueriedResult(java.util.List queriedResult)
Description copied from interface: JPAQueryCallback
process the result from calling javax.persistence.Query.list() method in JPAQueryTemplate.query(QueryCallback callback, int pageSize, int pageNo), and the value(java.util.List) returned by current method will be used as the return value of JPAQueryTemplate.query(QueryCallback callback, int pageSize, int pageNo).

Specified by:
processQueriedResult in interface JPAQueryCallback
Returns:


Copyright © 2008 HDPagination All Rights Reserved.