• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Mapping in Hibernate

Ranch Hand
Posts: 40
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When should we use Inheritance mapping and relational mapping in Hibernate?
Posts: 17346
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.

Crusading Chameleon likes the size of this ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic