From e91b152875d546e1dc0552dcbf43393b35045067 Mon Sep 17 00:00:00 2001 From: taekyunlee Date: Mon, 22 Jul 2024 13:29:26 +0900 Subject: [PATCH 1/2] upload --- build.gradle | 1 + sql/ddl.sql | 9 ++ .../springintro/aop/TimeTraceAop.java | 22 +++ .../controller/HelloController.java | 51 ++++++ .../controller/HomeController.java | 12 ++ .../controller/ItemController.java | 47 ++++++ .../controller/ItemCreateForm.java | 31 ++++ .../springintro/item/config/ItemConfig.java | 39 +++++ .../springintro/item/domain/Item.java | 48 ++++++ .../item/repository/ItemRepository.java | 13 ++ .../item/repository/JdbcItemRepository.java | 148 ++++++++++++++++++ .../JdbcTemplateItemRepository.java | 54 +++++++ .../item/repository/JpaItemRepository.java | 34 ++++ .../item/repository/MemoryItemRepository.java | 39 +++++ .../SpringDataJpaMemberRepository.java | 12 ++ .../springintro/item/service/ItemService.java | 42 +++++ src/main/resources/application.properties | 5 + .../resources/templates/items/createForm.html | 2 +- .../resources/templates/items/itemList.html | 2 +- .../repository/MemoryItemRepositoryTest.java | 79 ++++++++++ .../item/service/ItemServiceTest.java | 67 ++++++++ top:/localhost/~/test.mv.db | Bin 0 -> 20480 bytes top:/localhost/~/test.trace.db | 81 ++++++++++ 23 files changed, 836 insertions(+), 2 deletions(-) create mode 100644 sql/ddl.sql create mode 100644 src/main/java/landvibe/springintro/aop/TimeTraceAop.java create mode 100644 src/main/java/landvibe/springintro/controller/HelloController.java create mode 100644 src/main/java/landvibe/springintro/controller/HomeController.java create mode 100644 src/main/java/landvibe/springintro/controller/ItemController.java create mode 100644 src/main/java/landvibe/springintro/controller/ItemCreateForm.java create mode 100644 src/main/java/landvibe/springintro/item/config/ItemConfig.java create mode 100644 src/main/java/landvibe/springintro/item/domain/Item.java create mode 100644 src/main/java/landvibe/springintro/item/repository/ItemRepository.java create mode 100644 src/main/java/landvibe/springintro/item/repository/JdbcItemRepository.java create mode 100644 src/main/java/landvibe/springintro/item/repository/JdbcTemplateItemRepository.java create mode 100644 src/main/java/landvibe/springintro/item/repository/JpaItemRepository.java create mode 100644 src/main/java/landvibe/springintro/item/repository/MemoryItemRepository.java create mode 100644 src/main/java/landvibe/springintro/item/repository/SpringDataJpaMemberRepository.java create mode 100644 src/main/java/landvibe/springintro/item/service/ItemService.java mode change 100755 => 100644 src/main/resources/templates/items/itemList.html create mode 100644 src/test/java/landvibe/springintro/item/repository/MemoryItemRepositoryTest.java create mode 100644 src/test/java/landvibe/springintro/item/service/ItemServiceTest.java create mode 100644 top:/localhost/~/test.mv.db create mode 100644 top:/localhost/~/test.trace.db diff --git a/build.gradle b/build.gradle index 07d2578..a9340be 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.h2database:h2' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' diff --git a/sql/ddl.sql b/sql/ddl.sql new file mode 100644 index 0000000..d66d0c9 --- /dev/null +++ b/sql/ddl.sql @@ -0,0 +1,9 @@ +drop table if exists item CASCADE; +create table item +( + id bigint generated by default as identity, + name varchar(255), + price integer not null, + count integer not null, + primary key (id) +); \ No newline at end of file diff --git a/src/main/java/landvibe/springintro/aop/TimeTraceAop.java b/src/main/java/landvibe/springintro/aop/TimeTraceAop.java new file mode 100644 index 0000000..0ff28c0 --- /dev/null +++ b/src/main/java/landvibe/springintro/aop/TimeTraceAop.java @@ -0,0 +1,22 @@ +package landvibe.springintro.aop; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; +@Component +@Aspect +public class TimeTraceAop { + @Around("execution(* landvibe.springintro..*(..))") + public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { + long start = System.currentTimeMillis(); + System.out.println("START : " + joinPoint.toString()); + try { + return joinPoint.proceed(); // 다음 메소드가 진행 + } finally { + long finish = System.currentTimeMillis(); + long timeMs = finish - start; + System.out.println("END : " + joinPoint.toString() + " " + timeMs + + "ms"); // 어떤 메소드를 call 했는지 + } + } +} \ No newline at end of file diff --git a/src/main/java/landvibe/springintro/controller/HelloController.java b/src/main/java/landvibe/springintro/controller/HelloController.java new file mode 100644 index 0000000..6ff23f8 --- /dev/null +++ b/src/main/java/landvibe/springintro/controller/HelloController.java @@ -0,0 +1,51 @@ +package landvibe.springintro.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class HelloController { + @GetMapping("hello") + public String hello(Model model){ + model.addAttribute("data","LandVibe"); + return "hello"; + } + + @GetMapping("hello-mvc") + public String helloMvc( + @RequestParam(value="name", required=false, defaultValue= + "landVibe") String name, + Model model){ + model.addAttribute("name",name); + return "hello-template"; + } + + @GetMapping("hello-string") + @ResponseBody + public String helloString(@RequestParam("name") String name){ + return "hello " + name; + } + + @GetMapping("hello-api") + @ResponseBody + public Hello helloApi(@RequestParam("name") String name){ + Hello hello = new Hello(); + hello.setName(name); + return hello; + } + + static class Hello{ + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } +} diff --git a/src/main/java/landvibe/springintro/controller/HomeController.java b/src/main/java/landvibe/springintro/controller/HomeController.java new file mode 100644 index 0000000..b3bdfb8 --- /dev/null +++ b/src/main/java/landvibe/springintro/controller/HomeController.java @@ -0,0 +1,12 @@ +package landvibe.springintro.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class HomeController { + @GetMapping("/") + public String home(){ + return "home"; + } +} diff --git a/src/main/java/landvibe/springintro/controller/ItemController.java b/src/main/java/landvibe/springintro/controller/ItemController.java new file mode 100644 index 0000000..07b9228 --- /dev/null +++ b/src/main/java/landvibe/springintro/controller/ItemController.java @@ -0,0 +1,47 @@ +package landvibe.springintro.controller; + +import landvibe.springintro.item.service.ItemService; +import landvibe.springintro.item.domain.Item; +import landvibe.springintro.item.service.ItemService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +@Controller +public class ItemController { + private final ItemService itemService; + + @Autowired + public ItemController(ItemService itemService) { + this.itemService = itemService; + } + + @GetMapping("/items/new") + public String createForm(){ + return "items/createForm"; + } + + @PostMapping("/items/new") + public String create(@ModelAttribute ItemCreateForm form){ + Item item = new Item(); + item.setName(form.getName()); + item.setPrice(form.getPrice()); + item.setCount(form.getCount()); + itemService.create(item); + + return "redirect:/"; + } + + @GetMapping("/items") + public String list(Model model){ + List items = itemService.findItems(); + model.addAttribute("items", items); + return "items/itemList"; + } + +} diff --git a/src/main/java/landvibe/springintro/controller/ItemCreateForm.java b/src/main/java/landvibe/springintro/controller/ItemCreateForm.java new file mode 100644 index 0000000..1859669 --- /dev/null +++ b/src/main/java/landvibe/springintro/controller/ItemCreateForm.java @@ -0,0 +1,31 @@ +package landvibe.springintro.controller; + +public class ItemCreateForm { + private String name; + private Integer price; + private Integer count; + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/landvibe/springintro/item/config/ItemConfig.java b/src/main/java/landvibe/springintro/item/config/ItemConfig.java new file mode 100644 index 0000000..fc47105 --- /dev/null +++ b/src/main/java/landvibe/springintro/item/config/ItemConfig.java @@ -0,0 +1,39 @@ +package landvibe.springintro.item.config; + +import jakarta.persistence.EntityManager; +import landvibe.springintro.item.repository.*; +import landvibe.springintro.item.service.ItemService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.sql.DataSource; + +@Configuration +public class ItemConfig { +// private final DataSource dataSource; +// private final EntityManager em; +// +// @Autowired +// public ItemConfig(DataSource dataSource, EntityManager em) { +// this.dataSource = dataSource; +// this.em = em; +// } + + private final ItemRepository itemRepository; + public ItemConfig(ItemRepository itemRepository){ + this.itemRepository = itemRepository; + } + @Bean + public ItemService itemService(){ + return new ItemService(itemRepository); + } + +// @Bean +// public ItemRepository itemRepository(){ +// //return new MemoryItemRepository(); +// //return new JdbcItemRepository(dataSource); +// //return new JdbcTemplateItemRepository(dataSource); +// return new JpaItemRepository(em); +// } +} diff --git a/src/main/java/landvibe/springintro/item/domain/Item.java b/src/main/java/landvibe/springintro/item/domain/Item.java new file mode 100644 index 0000000..9e437e5 --- /dev/null +++ b/src/main/java/landvibe/springintro/item/domain/Item.java @@ -0,0 +1,48 @@ +package landvibe.springintro.item.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Item { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String name; + private Integer price; + private Integer count; + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/src/main/java/landvibe/springintro/item/repository/ItemRepository.java b/src/main/java/landvibe/springintro/item/repository/ItemRepository.java new file mode 100644 index 0000000..ca71d6c --- /dev/null +++ b/src/main/java/landvibe/springintro/item/repository/ItemRepository.java @@ -0,0 +1,13 @@ +package landvibe.springintro.item.repository; + +import landvibe.springintro.item.domain.Item; + +import java.util.List; +import java.util.Optional; + +public interface ItemRepository { + Item save(Item item); + Optional findById(Long id); + Optional findByName(String name); + List findAll(); +} diff --git a/src/main/java/landvibe/springintro/item/repository/JdbcItemRepository.java b/src/main/java/landvibe/springintro/item/repository/JdbcItemRepository.java new file mode 100644 index 0000000..b89477d --- /dev/null +++ b/src/main/java/landvibe/springintro/item/repository/JdbcItemRepository.java @@ -0,0 +1,148 @@ +package landvibe.springintro.item.repository; +import landvibe.springintro.item.domain.Item; +import org.springframework.jdbc.datasource.DataSourceUtils; +import javax.sql.DataSource; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +public class JdbcItemRepository implements ItemRepository { + private final DataSource dataSource; + public JdbcItemRepository(DataSource dataSource) { + this.dataSource = dataSource; + } + @Override + public Item save(Item item) { + String sql = "insert into item(name, price, count) values(?, ?, ?)"; + Connection conn = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + conn = getConnection(); + pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + pstmt.setString(1, item.getName()); + pstmt.setInt(2, item.getPrice()); + pstmt.setInt(3, item.getCount()); + pstmt.executeUpdate(); + rs = pstmt.getGeneratedKeys(); + if (rs.next()) { + item.setId(rs.getLong(1)); + } else { + throw new SQLException("id 조회 실패"); + } + return item; + } catch (Exception e) { + throw new IllegalStateException(e); + } finally { + close(conn, pstmt, rs); + } + } + @Override + public Optional findById(Long id) { + String sql = "select * from item where id = ?"; + Connection conn = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + conn = getConnection(); + pstmt = conn.prepareStatement(sql); + pstmt.setLong(1, id); + rs = pstmt.executeQuery(); + if (rs.next()) { + Item item = new Item(); + item.setId(rs.getLong("id")); + item.setName(rs.getString("name")); + item.setCount(rs.getInt("count")); + item.setPrice(rs.getInt("price")); + return Optional.of(item); + } else { + return Optional.empty(); + } + } catch (Exception e) { + throw new IllegalStateException(e); + } finally { + close(conn, pstmt, rs); + } + } + @Override + public Optional findByName(String name) { + String sql = "select * from item where name = ?"; + Connection conn = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + conn = getConnection(); + pstmt = conn.prepareStatement(sql); + pstmt.setString(1, name); + rs = pstmt.executeQuery(); + if (rs.next()) { + Item item = new Item(); + item.setId(rs.getLong("id")); + item.setName(rs.getString("name")); + item.setCount(rs.getInt("count")); + item.setPrice(rs.getInt("price")); + return Optional.of(item); + } + return Optional.empty(); + } catch (Exception e) { + throw new IllegalStateException(e); + } finally { + close(conn, pstmt, rs); + } + } + @Override + public List findAll() { + String sql = "select * from item"; + Connection conn = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + conn = getConnection(); + pstmt = conn.prepareStatement(sql); + rs = pstmt.executeQuery(); + List items = new ArrayList<>(); + while (rs.next()) { + Item item = new Item(); + item.setId(rs.getLong("id")); + item.setName(rs.getString("name")); + item.setCount(rs.getInt("count")); + item.setPrice(rs.getInt("price")); + items.add(item); + } + return items; + } catch (Exception e) { + throw new IllegalStateException(e); + } finally { + close(conn, pstmt, rs); + } + } + private Connection getConnection() { + return DataSourceUtils.getConnection(dataSource); + } + private void close(Connection conn, PreparedStatement pstmt, ResultSet rs) { + try { + if (rs != null) { + rs.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + try { + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + try { + if (conn != null) { + close(conn); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + private void close(Connection conn) throws SQLException { + DataSourceUtils.releaseConnection(conn, dataSource); + } +} \ No newline at end of file diff --git a/src/main/java/landvibe/springintro/item/repository/JdbcTemplateItemRepository.java b/src/main/java/landvibe/springintro/item/repository/JdbcTemplateItemRepository.java new file mode 100644 index 0000000..c3f27a8 --- /dev/null +++ b/src/main/java/landvibe/springintro/item/repository/JdbcTemplateItemRepository.java @@ -0,0 +1,54 @@ +package landvibe.springintro.item.repository; +import landvibe.springintro.item.domain.Item; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.simple.SimpleJdbcInsert; +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +public class JdbcTemplateItemRepository implements ItemRepository { + private final JdbcTemplate jdbcTemplate; + public JdbcTemplateItemRepository(DataSource dataSource) { + jdbcTemplate = new JdbcTemplate(dataSource); + } + @Override + public Item save(Item item) { + SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(jdbcTemplate); + jdbcInsert.withTableName("item").usingGeneratedKeyColumns("id"); + Map parameters = new HashMap<>(); + parameters.put("name", item.getName()); + parameters.put("count", item.getCount()); + parameters.put("price", item.getPrice()); + Number key = jdbcInsert.executeAndReturnKey(new + MapSqlParameterSource(parameters)); + item.setId(key.longValue()); + return item; + } + @Override + public Optional findById(Long id) { + List result = jdbcTemplate.query("select * from item where id = ? ", rowMapper(), id); + return result.stream().findAny(); + } + @Override + public Optional findByName(String name) { + List result = jdbcTemplate.query("select * from item where name = ? ", rowMapper(), name); + return result.stream().findAny(); + } + @Override + public List findAll() { + return jdbcTemplate.query("select * from item", rowMapper()); + } + private RowMapper rowMapper() { + return (rs, rowNum) -> { + Item item = new Item(); + item.setId(rs.getLong("id")); + item.setName(rs.getString("name")); + item.setPrice(rs.getInt("price")); + item.setCount(rs.getInt("count")); + return item; + }; + } +} \ No newline at end of file diff --git a/src/main/java/landvibe/springintro/item/repository/JpaItemRepository.java b/src/main/java/landvibe/springintro/item/repository/JpaItemRepository.java new file mode 100644 index 0000000..57e6a77 --- /dev/null +++ b/src/main/java/landvibe/springintro/item/repository/JpaItemRepository.java @@ -0,0 +1,34 @@ +package landvibe.springintro.item.repository; +import jakarta.persistence.EntityManager; +import landvibe.springintro.item.domain.Item; +import java.util.List; +import java.util.Optional; +public class JpaItemRepository implements ItemRepository { + private final EntityManager em; + public JpaItemRepository(EntityManager em) { + this.em = em; + } + @Override + public Item save(Item item) { + em.persist(item); + return item; + } + @Override + public Optional findById(Long id) { + Item item = em.find(Item.class, id); + return Optional.ofNullable(item); + } + @Override + public Optional findByName(String name) { + return em.createQuery("select i from Item i where i.name = :name", + Item.class) + .setParameter("name", name) + .getResultStream() + .findAny(); + } + @Override + public List findAll() { + return em.createQuery("select i from Item i", Item.class) + .getResultList(); + } +} \ No newline at end of file diff --git a/src/main/java/landvibe/springintro/item/repository/MemoryItemRepository.java b/src/main/java/landvibe/springintro/item/repository/MemoryItemRepository.java new file mode 100644 index 0000000..68b589c --- /dev/null +++ b/src/main/java/landvibe/springintro/item/repository/MemoryItemRepository.java @@ -0,0 +1,39 @@ +package landvibe.springintro.item.repository; + +import landvibe.springintro.item.domain.Item; +import org.springframework.stereotype.Repository; + +import java.util.*; + +public class MemoryItemRepository implements ItemRepository{ + private static Map store = new HashMap<>(); + private static long sequence = 0L; + + @Override + public Item save(Item item) { + item.setId(++sequence); + store.put(item.getId(),item); + return item; + } + + @Override + public Optional findById(Long id) { + return Optional.ofNullable(store.get(id)); + } + + @Override + public Optional findByName(String name) { + return store.values().stream() + .filter(item->item.getName().equals(name)) + .findAny(); + } + + @Override + public List findAll() { + return new ArrayList<>(store.values()); + } + + public void clearStore(){ + store.clear(); + } +} diff --git a/src/main/java/landvibe/springintro/item/repository/SpringDataJpaMemberRepository.java b/src/main/java/landvibe/springintro/item/repository/SpringDataJpaMemberRepository.java new file mode 100644 index 0000000..a42e702 --- /dev/null +++ b/src/main/java/landvibe/springintro/item/repository/SpringDataJpaMemberRepository.java @@ -0,0 +1,12 @@ +package landvibe.springintro.item.repository; + +import landvibe.springintro.item.domain.Item; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface SpringDataJpaMemberRepository extends JpaRepository, ItemRepository { + @Override + Optional findByName(String name); +} diff --git a/src/main/java/landvibe/springintro/item/service/ItemService.java b/src/main/java/landvibe/springintro/item/service/ItemService.java new file mode 100644 index 0000000..34c64d4 --- /dev/null +++ b/src/main/java/landvibe/springintro/item/service/ItemService.java @@ -0,0 +1,42 @@ +package landvibe.springintro.item.service; + +import landvibe.springintro.item.domain.Item; +import landvibe.springintro.item.repository.ItemRepository; +import landvibe.springintro.item.repository.MemoryItemRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Transactional +public class ItemService { + private final ItemRepository repository; + public ItemService(ItemRepository repository){ + this.repository = repository; + } + + /** + * 상품 등록 + */ + public Long create(Item item){ + long start = System.currentTimeMillis(); + try { + validateDuplicateItem(item.getName()); + repository.save(item); + return item.getId(); + } finally { + long end = System.currentTimeMillis(); + long timeMs = end - start; + System.out.println("create::timeMs = " + timeMs); + } + } + public List findItems(){ + return repository.findAll(); + } + public void validateDuplicateItem(String itemName){ + repository.findByName(itemName) + .ifPresent(i->{ + throw new IllegalArgumentException("이미 존재하는 상품입니다."); + }); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e7c1e8f..459d5e8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,6 @@ spring.application.name=springintro +server.port=8080 +spring.datasource.url=jdbc:h2:top://localhost/~/test +spring.datasource.driver-class-name=org.h2.Driver +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=none diff --git a/src/main/resources/templates/items/createForm.html b/src/main/resources/templates/items/createForm.html index 6331260..48171c3 100644 --- a/src/main/resources/templates/items/createForm.html +++ b/src/main/resources/templates/items/createForm.html @@ -26,4 +26,4 @@ - + \ No newline at end of file diff --git a/src/main/resources/templates/items/itemList.html b/src/main/resources/templates/items/itemList.html old mode 100755 new mode 100644 index 28a34de..220f018 --- a/src/main/resources/templates/items/itemList.html +++ b/src/main/resources/templates/items/itemList.html @@ -36,4 +36,4 @@ - + \ No newline at end of file diff --git a/src/test/java/landvibe/springintro/item/repository/MemoryItemRepositoryTest.java b/src/test/java/landvibe/springintro/item/repository/MemoryItemRepositoryTest.java new file mode 100644 index 0000000..4409341 --- /dev/null +++ b/src/test/java/landvibe/springintro/item/repository/MemoryItemRepositoryTest.java @@ -0,0 +1,79 @@ +package landvibe.springintro.item.repository; + +import landvibe.springintro.item.domain.Item; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + + +import java.util.List; + +import static org.assertj.core.api.Assertions.*; + +class MemoryItemRepositoryTest { + MemoryItemRepository repository = new MemoryItemRepository(); + @AfterEach + void afterEach(){ + repository.clearStore(); + } + + @Test + void save() { + //given + Item item = createItem("과자", 10, 1000); + + //when + repository.save(item); + + //then + Item foundItem = repository.findById(item.getId()).get(); + assertThat(foundItem).isEqualTo(item); + } + + @Test + void findById() { + Item 포카칩 = createItem("포카칩",10,1000); + repository.save(포카칩); + Item foundItem = repository.findById(포카칩.getId()).get(); + assertThat(foundItem).isEqualTo(포카칩); + } + + @Test + void findByName() { + //given + Item 눈을감자 = createItem("눈을감자",10,1000); + Item 프링글스 = createItem("프링글스",10,1000); + repository.save(눈을감자); + repository.save(프링글스); + + //when + Item foundItem = repository.findByName("눈을감자").get(); + + //then + assertThat(foundItem).isEqualTo(눈을감자); + } + + @Test + void findAll() { + //given + Item 눈을감자 = createItem("눈을감자",10,1000); + Item 프링글스 = createItem("프링글스",10,1000); + repository.save(눈을감자); + repository.save(프링글스); + + //when + List foundItems = repository.findAll(); + + //then + assertThat(foundItems.size()).isEqualTo(2); + assertThat(foundItems).contains(눈을감자,프링글스); + } + + private static Item createItem(String name, int count, int price){ + Item item = new Item(); + item.setName(name); + item.setCount(count); + item.setPrice(price); + return item; + } + +} \ No newline at end of file diff --git a/src/test/java/landvibe/springintro/item/service/ItemServiceTest.java b/src/test/java/landvibe/springintro/item/service/ItemServiceTest.java new file mode 100644 index 0000000..5a817aa --- /dev/null +++ b/src/test/java/landvibe/springintro/item/service/ItemServiceTest.java @@ -0,0 +1,67 @@ +package landvibe.springintro.item.service; + +import landvibe.springintro.item.domain.Item; +import landvibe.springintro.item.repository.ItemRepository; +import landvibe.springintro.item.repository.MemoryItemRepository; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + +@SpringBootTest +@Transactional +class ItemServiceTest { + @Autowired + ItemService service; + @Autowired + ItemRepository repository; + +// @BeforeEach +// void setUp(){ +// repository = new MemoryItemRepository(); +// service = new ItemService(repository); +// } +// @AfterEach +// void tearDown(){ +// repository.clearStore(); +// } + + @Test + public void 상품생성() throws Exception{ + //given + Item item = createItem("눈을감자",10,1000); + + //when + Long id = service.create(item); + + //then + Item foundItem = repository.findById(id).get(); + assertThat(foundItem).isEqualTo(item); + } + + @Test + void 중복이름_상품예외(){ + //given + Item item = createItem("눈을감자",10,1000); + Item duplicatedItem = createItem("눈을감자",10,1000); + service.create(item); + + //when & then + IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, + ()->service.create(duplicatedItem)); //예외발생 + assertThat(ex.getMessage()).isEqualTo("이미 존재하는 상품입니다."); + } + + private static Item createItem(String name, int count, int price){ + Item item = new Item(); + item.setName(name); + item.setCount(count); + item.setPrice(price); + return item; + } +} \ No newline at end of file diff --git a/top:/localhost/~/test.mv.db b/top:/localhost/~/test.mv.db new file mode 100644 index 0000000000000000000000000000000000000000..311b1f05be4e555ba54610f88fd2cc94209dbed3 GIT binary patch literal 20480 zcmeI4OK;mo5XVU&b_CaHd+DhN!n#g^7OcQsa``$%juqH|ofei7f00e*l5C8%|00;m9AOHmJ0D(Qw|99XifC)eV2mk>f00e*l z5C8%|00;m9AOHkzmq3=}H`FfcyGR|-6E@-@fgZhdv8nO>fENR(!zhYf9Pp|D{xWzS zfEu6mc$t8YDWbTn0Wj1)yNq3;#*y!0k0>|yN@@w-N;}e8O_FQU7s``2?Ne$;Aq zTE{!D_78RyjEya2>j6&RR9>}PN6P*S<>j{>rS)dN-DxXZTS~im&{3W~RrZ?gy=33q zJ=}jON%Ei4Ls?pv>He*%hy1v}n?Xw{`}Q1V6e0_$C-3x~`VSrX#@ORUo;sgdb<4VcJ|jF&9k@3MX_(X6|D9bYY+A8CClX8Es-; z+)fMlU@J~Ab?|0B`Y^Rk{r=|rr26yYm2S3-lsj*INlUHZboABNBIf2tvKfPeJ0+I2CUy1(*B70 zF)zOvrI*Ik>#~OSiD(kD-hh8Ye)-4ZeB2MBgXpAz9wn!4ahlclJ#7ceIqq419`1AFt;B zD668vQxj>`rBeT|y3`d8Wz0DgVxgHkRO0{KzpQ!xs?5V^k$+jg;@`*!;W!#*WF7LFF^-pG&t%+1kma1IARP_J+%2YQ(-!An(sp@|& z@5+w;_Yv3swcl!gOSK159T~*YLWb|-zz9u?)pZl=wuf+?VB*;h<_DP$spkTsPN*H2 zmdWZQ6AN`y^Bp_Hq;6SZhzy_Ab175L)kQs5Dqqe^!I$H1_ciT~S*|eOXB&0Kp7^qn z2{;xAqZ0kP{er8*XgGO1)0j)&qv-qG?7Y>zwbWN;TMH$Hbz{|{CFKdkD1J=g!nYWn~BklM=ne|bQS>;GiZb>{Uy4~3MWz$5@W6JIO!zp*e_ z!9y2CuySSne`QQ~E<9N=&sY?m6#739KQUSOFFRQf{saAg$Cou=9uNQmKmZ5;0U)r1 zz>NMbR&bTSrbmIP6VtlMWO|{-bNz2l>Hn+p|MR&Xogh}pJDXMge;fJ#XSbODe^kx? z8~OU5thWBYeo39K|C6GMJf&WQSEe#**Q}_M^}m2Vx4gixsNL z%GLA#=^}k9|DOhhmf4pUh|K5{k^f&J0MgNS$MgT7|3BFLKj?qZ|4V+U;Ugdb1b_e# i00KY&2;2;TO#kQlyU_n;CI8RNfLNAUi1r&i*!T}U8M5X8 literal 0 HcmV?d00001 diff --git a/top:/localhost/~/test.trace.db b/top:/localhost/~/test.trace.db new file mode 100644 index 0000000..5b0054f --- /dev/null +++ b/top:/localhost/~/test.trace.db @@ -0,0 +1,81 @@ +2024-07-22 06:27:39.670699+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item where name = ? [42104-224] +2024-07-22 06:28:14.551115+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item where name = ? [42104-224] +2024-07-22 06:28:18.915254+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:28:51.473506+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:30:41.779646+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item where name = ? [42104-224] +2024-07-22 06:30:44.090861+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:30:47.126538+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:31:13.251692+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:31:13.789977+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:31:43.472163+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:31:48.061998+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:32:26.908583+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:34:53.080648+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:38:23.940611+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:38:27.673013+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:38:31.607213+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:40:51.995039+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 06:40:55.172849+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224] +2024-07-22 12:56:29.095268+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 12:56:29.723690+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 12:56:32.464725+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 12:56:41.789791+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 12:57:15.786025+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 12:57:18.039077+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 12:57:19.600663+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 13:01:45.983813+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 13:14:22.558281+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] From 5f4cb6543761831f1a8b76060c2b3634a89b29eb Mon Sep 17 00:00:00 2001 From: taekyunlee Date: Mon, 22 Jul 2024 15:59:42 +0900 Subject: [PATCH 2/2] re-upload --- .../springintro/item/config/ItemConfig.java | 27 +++---- src/main/resources/application.properties | 3 +- top:/localhost/~/test.mv.db | Bin 20480 -> 28672 bytes top:/localhost/~/test.trace.db | 66 ++++++++++++++++++ 4 files changed, 83 insertions(+), 13 deletions(-) diff --git a/src/main/java/landvibe/springintro/item/config/ItemConfig.java b/src/main/java/landvibe/springintro/item/config/ItemConfig.java index fc47105..c93d5c1 100644 --- a/src/main/java/landvibe/springintro/item/config/ItemConfig.java +++ b/src/main/java/landvibe/springintro/item/config/ItemConfig.java @@ -11,8 +11,7 @@ @Configuration public class ItemConfig { -// private final DataSource dataSource; -// private final EntityManager em; + private final DataSource dataSource; // // @Autowired // public ItemConfig(DataSource dataSource, EntityManager em) { @@ -20,20 +19,24 @@ public class ItemConfig { // this.em = em; // } - private final ItemRepository itemRepository; + public ItemConfig(DataSource dataSource) { + this.dataSource = dataSource; + } + +/* private final ItemRepository itemRepository; public ItemConfig(ItemRepository itemRepository){ this.itemRepository = itemRepository; - } + }*/ @Bean public ItemService itemService(){ - return new ItemService(itemRepository); + return new ItemService(itemRepository()); } -// @Bean -// public ItemRepository itemRepository(){ -// //return new MemoryItemRepository(); -// //return new JdbcItemRepository(dataSource); -// //return new JdbcTemplateItemRepository(dataSource); -// return new JpaItemRepository(em); -// } + @Bean + public ItemRepository itemRepository(){ + //return new MemoryItemRepository(); + //return new JdbcItemRepository(dataSource); + return new JdbcTemplateItemRepository(dataSource); + //return new JpaItemRepository(em); + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 459d5e8..267d0f0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,7 @@ spring.application.name=springintro server.port=8080 -spring.datasource.url=jdbc:h2:top://localhost/~/test +spring.datasource.url=jdbc:h2:tcp://localhost/~/test spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.username=sa spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=none diff --git a/top:/localhost/~/test.mv.db b/top:/localhost/~/test.mv.db index 311b1f05be4e555ba54610f88fd2cc94209dbed3..486313b42062bb8d7fc44ed451a73a01dea7f2fe 100644 GIT binary patch literal 28672 zcmeHQ&2HO95GI}2Vbin?ivC>HG(RY!3gmM6dy11dNC3wzEGNjJK(Hj2j$v66WZAWQ z>LUcbwWsz_1iAFkLxTc+k-k9Dcj%=t zonE{hy5ij4`i6&=X`0RW$zFFmv@F()JDhbxs~HbC8}cNy0yA-W%3RZKroF)q8-{js zpAUAode9ASNIQHOKjDKg;XJk-kDS-=4-r5F5CKF05kLeG0Ym^1Km-s0L;w*$1YR2g zcai_UHtca?L;w*$1P}p401-e05CKF05kLeG0Yu@?D4t?68B7 zxF($YAtdw%z1}dSjt_MKrb&rqHiug~JS4W4MzNavcbi>)FbtjMuos6UN*nY0%W4R| z(*M#H7c_lA`=oL8QF~>hacg~Ld1K}A%?I~ZZ#M{`ml~JeA>zZvgZ9dLPF+*wZ`4$_TB8feEa^rHBHlB=+AX+NqZ}Yq-9yOymHR%@F8n$ zB}*9&ElZq;I61%Q5=2^*QqUThovnTTWe#ixr~o$m>^@wV5Er-=NasM0B2A-+HTSxE zyHJ54ffvo?;lr}{!cht_s9c3+FOK*6tQ#MOru|bXuT#iNM&z}dmAv9XU{DPr<%LH; zJ`|%8(@bP5B0=?RxONa15>FFRJSe_zsv=U|x@~|sr@2p~hIEeNYOlNbG60g=Ah5Wry{HW<3NP1v z*1vqS(~H)5$_Km~^UK+ae?H4C_u=i%d&A@O$Ko?xzo;#N;%ixKF*}j`Xy->KKf3wR z%a4A343@fVhqoSI$WI_f_PySg4Unz82KheBKkxNZRMb(7v|Z?k1JvSwH|i^{A@3z)e$;p2R!us+k({O)3=<~BbJ{ge@h zn6$aiIw8DYc4Vj4mAo5#7npy%S4yd8(!l>r3|2}y-qQ(~%S^8t4VIe(+AUu9_X&_>$dLb-h#zo?S5O@T2M8(U21STqXxGNjR-nWF^8%~6dGLB zh@<+D7PgYcWBSmIY@aF`9MoenK|KN-r8c*74PH}^-jAgQKi=Y4V-}~f>Z1z$Xp^HV za8<&IHijIdz{ONTfotD_0{;l~@eNJC^)%PZ`maw5>nLRnq+21(V{RJ2*zn5OI6QJD z85>hU6D$*WC4MwwY?4e?su~;7D2z=pmF@drY$nS3T`n^o5CKF05kLeGftNr)Qb)ueqQe;EfEi)_pS{=E9ULHz$`3Rs__3}(;jTUQ{xp7&n+X)v-AIH!Ts?VvnruGDaI`Lzwj1{ z0B+ux6u_OxsgeJ`gb#^b5dlO15kLgqJOt|eyW;;|#s3p8HMx1B{NJxR5Hd|Y!vEdz z6oKy%pD7NDFZjR6TR^&Y4!mCuA@cu!pIH9?x&He|{@*RVNAF1Q@mZOTk>1#7K3(<3 zg!h;gR>*vMJ;ZXf7nZq=IpX6^nWwD6M5oODp%m0B(p=8Ss;g%t` zfD(a(sbQt@K!UG4YJQPhJfV%l7CnHKT!C80{owz zDF0^@_&>1y(fWT^ZoIZ&*Pqz`5Bxt+_y04I{})MKn=I#H(k$|c$BbZq3U@29yqAnu~culFxm>T*LF$z(a0dK;1$Rbce z7J&#^q)ZK2Sovnz*=ip$?Q#8s+J*?&<1iMrn1z$S%08I?$NWF?|LXTpkpG*o86f)s s7v%pnmk^tX03v`0AOfcV0m=U*|E~DI@?Z3rlMf00e*l5C8%|00;m9AOHmJ0D(Qw|99XifC)eV2mk>f00e*l z5C8%|00;m9AOHkzmq3=}H`FfcyGR|-6E@-@fgZhdv8nO>fENR(!zhYf9Pp|D{xWzS zfEu6mc$t8YDWbTn0Wj1)yNq3;#*y!0k0>|yN@@w-N;}e8O_FQU7s``2?Ne$;Aq zTE{!D_78RyjEya2>j6&RR9>}PN6P*S<>j{>rS)dN-DxXZTS~im&{3W~RrZ?gy=33q zJ=}jON%Ei4Ls?pv>He*%hy1v}n?Xw{`}Q1V6e0_$C-3x~`VSrX#@ORUo;sgdb<4VcJ|jF&9k@3MX_(X6|D9bYY+A8CClX8Es-; z+)fMlU@J~Ab?|0B`Y^Rk{r=|rr26yYm2S3-lsj*INlUHZboABNBIf2tvKfPeJ0+I2CUy1(*B70 zF)zOvrI*Ik>#~OSiD(kD-hh8Ye)-4ZeB2MBgXpAz9wn!4ahlclJ#7ceIqq419`1AFt;B zD668vQxj>`rBeT|y3`d8Wz0DgVxgHkRO0{KzpQ!xs?5V^k$+jg;@`*!;W!#*WF7LFF^-pG&t%+1kma1IARP_J+%2YQ(-!An(sp@|& z@5+w;_Yv3swcl!gOSK159T~*YLWb|-zz9u?)pZl=wuf+?VB*;h<_DP$spkTsPN*H2 zmdWZQ6AN`y^Bp_Hq;6SZhzy_Ab175L)kQs5Dqqe^!I$H1_ciT~S*|eOXB&0Kp7^qn z2{;xAqZ0kP{er8*XgGO1)0j)&qv-qG?7Y>zwbWN;TMH$Hbz{|{CFKdkD1J=g!nYWn~BklM=ne|bQS>;GiZb>{Uy4~3MWz$5@W6JIO!zp*e_ z!9y2CuySSne`QQ~E<9N=&sY?m6#739KQUSOFFRQf{saAg$Cou=9uNQmKmZ5;0U)r1 zz>NMbR&bTSrbmIP6VtlMWO|{-bNz2l>Hn+p|MR&Xogh}pJDXMge;fJ#XSbODe^kx? z8~OU5thWBYeo39K|C6GMJf&WQSEe#**Q}_M^}m2Vx4gixsNL z%GLA#=^}k9|DOhhmf4pUh|K5{k^f&J0MgNS$MgT7|3BFLKj?qZ|4V+U;Ugdb1b_e# i00KY&2;2;TO#kQlyU_n;CI8RNfLNAUi1r&i*!T}U8M5X8 diff --git a/top:/localhost/~/test.trace.db b/top:/localhost/~/test.trace.db index 5b0054f..8a00eec 100644 --- a/top:/localhost/~/test.trace.db +++ b/top:/localhost/~/test.trace.db @@ -79,3 +79,69 @@ select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] 2024-07-22 13:14:22.558281+09:00 jdbc[3]: exception org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 13:33:15.687339+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:02:03.877594+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:37:55.046655+09:00 jdbc[13]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:38:22.206815+09:00 jdbc[13]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:39:39.582182+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:39:39.768284+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:39:43.516229+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:45:23.362213+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:45:27.304265+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:46:20.284427+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:47:25.858248+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:47:26.758774+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:48:14.730746+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:48:33.030285+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:48:39.373925+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:50:25.488381+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 14:50:43.856552+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 15:27:26.001008+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 15:27:29.653356+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 15:30:08.541652+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 15:32:11.515399+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select i1_0.id,i1_0.count,i1_0.name,i1_0.price from item i1_0 [42104-224] +2024-07-22 15:34:07.024311+09:00 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ITEM" not found (this database is empty); SQL statement: +select * from item [42104-224]