public JLGGroupData mapRowData(ResultSet rs, int rowNum) throws SQLException { final List<JLGClientData> clients = new ArrayList<>(); final JLGGroupData group = this.mapRow(rs, rowNum); final Long previousGroupId = group.getGroupId(); // first client row of new group JLGClientData client = clientSavingsDataMapper.mapRowData(rs, rowNum); clients.add(client); // if its not after last row loop while (!rs.isAfterLast()) { final Long groupId = JdbcSupport.getLong(rs, "groupId"); if (previousGroupId != null && groupId.compareTo(previousGroupId) != 0) { // return for next group details return JLGGroupData.withClients(group, clients); } client = clientSavingsDataMapper.mapRowData(rs, rowNum); clients.add(client); } return JLGGroupData.withClients(group, clients); }