6- Mapping in Hibernate

Mapping meaning in hibernate-

Connection between java class to database tables

Types of mapping in hibernate-

1- Inheritance Mapping-

When java classes are having inheritance, their tables can be created using 3 ways-

1- Table per class hierarchy –
-Only one table is created for all the classes.
-One Discriminator field is used.
xml element <subclass> is used.
-Gives maximum performance

2–Table per sub-class hierarchy-
-One table for each class is created.
-Foreign key is maintained between the tables.
-xml element <joined- subclass> is used.

3-Table per concrete class hierarchy-
-One table for each concrete class (subclass) is created but not of super classes.
-Foreign key is not maintained.
-xml element<union-subclass> is used.


2- Collection Mapping-

When java class is having collection object, they can be stored according to their type of collection –

1-list mapping
2-set mapping
3-map mapping

3- Association mapping-

When java class is having reference of another java class, their tables can be created using 3 ways-

1-One to one
2-One to many or many to one
3-Many to many