我有一个域实体,如下所示:
class Exch{
private int id;
private String val1;
private String val2;
@Column(name = "val1")
public String getVal1(){
return val1;
}
@Column(name = "val2")
public String getVal2(){
return val2;
}
@Column(name = "id")
public int id(){
return id;
}
}
和表:
交换
Exch_ID| VAL1 | VAL2
100000 | AAA | BBB
200000 | CCC | DDD
现在我有另一个表格,如下所示:
exch_extra
Exch_ID| VAL3 | VAL4
100000 | ZZZ| 年年
200000 | XXX| 乌乌乌
无论如何我可以将 exch_extra 表中的 val3 映射到 Entity Exch 而不创建额外的 Exch_extra 实体?
所以我可以拥有:
class Exch{
private int id;
private String val1;
private String val2;
private String val3;
@Column(name = "val1")
public String getVal1(){
return val1;
}
@Column(name = "val2")
public String getVal2(){
return val2;
}
@ do something here so i can have val3 from exch_extra table
public String val3(){
return val3
}
@Column(name = "id")
public int id(){
return id;
}
}