Friday, August 26, 2016

HIBERNATE: IMPLEMENTING INHERITANCES (Introduction & Single-Table Strategy)

So, this is the situation. We have a parent 'Vehicle' class. Then there are two child classes extending from the Vehicle class.



Programmatically expressed as,

PARENT CLASS


CHILD CLASS-1


CHILD CLASS-2


main() method


Resultant Schema








SINGLE-TABLE STRATEGY (more options)

Default inheritance strategy is SINGLE.TABLE

PARENT VEHICLE CLASS


CHILD CLASS-1
This time, the column value for this child class will be 'Bike' inside the table.

CHILD CLASS-2
The value inside the table would be now 'Car'.


main() method:



Resultant Schema









No comments:

Post a Comment