Refer to a row in a table using two columns of another table

public class Toys {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "unit_id")
    private Long toyid;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "boxId", referencedColumnName = "boxId")
    @JsonBackReference
    private ToyBox christmasBox;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "boxId", referencedColumnName = "boxId")
    @JsonBackReference
    private ToyBox newYearBox;
}

public class ToyBox extends BosEntityBase  implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "boxId")
    private Long boxId;

    @JsonManagedReference
    @OneToMany(mappedBy = "christmasBox", fetch = FetchType.EAGER)
    @Fetch(value = FetchMode.SUBSELECT)
    @DiffIgnore
    private List<Toys> christmasToys = new ArrayList<>();

    @JsonManagedReference
    @OneToMany(mappedBy = "newYearBox", fetch = FetchType.EAGER)
    @Fetch(value = FetchMode.SUBSELECT)
    @DiffIgnore
    private List<Toys> newYear = new ArrayList<>();
}```

I am trying to a relation as shown above. There would be multiple toys in the toybox - each toy is either a christmas toy or a new year toy. I would like to get the list of christmas toys given a box, or the list of new year toys given a box. Also, I would like to be able to get the specific box given the toy(christmas toy or a new year toy). So I have created the relation as shown. I get an error saying,

Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.sample.play.entities.Toy column: box_id (should be mapped with insert="false" update="false")

I dont understand why I get this error, can you please help me out with this? Am I doing something wrong?

You are mapping the foreign key column Toys.boxId for both, christmasBox and newYearBox which is not possible/sensible. What you probably want is to use a different column.

public class Toys {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "unit_id")
    private Long toyid;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "christmasBoxId", referencedColumnName = "boxId")
    @JsonBackReference
    private ToyBox christmasBox;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "newYearBoxId", referencedColumnName = "boxId")
    @JsonBackReference
    private ToyBox newYearBox;
}