• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Combining Joined Table Inheritance With One or Many to Many Relationships

 
Ranch Hand
Posts: 146
2
Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic