映射两列没有主键

时间:2013-06-06 22:39:23

标签: java hibernate jpa annotations

我有2张桌子 - 人和请求。

Person (id is PK):  
id  name  req_id
Requests(id is PK):  
id rid

在java中:

@Entity
public class Person{
@Id
Int id;
String name;
String req_id;
...}    

@Entity
public class Requests{
@Id
Int id;
String rid;
...}` 

我想做的是用req_id映射(OneToOne)摆脱。
不幸的是,我无法使用@SecondaryTable,因为表没有按主键映射。 我很感激任何帮助...

1 个答案:

答案 0 :(得分:0)

我无法理解为什么你需要这个,但这对你有什么帮助How to do one to one hibernate mapping, using a non-primary key as references

相关问题