Vertx repository refactor

This commit is contained in:
Grzegorz Piwowarek 2017-06-19 08:49:45 +02:00
parent 9048d5215b
commit df9953b6e6
2 changed files with 8 additions and 17 deletions

View File

@ -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<Article, Long> {
public interface ArticleRepository extends JpaRepository<Article, Long> {
}

View File

@ -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<Article> getAllArticle() {
List<Article> articles = new ArrayList<>();
articleRepository.findAll()
.forEach(articles::add);
return articles;
return articleRepository.findAll();
}
}