// count records
Map<String, Object> inputs = ActiveRecordUtil.getGateway(modelClass).constructFindSQL((String)null, (Map<String, Object>)null, inputOptions);
String findSQL = (String)inputs.get(ActiveRecordConstants.key_finder_sql);
String selectCountSQL = "SELECT count(*) total FROM (" + findSQL + ") xxx";
TableGateway tg = ActiveRecordUtil.getGateway(modelClass);
Object total = null;
Object cacheKey = null;
if (tg.getModelCacheClient().useCache("countTotalRecords")) {
cacheKey = tg.getModelCacheClient().getCacheKey("countTotalRecords", selectCountSQL);
total = tg.getModelCacheClient().getCache().get(cacheKey);
if (total != null) return Util.getSafeIntValue(total);
}
total = SqlServiceClient.retrieveObjectBySQL(selectCountSQL, inputs);
if (tg.getModelCacheClient().useCache("countTotalRecords")) {
tg.getModelCacheClient().getCache().put(cacheKey, total);
}
totalRecords = Util.getSafeIntValue(total);
}
catch (Exception ex) {