package net.employee_managment.springboot.model;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
@Entity
@Table(name = "employee")
@Inheritance(strategy = InheritanceType.JOINED)
public class Employee {
@Id
@Column(name="employee_id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int employee_id;
@NotNull
@ManyToOne
@JoinColumn(name="general_details_id", nullable = false)
private GeneralDetails generalDetails;
@NotNull
@ManyToOne
@JoinColumn(name="spouse_id", nullable = false)
private Spouse spouse;
@NotNull
@ManyToOne
@JoinColumn(name="address_Id")
private Address[] addresses;
@NotNull
@ManyToOne
@JoinColumn(name="child_ID")
private Child[] children;
.... Constractors, Gettes, Setters}
Until now I could use the ID of the objects within the Employee object to link the objects and everything worked fine. But now I have an array of objects and I have a hard time figuring out how to link the Address array to the Employee object