Skip to content

Commit

Permalink
java pizza project #2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
biblelamp committed May 21, 2024
1 parent 99f37fe commit 0da3076
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public Order findById(Integer id) {
if (rs.getString("close_date") != null) {
order.setCloseDate(LocalDateTime.parse(rs.getString("close_date")));
}
}
// read pizzas
psp.setInt(1, order.getId());
ResultSet rsp = psp.executeQuery();
while (rsp.next()) {
Integer pizzaId = rsp.getInt("pizza_id");
Pizza pizza = pizzaRepository.findById(pizzaId);
order.getOrderPizzas().add(pizza);
// read pizzas
psp.setInt(1, order.getId());
ResultSet rsp = psp.executeQuery();
while (rsp.next()) {
Integer pizzaId = rsp.getInt("pizza_id");
Pizza pizza = pizzaRepository.findById(pizzaId);
order.getOrderPizzas().add(pizza);
}
}
return order;
} catch (SQLException e) {
Expand All @@ -125,7 +125,13 @@ public Collection<Order> findAll() {

@Override
public void deleteById(Integer id) {
// TODO
try (Connection connection = DriverManager.getConnection(dbName);
PreparedStatement ps = connection.prepareStatement(SQL_DELETE_BY_ID)) {
ps.setInt(1, id);
ps.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@Override
Expand Down

0 comments on commit 0da3076

Please sign in to comment.