Types of inheritence models in Hibernate

By: Emiley J. Emailed: 1673 times Printed: 2153 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

This tutorial discusses what are the types of inheritance models in Hibernate and describes how they work like vertical inheritance and horizontal.

There are three types of inheritance mapping in hibernate

1. Table per concrete class with unions

2. Table per class hierarchy

3. Table per subclass

Example:

Let us take the simple example of 3 java classes.

Class Manager and Worker are inherited from Employee Abstract class.

1. Table per concrete class with unions

In this case there will be 2 tables

Tables: Manager, Worker [all common attributes will be duplicated]

2. Table per class hierarchy

Single Table can be mapped to a class hierarchy

There will be only one table in database called 'Employee' that will represent all the attributes required for all 3 classes.

But it needs some discriminating column to differentiate between Manager and worker;

3. Table per subclass

In this case there will be 3 tables represent Employee, Manager and Worker

 


Hibernate Home | All Hibernate Tutorials | Latest Hibernate Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(4)


1. View Comment

Very Nice and Concrete Explanation ..

View Tutorial          By: Parvesh at 2009-09-18 11:11:00
2. View Comment

Nice Explanation

View Tutorial          By: sam at 2010-11-24 02:23:57
3. View Comment

It will be better, if you expalin by examples coding...

View Tutorial          By: Parwez at 2012-06-18 08:03:45
4. View Comment

Good explanation

View Tutorial          By: Siddesh at 2012-07-12 03:53:07

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Emiley J.
Error generating R.java from manifest
ERROR 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client
IIS and Tomcat - how to configure to work together
PHP Warning: Unknown(): Unable to load dynamic library '/usr/local/php4/lib/php/extensions/no-debug ......
Adding your own Application icon for your J2ME application (jar file)
Creating Menus in Code using VB.net
Traversing all files in a directory using Ruby
Using Proxy to connect to URLs in Ruby
POST a form in Ruby
Reading URL content using Ruby (HTTP)
dRuby client/server mode sample program
Benchmark module in Ruby
encoding and decoding in Ruby using Base64 Module
Module Abbrev in Ruby
Standard Library Packages in Ruby

More Tutorials in Hibernate
Fetching strategies in Hibernate
equals() and hashCode() in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
EntityNameResolvers in Hibernate
Hi/lo algorithm in Hibernate
Identity columns and sequences in Hibernate
Assigned identifiers in Hibernate
Primary keys assigned by triggers in Hibernate
Formula in Hibernate
Step by Step Hibernate - Your First Hibernate Application
A sample Hibernate Web Application using Servlets
Some Basic APIs in Hibernate
Contextual sessions in Hibernate
Programmatic configuration in Hibernate
SessionFactory in Hibernate

More Latest News
Most Viewed Articles (in Hibernate )
Download Hibernate latest version
Step by Step Hibernate - Your First Hibernate Application
Hibernate Vs. JDBC ( A comparison)
Types of inheritence models in Hibernate
Some Basic APIs in Hibernate
Hibernate JDBC and Connection Properties
equals() and hashCode() in Hibernate
EntityNameResolvers in Hibernate
Hi/lo algorithm in Hibernate
Formula in Hibernate
Delta Electronics Chairman Bruce Cheng Endows NCKU Build Y.S. Sun Green Building Research Center
What is component mapping in hibernate?
Paging Through the Result Set in Hibernate
Tutorial Using the Java Persistence API (JPA) in Hibernate
A sample Hibernate Web Application using Servlets
Most Emailed Articles (in Hibernate)
Hibernate Vs. JDBC ( A comparison)
Programmatic configuration in Hibernate
Step by Step Hibernate - Your First Hibernate Application
equals() and hashCode() in Hibernate
Delta Electronics Chairman Bruce Cheng Endows NCKU Build Y.S. Sun Green Building Research Center
A sample Hibernate Web Application using Servlets
Some Basic APIs in Hibernate
Contextual sessions in Hibernate
Creating Connection Pool for JDBC Connections in Hibernate
Hibernate Cache Properties
Hibernate Transaction Properties
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
EntityNameResolvers in Hibernate
Hi/lo algorithm in Hibernate
Identity columns and sequences in Hibernate