本文整理了Java中com.example.model.Base.<init>()
方法的一些代码示例,展示了Base.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base.<init>()
方法的具体详情如下:
包路径:com.example.model.Base
类名称:Base
方法名:<init>
暂无
代码示例来源:origin: making/spring-boot-db-samples
public List<Pizza> findOrderByIdAsc() {
return pizzaDao.findOrderByIdAsc().stream()
.collect(Collectors.groupingBy(x -> x.id))
.entrySet()
.stream()
.map(e -> {
com.example.doma.Pizza dto = e.getValue().get(0);
Pizza pizza = new Pizza();
pizza.setId(dto.id);
pizza.setName(dto.name);
pizza.setPrice(dto.price);
Base base = new Base(dto.id);
base.setName(dto.baseName);
pizza.setBase(base);
pizza.setToppings(e.getValue().stream()
.map(x -> {
Topping topping = new Topping(x.toppingId);
topping.setName(x.toppingName);
return topping;
})
.collect(Collectors.toList()));
return pizza;
})
.collect(Collectors.toList());
}
代码示例来源:origin: making/spring-boot-db-samples
public List<Pizza> findOrderByIdAsc() {
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 -> {
List<Pizza> pizzas = new ArrayList<>();
Pizza pizza = null;
while (rs.next()) {
Long pizzaId = rs.getLong("id");
if (pizza == null || !pizzaId.equals(pizza.getId())) {
pizza = new Pizza();
pizza.setId(pizzaId);
pizza.setName(rs.getNString("name"));
pizza.setPrice(rs.getBigDecimal("price"));
Base base = new Base(rs.getLong("baseId"));
pizza.setBase(base);
base.setName(rs.getString("baseName"));
pizza.setToppings(new ArrayList<>());
pizzas.add(pizza);
}
Topping topping = new Topping(rs.getLong("toppingId"));
topping.setName(rs.getString("toppingName"));
pizza.getToppings().add(topping);
}
return pizzas;
});
}
代码示例来源:origin: making/spring-boot-db-samples
public List<Pizza> findOrderByIdAsc() {
return pizzaMapper.findOrderByIdAsc().stream()
.collect(Collectors.groupingBy(com.example.mybatis.Pizza::getId))
.entrySet()
.stream()
.map(e -> {
com.example.mybatis.Pizza dto = e.getValue().get(0);
Pizza pizza = new Pizza();
pizza.setId(dto.getId());
pizza.setName(dto.getName());
pizza.setPrice(dto.getPrice());
Base base = new Base(dto.getId());
base.setName(dto.getBaseName());
pizza.setBase(base);
pizza.setToppings(e.getValue().stream()
.map(x -> {
Topping topping = new Topping(x.getToppingId());
topping.setName(x.getToppingName());
return topping;
})
.collect(Collectors.toList()));
return pizza;
})
.collect(Collectors.toList());
}
代码示例来源:origin: making/spring-boot-db-samples
public List<Pizza> findOrderByIdAsc() {
return pizzaDao.findOrderByIdAsc().stream()
.collect(Collectors.groupingBy(com.example.jdbi.Pizza::getId))
.entrySet()
.stream()
.map(e -> {
com.example.jdbi.Pizza dto = e.getValue().get(0);
Pizza pizza = new Pizza();
pizza.setId(dto.getId());
pizza.setName(dto.getName());
pizza.setPrice(dto.getPrice());
Base base = new Base(dto.getId());
base.setName(dto.getBaseName());
pizza.setBase(base);
pizza.setToppings(e.getValue().stream()
.map(x -> {
Topping topping = new Topping(x.getToppingId());
topping.setName(x.getToppingName());
return topping;
})
.collect(Collectors.toList()));
return pizza;
})
.collect(Collectors.toList());
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
public Pizza toPizza(Long id) {
Pizza pizza = new Pizza();
pizza.setId(id);
pizza.setName(name);
pizza.setPrice(price);
Base base = new Base(id);
base.setName(baseName);
pizza.setBase(base);
pizza.setToppings(new ArrayList<>());
return pizza;
}
}
代码示例来源:origin: making/spring-boot-db-samples
public List<Pizza> findOrderByIdAsc() {
try (Connection con = sql2o.open()) {
return con.createQuery("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")
.executeAndFetch(PizzaDto.class)
.stream()
.collect(Collectors.groupingBy(PizzaDto::getId))
.entrySet()
.stream()
.map(e -> {
PizzaDto dto = e.getValue().get(0);
Pizza pizza = new Pizza();
pizza.setId(dto.getId());
pizza.setName(dto.getName());
pizza.setPrice(dto.getPrice());
Base base = new Base(dto.getId());
base.setName(dto.getBaseName());
pizza.setBase(base);
pizza.setToppings(e.getValue().stream()
.map(x -> {
Topping topping = new Topping(x.getToppingId());
topping.setName(x.getToppingName());
return topping;
})
.collect(Collectors.toList()));
return pizza;
})
.collect(Collectors.toList());
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
}
代码示例来源:origin: making/spring-boot-db-samples
@Bean
CommandLineRunner runner(PizzaRepository pizzaRepository) {
return a -> {
Pizza pizza = new Pizza();
pizza.setBase(new Base(1L));
pizza.setToppings(Arrays.asList(new Topping(1L), new Topping(2L), new Topping(3L), new Topping(4L), new Topping(5L)));
pizza.setName("Hello Pizza");
pizza.setPrice(new BigDecimal("1000"));
pizzaRepository.save(pizza);
};
}
代码示例来源:origin: making/spring-boot-db-samples
pizza.setName(tuple.get(qPizza.name));
pizza.setPrice(tuple.get(qPizza.price));
com.example.model.Base base = new Base(tuple.get(qBase.id));
base.setId(tuple.get(qBase.id));
base.setName(tuple.get(qBase.name));
代码示例来源:origin: making/spring-boot-db-samples
public List<com.example.model.Pizza> findOrderByIdAsc() {
ListResultBean<Pizza> pizzaList = pizzaBhv.selectList(cb -> {
cb.setupSelect_Base();
cb.query().addOrderBy_Id_Asc();
});
pizzaBhv.loadPizzaToppings(pizzaList, toppingsCB -> {
toppingsCB.setupSelect_Topping();
});
return pizzaList.mappingList(pizza -> { // mapping entity to model
com.example.model.Pizza modelPizza = new com.example.model.Pizza();
modelPizza.setId(pizza.getId());
modelPizza.setName(pizza.getName());
modelPizza.setPrice(pizza.getPrice());
pizza.getBase().alwaysPresent(base -> { // BASE_ID is not-null
com.example.model.Base modelBase = new com.example.model.Base(base.getId());
modelBase.setName(base.getName());
modelPizza.setBase(modelBase);
});
List<com.example.model.Topping> modelToppingList = pizza.getPizzaToppingsList().stream().map(toppings -> {
com.example.model.Topping modelTopping = new com.example.model.Topping(toppings.getToppingsId());
modelTopping.setName(toppings.getTopping().get().getName()); // TOPPINGS_ID is not-null
return modelTopping;
}).collect(Collectors.toList());
modelPizza.setToppings(modelToppingList);
return modelPizza;
});
}
内容来源于网络,如有侵权,请联系作者删除!