5 Replies Latest reply on Jul 24, 2006 9:13 PM by Marcelo Farinelli

    Self-referencing foreign keys

    Marcelo Farinelli Newbie

      I used the CRUD generator to create an app based on the Employees table provided by Oracle. After a few adjustments, I got it working pretty nice.

      This table has a foreign key (manager_id) that references the primary key of the same table (employee_id). That is, an employee can manage many employees (one-to-many) and this very same employee can be managed by another employee (many-to-one).

      In the application, I can successfully:
      - Search for existing employees.
      - Create/Update/Delete employees.
      - Select a manager for an existing employee or when creating a new employee.

      The problem I will describe could be easily solved by getting rid of the "View Manager", "View Employee" and "Create Employee" buttons shown in the figure. But I would like to know if there is a possible solution.

      http://images.tigratuning.com.br/misc/seamapp.jpg

      When I click one of these buttons, essentially what happens on all of them is that I need to get a new editor for a employee different than the one I'm currently editing.

      I can't use the same employeeEditor, because I will certainly get a concurrent call exception.

      There's no way to create editors for the manager or managed employee, since, well, you can imagine where this would take us... an endless mess.

      Is there a way out of this? Any possible solution?

      Thanks in advance.