我有一个关于 Spring JPA 的 @GenerateValue 注释的问题。
这是我的课:
@Entity
@NoArgsConstructor
@Getter
@Setter
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private Double price;
private Integer quantity;
@ManyToOne
private Category category;
@ManyToOne
private Manufacturer manufacturer;
public Product(String name, Double price, Integer quantity, Category category, Manufacturer manufacturer) {
this.name = name;
this.price = price;
this.quantity = quantity;
this.category = category;
this.manufacturer = manufacturer;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试添加新产品时,出现此错误:
2021-12-06 18:03:02.013 ERROR 3720 --- [nio-9090-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: null value …Run Code Online (Sandbox Code Playgroud)