0

我想设计 DAO 界面,我有带有 dept_id 的部门表,带有 dept_id 和employee_id 的员工表,带有employee_id 的项目表和带有employee_id 的报告表。现在的要求是我想做这件事,spring所以我很困惑,我应该为每个表或一个包含所有表的所有实现逻辑的通用 DAO 制作不同的 DAO,如果它是通用的,我应该给出什么方法请帮助我设计界面

我已经制作了 EmployeeDAO 界面,但我必须制作项目、报告和部门表都是松散耦合的我已经完成了 EmployeeDAO 我在这里显示了我的 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
     */

}
4

1 回答 1

0

不要创建一个操纵所有表的 DAO。时期。

好吧,再来一句。如果您要增强系统并添加越来越多的表,您打算如何维护。你的超级多合一 DAO 将是巨大的。

于 2012-12-18T09:50:21.047 回答