Skip to content

Commit 293a628

Browse files
committed
Polish
1 parent cf02384 commit 293a628

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

demo-spring-jdbc/src/main/java/com/example/PizzaRepository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public PizzaRepository(JdbcTemplate jdbcTemplate) {
2222
}
2323

2424
public List<Pizza> findOrderByIdAsc() {
25-
return jdbcTemplate.query("SELECT p.id, p.name, p.price, b.id AS b_id, b.name AS b_name, t.id AS t_id, t.name AS t_name FROM pizza p INNER JOIN base b ON (b.id = p.base_id) INNER JOIN pizza_toppings pt ON (pt.pizza_id = p.id) INNER JOIN topping t ON (t.id = pt.toppings_id) ORDER BY p.id ASC", rs -> {
25+
return jdbcTemplate.query("SELECT p.id, p.name, p.price, b.id AS baseId, b.name AS baseName, t.id AS toppingId, t.name AS toppingName FROM pizza p INNER JOIN base b ON (b.id = p.base_id) INNER JOIN pizza_toppings pt ON (pt.pizza_id = p.id) INNER JOIN topping t ON (t.id = pt.toppings_id) ORDER BY p.id ASC", rs -> {
2626
List<Pizza> pizzas = new ArrayList<>();
2727
Pizza pizza = null;
2828
while (rs.next()) {
@@ -32,14 +32,14 @@ public List<Pizza> findOrderByIdAsc() {
3232
pizza.setId(pizzaId);
3333
pizza.setName(rs.getNString("name"));
3434
pizza.setPrice(rs.getBigDecimal("price"));
35-
Base base = new Base(rs.getLong("b_id"));
35+
Base base = new Base(rs.getLong("baseId"));
3636
pizza.setBase(base);
37-
base.setName(rs.getString("b_name"));
37+
base.setName(rs.getString("baseName"));
3838
pizza.setToppings(new ArrayList<>());
3939
pizzas.add(pizza);
4040
}
41-
Topping topping = new Topping(rs.getLong("t_id"));
42-
topping.setName(rs.getString("t_name"));
41+
Topping topping = new Topping(rs.getLong("toppingId"));
42+
topping.setName(rs.getString("toppingName"));
4343
pizza.getToppings().add(topping);
4444
}
4545
return pizzas;

0 commit comments

Comments
 (0)