Compared to JDBC we have one main advantage in hibernate, which is hibernate inheritance.
Inheritance is one of the most visible facets of Object-relational mismatch. Object oriented systems can model both “is a†and “has a†relationship. Relational model supports only “has a†relationship between two entities. Hibernate can help you map such Objects with relational tables. But you need to choose certain mapping strategy based on your needs.
Note: We can also called this Hibernate Inheritance Mapping as Hibernate Hierarchy
Inheritance is one of the most visible facets of Object-relational mismatch. Object oriented systems can model both “is a†and “has a†relationship. Relational model supports only “has a†relationship between two entities. Hibernate can help you map such Objects with relational tables. But you need to choose certain mapping strategy based on your needs.
Inheritance Mapping Strategies in Hibernate
Hibernate supports 3 types of Inheritance Mappings:Note: We can also called this Hibernate Inheritance Mapping as Hibernate Hierarchy
Table Per Hierarchy
In table per hierarchy mapping, single table is required to map the whole hierarchy, an extra column (known as discriminator column) is added to identify the class. But nullable values are stored in the table .Table Per Concrete class
In case of table per concrete class, tables are created as per class. But duplicate column is added in subclass tables.Table Per Subclass
In this strategy, tables are created as per class but related by foreign key. So there are no duplicate columns.Source:http://www.tutorialsdesk.com/2015/01/inheritance-mapping-in-hibernate.html
Tidak ada komentar:
Posting Komentar