The problem is poorly designed sub-query like:
SELECT COUNT(*) FROM
( SELECT .... <-- ORIGINAL QUERY
) AGN
So what I did is the next:
ReceipentDaoImpl.java
Code: Select all
public PaginatedList getRecipientList( String sqlStatementForCount , String sqlStatementForRows, String sort, String direction , int page, int rownums, int previousFullListSize ) throws IllegalAccessException, InstantiationException {
// TODO use RecipientQueryBuilder inside DAO
JdbcTemplate aTemplate = new JdbcTemplate((DataSource)this.applicationContext.getBean("dataSource"));
int idx = sqlStatementForCount.toUpperCase().indexOf("FROM");
String subStr = sqlStatementForCount.substring(idx);
String queryStr = "SELECT count(*) " + subStr;
int totalRows = aTemplate.queryForInt(queryStr);
//int totalRows = aTemplate.queryForInt("SELECT count(*) FROM ( " + sqlStatementForCount + " ) agn" );
if( previousFullListSize == 0 || previousFullListSize != totalRows ) {
page = 1;
}