6
我有一個域實體映射值如下:休眠:從另一個表列
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 | YYY
200000 | XXX | UUU
有無論如何我可以將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;
}
}
謝謝!一旦我添加SecondaryTable到實體,我可以映射該表的值。 – user1409920