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
Vehicle Class ---- Entity
@JoinColumn(name="patient_id")
---- annotation
private Patient patient ----field
Above code will generate a column patient_id
(a foreign key) in Vehicle class which will point to Patient Class primary key.
MappedBy
- This attribute tells us that this relation will be managed by Vehicle class. Example. If we insert a vehicle, then two SQL will be injected if cascadetype is all/save. 1st SQL will inject details in Patient table and 2nd SQL will inject vehicle details in vehicle table with patient_id column of Vehicle column pointing to Patient tuple inserted.