当我们使用 hibernate 创建主键时,我们使用 @Id 作为注释,但是应该使用什么注释来定义外键

When we create a primary key using hibernate we use @Id as annotation but what annotation should be used to define a foreign key

当我们使用 hibernate 创建主键时,我们使用 @Id 作为注释,但是应该使用什么注释来定义外键

最常见的是 @JoinColumn is use for mapping FK. If you have a link table, you need to use @JoinTable