FINERACT-995: Rewriting logic to remove call to rs.previous()

This commit is contained in:
Petri Tuomola
2020-06-20 22:32:06 +02:00
committed by Michael Vorburger ⛑️
parent f3862bca8b
commit 6438063a7f
2 changed files with 8 additions and 12 deletions
@@ -438,19 +438,14 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
while (rs.next()) {
Long loanId = rs.getLong("loanId");
List<LoanSchedulePeriodData> periodDatas = new ArrayList<>();
LoanSchedulePeriodData loanSchedulePeriodData = fetchLoanSchedulePeriodData(rs);
periodDatas.add(loanSchedulePeriodData);
while (rs.next()) {
Long tempLoanId = rs.getLong("loanId");
if (loanId.equals(tempLoanId)) {
periodDatas.add(fetchLoanSchedulePeriodData(rs));
} else {
rs.previous();
break;
}
List<LoanSchedulePeriodData> periodDatas = scheduleDate.get(loanId);
if (periodDatas == null) {
periodDatas = new ArrayList<>();
scheduleDate.put(loanId, periodDatas);
}
scheduleDate.put(loanId, periodDatas);
periodDatas.add(fetchLoanSchedulePeriodData(rs));
}
return scheduleDate;