The Entity Classes (Models):
○ Doctors
▶The individual Doctors
○ Hospital
 The hospital to which many doctors ▶
belong.
○ Specialty
▶Each Doctor has one specialty
○ Doctor Schedule
▶Each doctor has one Schedule
Patients
▶Multiple patients can have multiple
Doctors
● Relationships:
○ Doctors -> Hospital (Many → One)
○ Specialty -> Doctors  (One → Many)
○ Doctor -> Schedule Profile (One → One)
○ Patients > Doctors (Many → Many)
This is my code:
package model;

import com.sun.javafx.beans.IDProperty;
import jakarta.persistence.*;

import java.io.Serial;
import java.io.Serializable;
import java.util.Set;

@Entity
public class Doctors {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long int id;
    private String name;
    @ManyToOne
    @JoinColumn(name = "hospital_id")
    private Hospital hospital;
    @ManyToOne
    @JoinColumn(name = "specialty_id")
    private Specialty specialty;
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "schedule_profile_id", referencedColumnName = "id")
    private ScheduleProfile scheduleProfile;
    @ManyToMany(mappedBy = "doctors")
    private List<Patient> patients;
    public long int getId() {return id;}
    public void setId(long int id) {this.id = id;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
    public Hospital getHospital() {return hospital;}
    public void setHospital(Hospital hospital) {this.hospital = hospital;}
    public Specialty getSpecialty() {return specialty;}
    public void setSpecialty(Specialty specialty) {this.specialty = specialty;}
    public ScheduleProfile getScheduleProfile() {return scheduleProfile;}
    public void setScheduleProfile(ScheduleProfile scheduleProfile) {this.scheduleProfile = scheduleProfile;}
    public List<Patient> getPatients() {return patients;}
    public void setPatients(List<Patient> patients) {this.patients = patients;}
}@Entity
public class Hospital {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long int id;
    private String name;
    @OneToMany(mappedBy = "hospital")
    private List<Doctors> doctors;
    public long int getId() {return id;}
    public void setId(long int id) {this.id = id;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
    public List<Doctors> getDoctors() {return doctors;}
    public void setDoctors(List<Doctor> doctors) {this.doctors = doctors;}
}@Entity
public class Specialty {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long int id;
    private String name;
    @OneToMany(mappedBy = "specialty")
    private List<Doctors> doctors;
    public long int getId() {return id;}
    public void setId(long int id) {this.id = id;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
    public List<Doctors> getDoctors() {return doctors;}
    public void setDoctors(List<Doctors> doctors) {this.doctors = doctors;}
}@Entity
public class ScheduleProfile {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String details;
    @OneToOne(mappedBy = "scheduleProfile")
    private Doctors doctor;
    public Long getId() {return id;}
    public void setId(Long id) {this.id = id;}
    public String getDetails() {return details;}
    public void setDetails(String details) {this.details = details;}
    public Doctors getDoctors() {return doctor;}
    public void setDoctors(Doctors doctor) {this.doctor = doctor;}
}@Entity
public class Patient {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    @ManyToMany
    @JoinTable(name = "patient_doctor", joinColumns = @JoinColumn(name = "patient_id"),
            inverseJoinColumns = @JoinColumn(name = "doctor_id"))
    private List<Doctors> doctors;
    public Long getId() {return id;}
    public void setId(Long id) {this.id = id;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
    public List<Doctors> getDoctors() {return doctors;}
    public void setDoctors(List<Doctors> doctors) {this.doctors = doctors;}
}