I\'m having two entities Car and CarDescription where CarDescription is depending on another foreign key from the table Language
In CarDescription you need to add the languageId property:
@Column(name = "language_id", insertable = false, updatable = false)
private Long languageId;
@NotNull
@OneToOne
@JoinColumn(name = "language_id")
private Language language;
public void setLanguage(Language language) {
this.languageId = language.getId();
this.language = language;
}
Then you can use it in the Car entity like this:
@OneToMany(mappedBy="car")
@MapKey(name = "languageId")
private Map carDescription = new HashMap<>(0);