I have a table that has two foreign keys to two different tables with both foreign keys sharing one column:
CREATE TABLE ZipAreas
(
countr
This is still not solved in Hibernate 5.
However, if I use @JoinColumnsOrFormulas I get ClassCastException.
Appending insertable = false, updatable = false on all join columns solved my problem:
Example:
@ManyToOne
@JoinColumns(value = {
@JoinColumn(name = "country_code", referencedColumnName = "country_code", insertable = false, updatable = false),
@JoinColumn(name = "state_code", referencedColumnName = "state_code", insertable = false, updatable = false),
@JoinColumn(name = "city_name", referencedColumnName = "name", insertable = false, updatable = false)})
private City city = null;