-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @AssociationOverride for @JoinColumnsOrFormulas?
PostPosted: Tue Dec 14, 2010 7:47 pm 
Newbie

Joined: Tue Dec 14, 2010 7:24 pm
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.