我如何在 JPA 中做到这一点?
数据库:
School
------
id int PK
name varchar
state int FK (State(id))
State
-----
id int PK
desc varchar
爪哇:
SchoolShow
----------
int id;
String name;
int iState;
String sState;
代码:
select sc.name, st.desc from school sc, state st where st.id=sc.state and sc.id=?
while(rs.hasNext()){
SchoolShow ss=new SchoolShow();
ss.setName(rs.getString("name"));
ss.setSState(rs.getString("desc"));
}
¿我可以有一个具有来自不同表的属性的@Entity 吗?
提前致谢!!