0
嗨JPA inharit領域所有沒有繼承id字段
我們一般放4場在每一個命名爲CREATED_BY,LAST_UPDATED_BY,CREATION_DATE,時間:LAST_UPDATED_DATELAST_UPDATED_TIME表,所以我想,爲什麼不把這個編在一個班裏BaseDo和比繼承這樣的類如EmployeeDo。問題是如果我用@Entity註釋這個BaseDo,我必須放一個@Id字段,我不想要。有沒有辦法做到這一點?
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class BaseDo implements Serializable {
private static final long serialVersionUID = 6685603264139140757L;
@Column(name="CREATED_BY" , nullable =false)
private String createdBy;
@Column(name="LAST_UPDATED_BY", nullable =false)
private String lastUpdatedBy;
@Column(name="CREATION_DATE", nullable =false)
private Date creationDate;
@Column(name="LAST_UPDATED_DATE", nullable =false)
private Date lastUpdationDate;
}
@Entity
@Table(name="EMPLOYEE")
public class EmployeeDo extends BaseDo implements Serializable {
private static final long serialVersionUID = 4465521188079217243L;
@Id
@Column(name="EMPLOYEE_ID")
private String employeeId ;
}
非常感謝