use of com.serotonin.ModuleNotLoadedException in project ma-core-public by infiniteautomation.
the class AbstractBasicDao method customizedQuery.
protected void customizedQuery(SelectJoinStep<Record> select, Condition condition, List<SortField<Object>> sort, Integer limit, Integer offset, MappedRowCallback<T> callback) {
SelectConnectByStep<Record> afterWhere = condition == null ? select : select.where(condition);
SelectLimitStep<Record> afterSort = sort == null ? afterWhere : afterWhere.orderBy(sort);
Select<Record> offsetStep = afterSort;
if (limit != null) {
if (offset != null) {
offsetStep = afterSort.limit(offset, limit);
} else {
offsetStep = afterSort.limit(limit);
}
}
String sql = offsetStep.getSQL();
List<Object> arguments = offsetStep.getBindValues();
Object[] argumentsArray = arguments.toArray(new Object[arguments.size()]);
LogStopWatch stopWatch = null;
if (useMetrics) {
stopWatch = new LogStopWatch();
}
// this.query(sql, argumentsArray, this.getRowMapper(), callback );
this.query(sql, argumentsArray, new ResultSetExtractor<Void>() {
@Override
public Void extractData(ResultSet rs) throws SQLException, DataAccessException {
RowMapper<T> rowMapper = getRowMapper();
int rowNum = 0;
while (rs.next()) {
try {
callback.row(rowMapper.mapRow(rs, rowNum), rowNum);
} catch (Exception e) {
if (e.getCause() instanceof ModuleNotLoadedException)
LOG.error(e.getCause().getMessage(), e.getCause());
else
LOG.error(e.getMessage(), e);
} finally {
rowNum++;
}
}
return null;
}
});
if (stopWatch != null) {
stopWatch.stop("customizedQuery(): " + this.create.renderInlined(offsetStep), metricsThreshold);
}
}
Aggregations