Inheritance is one of the key concepts in Java, and most development teams prefer using it in their domain model. Unfortunately, relational table models don’t support the concept of inheritance. The JPA specification defines multiple mapping strategies to bridge the gap between the object-oriented and the relational world. I explained them in great detail in my Ultimate Guide to Inheritance Mappings (https://thorben-janssen.com/complete-guide-inheritance-strategies-jpa-hibernate/).
When I recently taught these mappings strategies in an in-house workshop, I was asked if it’s possible to combine InheritanceType.SINGLE_TABLE with InheritanceType.JOINED. This is not an uncommon question, especially if the team is working on huge and complex enterprise applications. But the answer to that question is: No. Based on the JPA specification, persistence providers can support this, but they don’t have to. Hibernate doesn’t support the mix of multiple strategies.
But in most cases, you can combine your inheritance mapping with a @SecondaryTable mapping to achieve your mapping goals.
Like my channel? Subscribe!
➜ http://bit.ly/2cUsid8
Read the accompanying post: https://thorben-janssen.com/hibernate-mix-inheritance-mappings/
Other posts mentioned in the video:
Ultimate Guide to Inheritance Mappings - https://thorben-janssen.com/complete-guide-inheritance-strategies-jpa-hibernate/
Want to connect with me?
Blog: https://thorben-janssen.com/
Twitter: https://twitter.com/thjanssen123
Facebook: https://www.facebook.com/thorbenjanssenofficial
Linkedin: https://www.linkedin.com/in/thorbenjanssen/
0 Comments