Does something similar to @AssociationOverride exist for overriding relationships defined with the @JoinColumnsOrFormulas annotation?
I'm storing mailing and residential addresses in my legacy database. The lookup table containing the valid state and country names has a composite key, which is a combination of the place id (stored in the address) and a language code (not stored in the address, but obtained from a locale variable in the environment to represent which language translation of the state or country name should be used).
Within my Address object, I've mapped the relationships like this (hard coding a 0 in the formula to represent the English language for now--I'll eventually write a subquery to populate this):
Code:
@ManyToOne
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(column=@JoinColumn(name="HHHOMESTATE", referencedColumnName="GPCODE")),
@JoinColumnOrFormula(formula=@JoinFormula(value="0", referencedColumnName="GPLANGUAGE"))
})
private GeoPoliticalPlace state;
@ManyToOne
@JoinColumnsOrFormulas({
@JoinColumnOrFormula(column=@JoinColumn(name="HHHOMECOUNTRY", referencedColumnName="GPCODE")),
@JoinColumnOrFormula(formula=@JoinFormula(value="0", referencedColumnName="GPLANGUAGE"))
})
private GeoPoliticalPlace country;
This works fine for my residential addresses. But, when I try to override this for use with the mailing addresses, by doing something like:
Code:
@Embedded
@AssociationOverrides( {
@AssociationOverride(name="state", joinColumns=@JoinColumn(name="HHMAILSTATE")),
@AssociationOverride(name="country", joinColumns=@JoinColumn(name="HHMAILCOUNTRY"))
})
I receive a configuration error:
Code:
Caused by: org.hibernate.MappingException: Unable to find column with logical name in table XXX_GEOPOLITICAL_PLACE
Can you use @AssociationOverrides for relationships defined with @JoinColumnsOrFormulas? If not, is there some other way to override relationships defined with @JoinColumnsOrFormulas?
Thanks!