Inheritance hibernate

Using Inheritance with Hibernate JPA. Featured articles: Mapping Table per Concrete Class Using Table per subclass strategy Using table per class hierarchy

Mapping Table per Concrete Class

Hibernate Table per concrete class strategy You can use the Table per concrete class strategy in two ways: 1) Table per concrete class with implicit polymorphism The table contains all the properties of the concrete class and the properties that are inherited from its superclasses. All subclasses are mapped as separate entities. Example: package com.sample … Read more

Using Table per subclass strategy

Hibernate Table per subclass strategy When using this strategy, the superclass has a table and each subclass has a table that contains only un-inherited properties: the subclass tables have a primary key that is a foreign key of the superclass.Example: package com.sample public class Vehicle {     // Constructors and Getter/Setter methods,     long id; … Read more

Using table per class hierarchy

  Using table per class hierarchy When using this inheritance strategy, the class hierarchy is represented by multiple classes combined into one de-normalized DB table. A discriminator column identifies the type and the subclass. Example: package com.sample public class Vehicle {     long id;     int noOfTyres;     private String colour;    // Constructors and … Read more