What is referencedColumnName used for in JPA?

前端 未结 5 620
不知归路
不知归路 2020-11-29 19:42

In JPA there is an attribute called referencedColumnName that can be set on @JoinColumn, @PrimaryKeyJoinColumn what is the idea behind this setting

5条回答
  •  悲&欢浪女
    2020-11-29 20:25

    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")
    

提交回复
热议问题