diff --git a/src/main/java/com/example/naverrestaurant/db/H2DbRepositoryAbstract.java b/src/main/java/com/example/naverrestaurant/db/H2DbRepositoryAbstract.java index cc37c34..1f4904d 100644 --- a/src/main/java/com/example/naverrestaurant/db/H2DbRepositoryAbstract.java +++ b/src/main/java/com/example/naverrestaurant/db/H2DbRepositoryAbstract.java @@ -70,15 +70,17 @@ public List listAll() { @Override public void updateById(int index, T entity) { - String updateByIdQuery = "update restaurant set isvisit=?, visitcount=? where index=?"; + String updateByIdQuery = "update restaurant " + + "set title=?, category=?, address=?, roadAddress=?, homepageLink=?, imageLink=?, isvisit=?, visitCount=?, lastVisitDate=?, starRating=? where index=?"; WishListEntity wishListEntity = (WishListEntity) entity; - jdbcTemplate.update(updateByIdQuery, wishListEntity.isVisit(), wishListEntity.getVisitCount(), index); - } + Object []updateParams = new Object[] {wishListEntity.getTitle(), + wishListEntity.getCategory(), wishListEntity.getAddress(), wishListEntity.getRoadAddress(), + wishListEntity.getHomePageLink(), wishListEntity.getImageLink(), wishListEntity.isVisit(), + wishListEntity.getVisitCount(), wishListEntity.getLastVisitDate(), wishListEntity.getStarRating(), index}; + + jdbcTemplate.update(updateByIdQuery, updateParams); - public void updateStarRatingById(int index, int starRating){ - String updateStarRatingByIdQuery = "update restaurant set starRating = ? where index = ?"; - jdbcTemplate.update(updateStarRatingByIdQuery, starRating, index); } private RowMapper wishListEntityRowMapper(){ diff --git a/src/main/java/com/example/naverrestaurant/wishlist/service/WishListService.java b/src/main/java/com/example/naverrestaurant/wishlist/service/WishListService.java index f521439..128f86f 100644 --- a/src/main/java/com/example/naverrestaurant/wishlist/service/WishListService.java +++ b/src/main/java/com/example/naverrestaurant/wishlist/service/WishListService.java @@ -123,7 +123,7 @@ public void setStarRating(int index, int starRating){ if(restaurant.isPresent()){ var restaurantEntity = restaurant.get(); restaurantEntity.setStarRating(starRating); - wishListRepository.updateStarRatingById(index, starRating); + wishListRepository.updateById(index, restaurantEntity); var result = wishListRepository.findById(index); System.out.println(result.toString());