Inheritance
One of the biggest challenges in mapping objects to relations is inheritance. Relational databases do not support this concept. So, ORM solutions need to get creative when dealing with this issue. JPA specifies several strategies, all of which are implemented by Hibernate and these will be discussed here.
Single table strategy
The default strategy to support class hierarchy, in the case of inheritance, is single table strategy. If you don't specify any strategy, Hibernate will look for (or create) a single table with the name of the parent class. This table has columns for every attribute in all the classes in the inheritance model. Let's consider the following superclass and its subclasses:
@Entity public class Person { @Id @GeneratedValue private long id; private String firstname; private String lastname; } @Entity public class Driver extends Person { @Column(name="LIC_NUM") private String licenseNumber; } @Entity public class Passenger...