EJB design: Dao Pattern - Search on multiple tables

  1. Dao Pattern - Search on multiple tables (2 messages)

    In many applications we have to search records using a number of tables, not just one. If we are using the Dao pattern, where can we add those search operations? For example: Say there are EmployeeDoa and ProjectDao which support basic CRUD operations. What if we need to search Employees in a given project? Are we adding a method as follows? interface EmployeeDao { List searchByProjectId(EmployeeDTO e, ProjectDTO p); }
  2. Can someone give some input pls?
  3. From what you say, employees inside projects, there must be an association between the project and the employees (I could imagine in this case either one project with many employees or many to many association, if one employee may be involved in more than one project). So create your method inside the EmployeeDAO and use the appropriate query with the appropriate join between the two tables.