Hibernate mapping to manage bidirectional relationship using intermediate table

Posted by shikarishambu on Stack Overflow See other posts from Stack Overflow or by shikarishambu
Published on 2010-06-17T14:55:08Z Indexed on 2010/06/17 16:43 UTC
Read the original article Hit count: 191

I have an object hierarchy that is as follows.

Party > inherited by > Organization and Person Organization > inherited by > Customer, Vendor Person > inherited by > Contact

In the database I have the following tables Party, Customer, Vendor, Contact. All of them have a corresponding row in Party table.

Contact belongs to either Vendor or Customer. I have a field on the Contact table for org_party_id. However, since the organization can be either a Customer or Vendor I need to be able to look at different tables.

Is there a way to map this in hibernate? Or, a better way to manage it in DB/ hibernate?

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate