1
私は2つのクラスに両方のDistrictクラスがあり、既存のデータベースには異なる名前のfkがあります。 @AssociationOverrideを作成しましたが、エラーの無効な列名であるdistrict_arrondisidを取得しました。@AssociationOverrideと@joinColumnは機能しません
クラス地区
@Entity
@Table(name = "arrond")
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name = "arrondisid"))
})
public class District extends BasicString implements Comparable<District> {
}
クラスBasicIDDistrict
@IdClass(BasicIDDistrictPK.class)
@MappedSuperclass
@XmlRootElement
public abstract class BasicIDDistrict {
@Id
private int id;
@Id
@ManyToOne(fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JsonIgnore
private District district;
//getters and setters
}
クラス1
@Entity
@Table(name = "tableA")
@AssociationOverrides({
@AssociationOverride(name = "district", joinColumns =
@JoinColumn(name = "arrondisid"))
})
@AttributeOverrides({
@AttributeOverride(name = "id", column =
@Column(name = "idA", insertable = false, updatable = false))
})
public class ClassA extends BasicIDDistrict {...}
クラス1
@Entity
@Table(name = "tableB")
@AssociationOverrides({
@AssociationOverride(name = "district", joinColumns = @JoinColumn(name = "id_arrond"))
})
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name = "idB", insertable = false, updatable = false))
})
public class ClassB extends BasicIDDistrict {..}
[Hibernateコレクション結合列をオーバーライドする方法は?](http://stackoverflow.com/questions/13026969/how-to-override-hibernate-collection-join-column) – Draken