hibernate使用@manyToOne注解关联非主键列

@ManyToOne(targetEntity = Citydictionaries.class )
@JoinColumn(name="city", referencedColumnName="CITY_CODE")
public Citydictionaries getCityDictionaries() {
return cityDictionaries;
}

public void setCityDictionaries(Citydictionaries cityDictionaries) {
this.cityDictionaries = cityDictionaries;
}
”city“是当前实体的列名称,“CITY_CODE”是关联表的引用列,不是主键列

你可能感兴趣的:(hibernate使用@manyToOne注解关联非主键列)