I have these classes:
@Entity
@Table(name = "garage")
class Garage {
@Id
private String id;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "garage_id", referencedColumnName = "id")
private List<Vehicle> vehiclesList;
}
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class Vehicle {
}
@Entity
@Table(name = "cars")
class Car extends Vehicle {
}
@Entity
@Table(name = "trucks")
class Truck extends Vehicle {
}
I am using cascade all.
When I am trying to persist them. I get: SqlError, No table 'vehicle'
I want to clarify that I am always persisting a garage with one type of vehicles
So when I hit garageRepository.save(garage)
I expect the child table (either car or truck) to be populated. and the garage_id will be the new garage.
How can this be done?
Regards, Ido