本文介绍了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 用于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!