StudentServiceSpringImpl.java

package com.sunilos.proj0.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import org.springframework.transaction.annotation.Propagation;

import org.springframework.transaction.annotation.Transactional;

import com.sunilos.proj0.dao.StudentDAOInt;

import com.sunilos.proj0.dto.StudentDTO;

/**

* Session facade of Student Service. It is transactional, apply delcarative

* transactions with help of Spring AOP.

*

* If unchecked exception is propagated from a method then transaction is rolled

* back.

*

* Default propogation value is Propagation.REQUIRED and readOnly = false

*

* @author SunilOS

* @version 1.0

* @Copyright (c) SunilOS

*/

@Service(value = "studentService")

public class StudentServiceSpringImpl implements StudentServiceInt {

@Autowired

private StudentDAOInt dao = null;

public void setDao(StudentDAOInt dao) {

this.dao = dao;

}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)

public long add(StudentDTO dto) {

return dao.add(dto);

}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)

public long update(StudentDTO dto) {

return dao.update(dto);

}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)

public void delete(long id) {

dao.delete(id);

}

@Transactional(readOnly = true)

public StudentDTO findByEmail(String email) {

return dao.findByEmail(email);

}

@Transactional(readOnly = true)

public StudentDTO findByPK(long pk) {

return dao.findByPK(pk);

}

@Transactional(readOnly = true)

public List<StudentDTO> search(StudentDTO dto, int pageNo, int pageSize) {

return dao.search(dto, pageNo, pageSize);

}

@Transactional(readOnly = true)

public List<StudentDTO> search(StudentDTO dto) {

return dao.search(dto, 0, 0);

}

}