JPA: difference between @JoinColumn and @PrimaryKeyJoinColumn?

前端 未结 3 1701
南笙
南笙 2020-12-02 06:42

What\'s the exact difference between @JoinColumn and @PrimaryKeyJoinColumn?

You use @JoinColumn for columns that are part of a

3条回答
  •  盖世英雄少女心
    2020-12-02 07:01

    I know this is an old post, but a good time to use PrimaryKeyColumn would be if you wanted a unidirectional relationship or had multiple tables all sharing the same id.

    In general this is a bad idea and it would be better to use foreign key relationships with JoinColumn.

    Having said that, if you are working on an older database that used a system like this then that would be a good time to use it.

提交回复
热议问题