Hibernate find with composite key. Invalid column name Exception

青春壹個敷衍的年華 提交于 2019-12-06 08:35:17

I was getting the same problem. I solved it using the @PrimaryKeyJoinColumns, try this (from another example):

@ManyToOne
@PrimaryKeyJoinColumns(value = {
    @PrimaryKeyJoinColumn(name = "country_code", referencedColumnName = "country_code"),
    @PrimaryKeyJoinColumn(name = "zip_code", referencedColumnName = "code")
})
private Zip zip;

@ManyToOne
@PrimaryKeyJoinColumns(value = {
    @PrimaryKeyJoinColumn(name = "country_code", referencedColumnName = "country_code"),
    @PrimaryKeyJoinColumn(name = "state_code", referencedColumnName = "state_code"),
    @PrimaryKeyJoinColumn(name = "city_name", referencedColumnName = "name")
})
private City city;

from Hibernate throws AnnotationException on column used by multiple overlapping foreign keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!