|
Hello everyone, I want to know that if there is anyone who has experience of pagination on the Spring2-ibatis2 integration. I desigened a pagination object myself, and the core methods are: public void execute(String statementName, Object parameterObject,
int pageNum, int pageSize, SqlMapClientTemplate sqlMapClientTemplate) { // count the total number of records this.rowCount = sqlMapClientTemplate.queryForList(statementName, parameterObject).size();
// count the pagination parameters countPage(); // get the pagination list this.list = sqlMapClientTemplate.queryForList(statementName, parameterObject, (pageNum - 1) * pageSize, pageSize);
} The second method is just no parameterObject argument.When the pagination work is finished, I put this object into data-model of FreeMarker, then showed at the view layer. In the method, I used the sqlMapClientTemplate.queryForList() method twice. First I just want to get the total number of records, the second is to get the list. In the configuration, I enabled the cache mode. Here I have no idea that if it has a better way of dealing.If wrote two SQL statement, first just like "select count(*) from table", maybe it is harder for maintaince;if use the dymanic sql, one select element could solve the problem, but the pagination method would be larger to judge the dymanics property.So I have no other idea about it. If the whole class of pagination needed,I will post it later.
Have a good week! Best Wishes! Nanlei
|