2 Replies Latest reply on Aug 9, 2006 7:18 PM by Andre Fernando Salvati

    Two relationship one-to-many

    Andre Fernando Salvati Novice

      Hi,

      I have two relationships between Employee and Order. One to get his "started" orders and the other to get his finished orders:

      Employee
      -----------
      codEmployee

      Order
      ----------
      EmployeeFinalizer
      EmployeeStarter


      When I try to persist a new Order with different Employees it's all fine, because I get the following on my database:

      Employee - 01
      ----------------

      Employee - 02
      ----------------

      Order - 01
      ------------
      employeeStarter - 01
      employeeFinalizer - 02


      but when I recall the Employee with findEmployee() method I see in my grafh:

      Employee - 01
      -----------
      startedOrders - 01
      finalizedOrders - 01

      this is wrong!!! Employee 01 did not finish Order 01. Am I doing something wrong. These are my mappings:

      Employee
      -----------

      @OneToMany(fetch=FetchType.EAGER)
      @JoinColumn(name="OrderCode")
      private Collection startedOrders;

      @OneToMany(fetch=FetchType.EAGER)
      @JoinColumn(name="OrderCode")
      private Collection finalizedOrders;

      Order
      ------
      @ManyToOne
      private Employee employeeStarter;
      @ManyToOne
      private Employee employeeFinalizer;

      Thanks by now.