JasperReports 结合 hibernate 实现真正分页
JasperReports 结合 hibernate 实现真正分页
本文在开始阶段,一步一步来写吧,目前在尝试中,相信一定能实现。
突破口应该在这个类上 net.sf.jasperreports.engine.data.JRHibernateListDataSource,这个类的构造方法需要一个 JRHibernateQueryExecuter 实例做为参数 ,而 JRHibernateQueryExecuter 这个类中有这个方法,有你熟悉的 hibernate分页语句,因此,可以肯定的是,可以实现真正的分页了。
/** * Returns a page of the query results by calling <code>org.hibernate.Query.iterate()</code>. * * @param firstIndex the index of the first row to return * @param resultCount the number of rows to return * @return result row list */ public List list(int firstIndex, int resultCount) { if (reportMaxCount != null && firstIndex + resultCount > reportMaxCount.intValue()) { resultCount = reportMaxCount.intValue() - firstIndex; } query.setFirstResult(firstIndex); query.setMaxResults(resultCount); if (isClearCache) clearCache(); return query.list(); }
根据学习过程一步一步将文章完成吧。如果有朋友已经实现了,还请告知下,这样我能省写时间。不是内存分页,是真正分页
近期评论