这是个hibernate QBC 分页方法    public class CustometImpl extends DAO implements Icst_customer { @SuppressWarnings("unchecked")
public List<CstCustomer> findAllCstCustomer(final CstCustomer customer,
final int page, final int row) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
@SuppressWarnings("finally")
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
try {
Criteria c = session.createCriteria(CstCustomer.class); if (customer != null)
c.add(Example.create(customer).enableLike(
MatchMode.ANYWHERE).excludeNone()
.excludeZeroes()); c.setFirstResult((page - 1) * row);
c.setMaxResults(row); List<CstCustomer> list = c.list(); int count = (Integer) c.setProjection(
Projections.rowCount()).uniqueResult();
// c.setProjection(null); int ye = 0;
if (count % row == 0)
ye = count / row;
else
ye = count / row + 1; List list1 = new ArrayList();
list1.add(list);
list1.add(count);
list1.add(ye);
return list1;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
session.close();
}
}
});
}   第一次 页面加载的时候正常  但是 点击分页按钮 例如上一页 或者跳转,
 也就是说第二次调用上面方法的时候 就会提示
int count = (Integer) c.setProjection(Projections.rowCount()).uniqueResult();  是null  高手来帮下忙 。感谢!