Inheritance Mapping In Hibernate – Introduction

Hibernate » on Jun 20, 2011 { 25 Comments } By Sivateja

Compared to JDBC we have one main advantage in hibernate, which is hibernate inheritance.Β  Suppose if we have base and derived classes, now if we save derived(sub) class object, base class object will also be stored into the database.
But the thing is we must specify in what table we need to save which object data ( i will explain about this point later, just remember as of now).

For Example:

class Payment
   // content will goes here
class CreditCard extends Payment
   // content will goes here
  • See if you save CreditCard class object, then payment class object will also be saved into the database

Hibernate supports 3 types of Inheritance Mappings:

  • Table per class hierarchy
  • Table per sub-class hierarchy
  • Table per concrete class hierarchy

Note: We can also called this Hibernate Inheritance Mapping as Hibernate Hierarchy

Will see these 3 Inheritance Mappings in depth___, friends ensure you are clear about all previous concepts so far we covered, if not so you may not understand further, please refer once if you have any doubts.

​ ​​

You Might Also Like

  ::. About the Author .::

Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


25 Responses to “Inheritance Mapping In Hibernate – Introduction”
  1. rajkirpal says:

    Hi, Java4s

    You have explained the tuffest topics in very very essiest way.
    really i never find this kind of explanation on any website or in any book ever before.

    Thank you so much.

  2. Java4s says:


    Thanks much friend πŸ™‚

  3. ram says:

    Way of explanation its very good thank you

  4. Gahininath says:

    I really enjoyed..thanx alot to is very useful and simple site..

  5. priyabrat says:

    Thanks Sivateja for the nice post.
    Could you please post the mapping example using annotation.

  6. sritej says:

    Thanks..Very clean explanation.. Could you please tell me, which one is better to use out of three..

  7. satti says:

    Thanks siva. could you please tell me, which is the better to use in that?

  8. Amar says:

    Good…site .Any one can understand easily.

  9. Naveen says:

    bhai, bahut hi badiya likhte ho.

    Keep it up Bro.

  10. Shashi says:

    Thanks a lot Shiva……………..:). it is explained very easyest way and understandable.

  11. Nandu says:

    Whenever I go to understand any tough topic in java. I search the topic as Topic Name appended with java4s

  12. biram says:

    good site

  13. arch says:

    very good site to learn…keep posting πŸ™‚

  14. Swamy says:

    I have learned hibernate from core to concepts….This site is very help full

  15. swetha says:

    Thank you so much SivaTeja for this tutorial:)

  16. sagar s rao says:


    Awesome job helped a lot

  17. Basu says:

    Nice Explanation…

  18. RAMA says:

    when i was read this tutorial,
    it is all about the class room explanation by Shekar sir from Satya institute,Ameerpet,Hyderabad.

    Thank you guys for the presentation of line to line from note book by shekar sir….

  19. haris says:

    I must say, ur articles have really brushed up my topics dat any site or book couldn’t do….amazing!

  20. akshay says:

    BEST EXPLAINED…hats off to you bro…

  21. Satheesh Banda says:

    Very good site to learn…keep posting

  22. chinujava says:

    Hi Java4s,

    Really I am enjoying this explanation, it explains very nicely, never seen such kind of explanation any other site.

    Please keep posting such kind of explanation it is really easy to understand.

  23. Deepak Kumar says:

    I'm enjoying after reading this explanation.


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2024 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.