1 Reply Latest reply on Oct 27, 2004 9:39 AM by bill.burke

    Inheritance and Relationships

    justinb

      Hi,

      It's great to be able to try this out... thanks alot.

      I'm not sure if I am doing something wrong:
      I have three entities,

      - Contact
      - Employee (extends Contact)
      - Branch (extends Contact)

      I used the JOINED inheritance type for this structure. And it compiles and deploys great, just like that. But then, I take it one step further and have Branch contain many Employees, this doesn't work (I get an org.hibernate.MappingException).

      I've found that if I remove all inheritance from Contact then it deploys great again.

      I should also mention that it is only the @OneToMany in Branch that causes the problem, the @ManyToOne in Employee is fine in all cases (even if I completely remove the relationship on Branch's side).

      So I have to choose between
      a) having this one-to-many relationship between Branch and Employee
      or
      b) having Branch and Employee inherit from Contact.

      It would be really nice to have both.

      Thanks,
      Regards