我试过这段代码:
List resultList = new ArrayList();
Criteria criteria = createCriteria(SystemLogFile.class);
criteria.add(Expression.eq("clientId", clientId));
criteria.addOrder(Order.desc("systemLogFileId"));
if (page == -1) {
resultList.add(criteria.setProjection(Projections.rowCount()).uniqueResult());
} else {
criteria.setFirstResult(page * pageSize);
criteria.setMaxResults(pageSize);
resultList = criteria.list();
setModelsListAsLoaded(resultList);
}
return resultList;
此代码生成以下查询:
select count(*) as y0_ from krn_system_log_file this_ where this_.CLIENT_ID=? order by this_.SYSTEM_LOG_FILE_ID desc
这适用于 oracle 和 mysql,但不适用于 db2!我收到此错误消息: 引起:com.ibm.db2.jcc.am.io:DB2 SQL 错误:SQLCODE=-119,SQLSTATE=42803,SQLERRMC=SYSTEM_LOG_FILE_ID,DRIVER=3.57.82