请帮助我理解为什么基于hibernate字段的注释基于primarykey字段工作?
模型类1 也会从getter和 Model Class 2 中获取docnum
字段值。尽管两个地方仅基于getter注释docnum
。它基于id
字段工作,该字段在 Model Class 2 和 Model Class 1 字段中注释基于getter。
模型类1:
@Entity(name="RDT_ORDER")
public class Order {
private int id;
private String docnum;
@Id
@Column(name="ORDID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="ORD_DOCNUM")
public String getDocnum() {
return docnum+" getter";
}
public void setDocnum(String docnum) {
this.docnum = docnum;
}
}
模型类2:
@Entity(name="RDT_ORDER")
public class Order {
private int id;
private String docnum;
@Id
@Column(name="ORDID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="ORD_DOCNUM")
public String getDocnum() {
return docnum+" getter";
}
public void setDocnum(String docnum) {
this.docnum = docnum;
}
}
输出:表格(RDT_ORDER)值
ID DOCNUM
5 docnum5
6 docnum6 getter