Resolved Question
What are the types of inheritence models and describe how they work like vertical inheritence and horizontal
 
Details:
  asked by: hippo93  on: Jul 25, 2009  
 Best Answer ! ! !
nameit 's Answer  ( this answer is maked as best answer of this question at: Jul 29, 2009 )


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

 

1 comments  answered on: Jul 30, 2009 
Other Answer (2)

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

  geniuspear   answered on£ºJul 26, 2009  0 comments

Table per concrete class using implicit
polymorphism can also be added as inheritance mapping in hibernate
  gin   answered on£ºJul 28, 2009  0 comments

Hot Questions

Contact Us - IT-Interview