JPA 中的 referencedColumnName 用于什么? [英] What is referencedColumnName used for in JPA?

查看:27
本文介绍了JPA 中的 referencedColumnName 用于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 JPA 中有一个名为 referencedColumnName 的属性,可以在 @JoinColumn, @PrimaryKeyJoinColumn 上设置这个设置背后的想法是什么,有人可以举一个很好的例子可以用在哪里?

In JPA there is an attribute called referencedColumnName that can be set on @JoinColumn, @PrimaryKeyJoinColumn what is the idea behind this setting, can someone give a good example of where this can be used?

推荐答案

指定另一列作为其他表的默认 id 列,例如考虑以下

It is there to specify another column as the default id column of the other table, e.g. consider the following

TableA
  id int identity
  tableb_key varchar


TableB
  id int identity
  key varchar unique

// in class for TableA
@JoinColumn(name="tableb_key", referencedColumnName="key")

这篇关于JPA 中的 referencedColumnName 用于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆