我正在使用数据库 H2(内存中)和 Hibernate 开发一个简单的 CRUD Spring boot REST 应用程序,汽车实体和制造商实体之间存在多对一关系。
@Entity
@Table(name = "car")
public class Car {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JoinColumn(name = "manufacturerId")
@ManyToOne()
private Manufacturer manufacturer;
///
}
@Entity
@Table(name = "manufacturer")
public class Manufacturer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy = "manufacturer")
private Set<Car> cars;
//
}
如何解决这个问题?
Cats萌萌
相关分类