Types of inheritence models in Hibernate
By: Emiley J.
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
Archived Comments
1. Good explanation
View Tutorial By: Siddesh at 2012-07-12 03:53:07
2. It will be better, if you expalin by examples coding...
View Tutorial By: Parwez at 2012-06-18 08:03:45
3. Simple, Sweet and StraightForward explanation. Thank You :)
View Tutorial By: Gayatri at 2011-12-02 09:01:50
4. It is easy to understand by beginners .......good one
View Tutorial By: Guru at 2011-10-04 12:32:49
5. Nice Explanation
View Tutorial By: sam at 2010-11-24 02:23:57
6. Very Nice and Concrete Explanation ..
View Tutorial By: Parvesh at 2009-09-18 11:11:00
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Primary keys assigned by triggers in Hibernate
Assigned identifiers in Hibernate
Identity columns and sequences in Hibernate
EntityNameResolvers in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
equals() and hashCode() in Hibernate
Fetching strategies in Hibernate
Creating Connection Pool for JDBC Connections in Hibernate
Hibernate JDBC and Connection Properties
Hibernate Transaction Properties