I have an interface and three classes which implements that interface and i should use Hibernate framework to save them to the database. The problem is that, it should create different tables depending on one of the three classes. For example,
interface Vehicle;
class Truck;
class Bus;
class Motorbike;
Vehicle vehicle = new Truck(); // In that case, Truck table should be generated
session.save(vehicle); // In that case, Truck table should be generated
Vehicle vehicle = new Bus();
session.save(vehicle); // In that case, Bus table should be generated
Vehicle vehicle = new Motorbike();
session.save(vehicle); // In that case, Motorbike table should be generated
How can i do this with annotations? Any help will be appreciated. Thank you.