【发布时间】:2019-05-01 17:09:16
【问题描述】:
我想在产品类和笔记本电脑之间建立联系 产品类别
@Entity
@Table(name = "products")
@Inheritance(strategy = InheritanceType.JOINED)
public class Product {
@Id
@Column(unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(nullable = false, unique = true)
private String name;
@Column(nullable = false)
private BigDecimal cost;
@Column(nullable = false)
private int count;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "productStatus", nullable = false)
private ProductStatus productStatus;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "productManufacture", nullable = false)
private ProductManufacture productManufacture;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "productCategory", nullable = false)
private ProductCategory productCategory;
和 笔记本电脑类
@Entity
@Table(name = "laptops")
public class Laptop extends Product {
@Id
@Column(unique = true, nullable = false)
private int id;
@Column(nullable = false)
private String processor;
private int videoMemory;
@Column(nullable = false)
private int ram;
但是我的变种不起作用...(我怎样才能正确 我怎样才能在数据库中插入一些数据?(请举例)
【问题讨论】:
标签: java mysql spring hibernate hql