From df9953b6e6950353b0edd63cd577346c5bffdb3c Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Mon, 19 Jun 2017 08:49:45 +0200 Subject: [PATCH] Vertx repository refactor --- .../repository/ArticleRepository.java | 8 ++------ .../vertxspring/service/ArticleService.java | 17 ++++++----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java b/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java index 843c88b694..21f1ab7425 100644 --- a/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java +++ b/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java @@ -1,11 +1,7 @@ package com.baeldung.vertxspring.repository; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - import com.baeldung.vertxspring.entity.Article; +import org.springframework.data.jpa.repository.JpaRepository; -@Repository -public interface ArticleRepository extends CrudRepository { - +public interface ArticleRepository extends JpaRepository { } diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java b/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java index 55cb8bbfcb..8817701036 100644 --- a/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java +++ b/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java @@ -1,25 +1,20 @@ package com.baeldung.vertxspring.service; -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - import com.baeldung.vertxspring.entity.Article; import com.baeldung.vertxspring.repository.ArticleRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; @Service public class ArticleService { @Autowired - ArticleRepository articleRepository; + private ArticleRepository articleRepository; public List
getAllArticle() { - List
articles = new ArrayList<>(); - articleRepository.findAll() - .forEach(articles::add); - return articles; + return articleRepository.findAll(); } }