what is @JoinColumn and how it is used in Hibernate

后端 未结 5 574
死守一世寂寞
死守一世寂寞 2020-11-28 06:08

I have been reading a lot about @JoinColumn but I still don\'t get the idea behind it.

Patient Table

CREATE TABLE patient (
patient_id BIGINT NOT NUL         


        
5条回答
  •  情话喂你
    2020-11-28 06:36

    The table in which join column will be found depends upon context.

    • If the join is for a OneToOne or ManyToOne mapping using a foreign key mapping strategy, the foreign key column is in the table of the source entity or embeddable.

    • If the join is for a unidirectional OneToMany mapping using a foreign key mapping strategy, the foreign key is in the table of the target entity.

    • If the join is for a ManyToMany mapping or for a OneToOne or bidirectional ManyToOne/OneToMany mapping using a join table, the foreign key is in a join table.

    • If the join is for an element collection, the foreign key is in a collection table.

提交回复
热议问题