0
我想要設計DAO接口我有dept_id的department表,帶有dept_id和employee_id的employee表,帶有employee_id的項目表和帶有employee_id的報表。現在的要求是,我想在spring
做這件事情,所以我很困惑,我應該爲每個表或一個包含所有表的所有實現邏輯的通用DAO做不同的DAO,如果它的通用我應該給我什麼方法,請幫助我在界面設計在彈簧上設計不同的-2DAO或單個DAO
我必須做出EmployeeDAO接口,但我必須做出項目和報告和部門表中的所有鬆耦合我有EmployeeDAO做IM在這裏展示我的EmployeeDAO接口
package com.ankur.tutorial.dao;
import java.util.List;
import com.ankur.tutorial.employee.model.Employee;
/**
* The employee DAO is the main Data Access Object that will allow to retrieve
* and update the employee objects from and to the database. The retrieve and
* update is done in a manner that employee, the projects and reporting
* associated are updated
*
*
*/
public interface EmployeeDAO {
/**
* @throws EmployeeDAOException
*
* Returns all the employees from the database along with
* projects and reportigns.
*
* @return List of all employees.
* @throws
*/
List<Employee> getAllEmployees();
/**
* Search for an employee by name. The name will match either the first name
* or the last name. The matching is done using the SQL expression LIKE
* %name%
*
* @param name
* The name to search for
* @return The list of employees with matching name.
* @throws EmployeeDAOException
*/
List<Employee> findEmployees(String name);
/**
* Select employee by ID.
*
* @param id
* The ID (Number) of the employee
* @return The employee with employee number matching the id
* @throws EmployeeDAOException
*/
Employee getEmployee(long id);
/**
* Update the employee and the associated project and reporting to the
* database.
*
* @param employee
* The employee to update
* @return true if the employee record is updated
* @throws EmployeeDAOException
*/
boolean updateEmployee(Employee employee);
/**
* Delete the employee and the associated projects and reportings.
*
* @param employee
* The employee to be deleted.
* @return true if the employee record is deleted
* @throws EmployeeDAOException
*/
boolean deleteEmployee(Employee employee);
/**
* Create employee, project and reporting records in the database.
*
* @param The
* employee to be created
* @return true if the creation is successful
* @throws EmployeeDAOException
*/
}
還有一個問題,我們如何在不使用getJdbcTemplate()方法的情況下在不同的dao中使用一個數據源,現在我使用getJdbctemplate()並將xml中的數據源引用到每個DAO impl – henrycharles