jpa Table per concrete class inheritance strategy

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

  • Vehicle, TransportationVehicle and PassengerVehicle are abstract classes and they will not have separate table in database.
  • Truck, Car and Bike are concrete classes so they will be mapped to corresponding tables. These tables should include all the fields for classes annotated with @MappedSuperClass because they don’t have corresponding tables in database.
  • So, Truck table will have columns to store fields inherited from TransportationVehicle and Vehicle.
  • Similarly, Car and Bike will have columns to store fields inherited from PassengerVehicle and Vehicle.

Full example can be found here



Got any jpa Question?