[英]Iam unable to define how to map two foreign key columns of two different table in Entity class of other table
Iam unable to define how to map two foreign key columns of two different table in Entity class of other table. 我无法定义如何在另一个表的Entity类中映射两个不同表的两个外键列。
let me give example of table structure 让我举一个表结构的例子
table1
column11 (primary key)
column12
column13
table2
column21 (primary key)
column11 (foreign key - table1 primary key column)
column22
column23
table3
column31 (primary key)
column11 (foreign key - table1 primary key column)
column21 (foreign key - table2 primary key column)
column32
column33
Now i want to my entity class table3 to hold these two foreign keys. 现在我想让我的实体类table3拥有这两个外键。 Iam very new to JPA(hibernate) .
我对JPA(休眠)非常陌生。 How can i map those foreign key columns as entity class attributes?
如何将那些外键列映射为实体类属性? Please suggest me.
请给我建议。
@Entity
public class Table3 {
// ...
@ManyToOne
@JoinColumn(name = "column11")
private Table1 table1;
@ManyToOne
@JoinColumn(name = "column21")
private Table2 table2;
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.