What is referencedColumnName used for in JPA?

前端 未结 5 623
不知归路
不知归路 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:33

    Quoting API on referencedColumnName:

    The name of the column referenced by this foreign key column.

    Default (only applies if single join column is being used): The same name as the primary key column of the referenced table.

    Q/A

    Where this would be used?

    When there is a composite PK in referenced table, then you need to specify column name you are referencing.

提交回复
热议问题