你好,我希望你能帮助我,我有一个在冬眠插入问题。首先我有个人课
@Entity
@Table(name = "persons")
@Inheritance(strategy = InheritanceType.JOINED)
public class Person implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id_card", columnDefinition = "VARCHAR(13)")
private String idCard;
@Column(name = "name", columnDefinition = "VARCHAR(50) NOT NULL")
private String name;
@Column(name = "last_name", columnDefinition = "VARCHAR(50) NOT NULL")
private String lastName;
}
我有两个班外加一个提供者。
@Entity
@Table(name = "providers")
public class Provider extends Person implements Serializable {
private static final long serialVersionUID = 1L;
public Provider() {
// TODO Auto-generated constructor stub
}
}
顾客
@Entity
@Table(name = "customers")
public class Customer extends Person implements Serializable {
private static final long serialVersionUID = 1L;
public Customer() {
// TODO Auto-generated constructor stub
}
}
结果是,我插入了一个提供者,没有问题,就像插入一个客户时没有问题一样,结果是,当我已经插入一个人作为客户时,我不能再插入他们作为供应商,我得到了密钥。
事实上,一个人可以同时成为客户、供应商或员工。
er图
暂无答案!
目前还没有任何答案,快来回答吧!