-->
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.  [ 3 posts ] 
Author Message
 Post subject: Embedded AttributeOverrides ignored?
PostPosted: Tue May 06, 2008 8:13 pm 
Newbie

Joined: Wed Jan 31, 2007 10:53 am
Posts: 3
I am using the latest Hibernate GA releases as of today. I have a very simple class that is embeddable:

Code:
@Embeddable
public class Address implements Serializable {
   
    @Column(name = "addressStreet1", length = 40)
    private String street1;
   
    @Column(name = "addressStreet2", length = 40)
    private String street2;
   
    @Column(name = "addressApartmentNumber", length = 10)
    private String apartmentNumber;
   
    @Column(name = "addressCity", length = 40)
    private String city;
   
    @Column(name = "addressState", length = 3)
    private String state;
   
    @Column(name = "addressPostalCode", length = 11)
    private String postalCode;

    ....
}


When I embed this class and use AttributeOverrides to rename the columns, the renaming doesn't occur. No matter what it still adds the columns with the names "addressStreet1", "addressStreet2", etc.

Here is the code for how I am embedding it:

Code:
    @Embedded
    @AttributeOverrides({
        @AttributeOverride(name = "addressStreet1", column = @Column(name = "mailingAddressStreet1")),
        @AttributeOverride(name = "addressStreet2", column = @Column(name = "mailingAddressStreet2")),
        @AttributeOverride(name = "addressApartmentNumber", column = @Column(name = "mailingAddressApartmentNumber")),
        @AttributeOverride(name = "addressCity", column = @Column(name = "mailingAddressCity")),
        @AttributeOverride(name = "addressState", column = @Column(name = "mailingAddressState")),
        @AttributeOverride(name = "addressPostalCode", column = @Column(name = "mailingAddressPostalCode"))
    })
    private Address mailingAddress;


What am I doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 5:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I think in the name attribute of the @AttributeOverride annotation you have to specify the actual property. What i mean is street1 instead of addressStreet1, ...

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 7:36 am 
Newbie

Joined: Wed Jan 31, 2007 10:53 am
Posts: 3
That did it! I've been looking at it and trying everything under the sun but never even noticed that I named the property a different name than the column in my Address class. In all of my other embeddable classes I used the same name for the property and column so I didn't run into this.

Thanks for the quick reply.


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

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.