Fixed multiple extraction eating first result

This commit is contained in:
Aleksei 2020-02-27 16:10:14 -05:00
parent c7ed16a6c8
commit eed3bb9cd5

View File

@ -262,18 +262,20 @@ public class OutfitController {
private static Optional<Collection<Outfit>> extractMultiple(ResultSet rs) throws SQLException {
Collection<Outfit> outfits = new ArrayList<>();
if (rs.next()) { // I don't see a better way to wrap this. If results exist -> iterate through them, return the optional.
while (rs.next()) {
outfits.add(mapObject(rs));
}
FSDB.get().close(rs);
return Optional.of(outfits);
}
FSDB.get().close(rs);
if (outfits.size() == 0) {
return Optional.empty();
}
return Optional.of(outfits);
}
private static Outfit mapObject(ResultSet rs) throws SQLException {
return new Outfit.OutfitBuilder()
.setId(rs.getString("id"))