EmployeeDao.java
package com.sword.rapdemo;
import java.util.List;
public interface EmployeeDao {
void save(Employee employee);
void delete(Employee employee);
List<Employee> findAll();
}
EmployeeDaoImpl.java
package com.sword.rapdemo;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
public class EmployeeDaoImpl implements EmployeeDao {
private HibernateTemplate hibernateTemplate;
public void setSessionFactory(SessionFactory sessionFactory) {
hibernateTemplate = new HibernateTemplate(sessionFactory);
}
public void delete(Employee employee) {
hibernateTemplate.delete(employee);
}
@SuppressWarnings("unchecked")
public List<Employee> findAll() {
return hibernateTemplate.loadAll(Employee.class);
}
public void save(Employee employee) {
hibernateTemplate.save(employee);
}
}
EmployeeService.java
package com.sword.rapdemo;
import java.util.List;
public interface EmployeeService {
void save(Employee employee);
void delete(Employee employee);
List<Employee> findAll();
}
EmployeeServiceImpl.java
package com.sword.rapdemo;
import java.util.List;
public class EmployeeServiceImpl implements EmployeeService {
private EmployeeDao employeeDao;
public void setEmployeeDao(EmployeeDao employeeDao) {
this.employeeDao = employeeDao;
}
public void save(Employee employee) {
employeeDao.save(employee);
}
public void delete(Employee employee) {
employeeDao.delete(employee);
}
public List<Employee> findAll() {
return employeeDao.findAll();
}
}