Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Combining Joined Table Inheritance With One or Many to Many Relationships

 
Ashley Bye
Ranch Hand
Posts: 132
2
Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just about to start implementing a database schema, which has a few tables that inherit from another table. Some of the parent tables can be concrete and others need to be abstract since they are of no use on their own. A couple of the concrete tables also have one or many to many relationships based on the id which is auto generated in the abstract table. In the database schema, this has been modelled such that the relationship is from the concrete classes. However, since I am in a position to change the schema if need be, should the relationship be from the abstract table instead? If it can be from the concrete table how do I refer to the parent class in the relationship annotation in the child class? i.e. @OneToMany(mappedBy="ParentClass.id")

Is this a problem, or because ChildClass extends ParentClass will it be happy with just being supplied mappedBy="id")?

The same question goes for some concrete tables being extended - in some situations the extension is necessary because the extra data is required. Therefore I don't want to put the relationships on the parent table in this instance because there might not actually be a relationship there.

It's late, so please let me know if this doesn't make sense and I will re-word it if needed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic