• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Mapping in Hibernate

 
Ranch Hand
Posts: 40
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When should we use Inheritance mapping and relational mapping in Hibernate?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
relational mapping??? No idea what you mean by that as a separate thing. In Hibernate you are mapping to your relational database, so technically all the mapping in Hibernate is relational mapping. And you can't use hibernate without any mapping.

Now Inheritance mapping is different, and it is used for specific reasons. Personally, I actually avoid using Inheritance as much as possible. HOWEVER, there are times where a hierarchical Domain object model is warranted. If you have domain objects that inherit from other domain objects, then you sort of have to use inheritance mapping. Just to make it cleaner. It still isn't required.

Basically, it is about your domain classes. And in Java, I think it is always better to try not to use inheritance in your domain code, but sometimes it is necessary. I still find it rare when I need to use it. My friend on my team though, loves ORM inheritance mapping. ;)

What I find with inheritance mapping is that later when you want to delete data in via ORM code, it becomes a bit tougher to delete it because the data model becomes coupled/intertwined and more difficult to find the right order of deletion of rows through a bunch of db tables.

Mark
 
The City calls upon her steadfast protectors. Now for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic