Skip to content

Commit

Permalink
fix issue in mapping int SQL array to long array
Browse files Browse the repository at this point in the history
  • Loading branch information
varjoranta committed Feb 11, 2015
1 parent cb50e66 commit ae5cbe5
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@ public class RepairScheduleMapper implements ResultSetMapper<RepairSchedule> {

@Override
public RepairSchedule map(int index, ResultSet r, StatementContext ctx) throws SQLException {
Long[] runHistory = ArrayUtils.toObject((long[]) r.getArray("run_history").getArray());
Integer[] runHistory = ArrayUtils.toObject((int[]) r.getArray("run_history").getArray());
Long[] runHistoryLong;
if (null != runHistory && runHistory.length > 0) {
runHistoryLong = new Long[runHistory.length];
for (int i = 0; i < runHistory.length; i++) {
runHistoryLong[i] = runHistory[i].longValue();
}
} else {
runHistoryLong = new Long[0];
}
return new RepairSchedule.Builder(
r.getLong("repair_unit_id"),
RepairSchedule.State.valueOf(r.getString("state")),
r.getInt("days_between"),
RepairRunMapper.getDateTimeOrNull(r, "next_activation"),
runHistory != null ? ImmutableList.copyOf(runHistory) : ImmutableList.<Long>of(),
ImmutableList.copyOf(runHistoryLong),
r.getInt("segment_count"),
RepairParallelism.valueOf(r.getString("repair_parallelism")),
r.getDouble("intensity"),
Expand Down

0 comments on commit ae5cbe5

Please sign in to comment.