what is @JoinColumn and how it is used in Hibernate

后端 未结 5 562
死守一世寂寞
死守一世寂寞 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条回答
  •  -上瘾入骨i
    2020-11-28 06:35

    Why is that the patient_id (generated column which is a FK) in the Vehicle Table doesn't have any value when I run my code?

    All @JoinColumn does is to specify a column for joining an entity association or element collection. Since you have made @JoinColumn associated with Patient class object, that's why foreign key is created on Patient table.

    For more please refer https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/JoinColumn.html

提交回复
热议问题