posted 10 years ago
I want to annotate my classes using Hibernate. Suppose you have a UML diagram were you have a Person as a superclass, and a Member who is a child class of Person. Then you have Member who can be composed of many EmergencyContacts:
EmergencyContact *----1<> Member ----> Person
The Member will have an attribute of type List<EmergencyContact>. The EmergencyContact will have a foreign key called Member_Id that points to an Id in Member. I'm going to annotate the inheritance relationship between Person with @MappedSuperclass and Person with @Entity. How would you annotate EmergencyContact? Is there a best way to design a database with a composite relationship like this, or is the choice debatable? Should I create another table by labeling EmergencyContact with @Entity?