net.roseindia.service

This package is the part of Spring and Hibernate JPA integration application which contains service interface and it's implementation class.

net.roseindia.service

net.roseindia.service

This package is the part of  Spring and Hibernate JPA  integration application which contains service interface and it's implementation class.

For returning to main example(Spring Jpa Hibernate). Click here.

ArticleService.java

package net.roseindia.service;

import java.util.List;

import net.roseindia.model.Article;

public interface ArticleService {

public void addArticle(Article article);

public List<Article> listArticles();
}

ArticleServiceImpl.java

package net.roseindia.service;

import java.util.List;

import net.roseindia.dao.ArticleDao;
import net.roseindia.model.Article;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("articleService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class ArticleServiceImpl implements ArticleService {


private ArticleDao articleDao;

@Autowired
public ArticleServiceImpl(ArticleDao articleDao) {
this.articleDao = articleDao;
}

public ArticleServiceImpl() {
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void addArticle(Article article) {
articleDao.saveArticle(article);
}

public List<Article> listArticles() {
return articleDao.listArticles();
}

}