I am using Table per concrete class strategy
Vehicle
TransportationVehicle extends Vehicle
PassengerVehicle extends Vehicle.
Now three tables are created
Vehicle
TransportationVehicle
PassengerVehicle
but when I query database using
from Vehicle v
Hibernate issues union query for all the three tables, why it does like this? I am just asking for Vehicle.
TransportationVehicle and PassengerVehicle are subclasses of Vehicle. Hibernate will return all instances of Vehicle(TransportationVehicle and PassengerVehicle are instances of Vehicle too). If you want to select only Vehicle you could create hierarchy:
AbstractVehicle should be annotated with @MappedSuperclass.