-->
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.  [ 4 posts ] 
Author Message
 Post subject: @AttributeOverride ignored.
PostPosted: Mon Jun 02, 2008 5:01 am 
Newbie

Joined: Mon Jun 02, 2008 4:38 am
Posts: 3
Hibernate version:3.2.4.sp1 as well as 3.2.6GA

Name and version of the database you are using:PostgreSQL 8.3

Hi, I have a very simple @Embeddable class called Email with one persistent attribute:

...
@Column(name = "email_address")
public String getEmailaddress() { return this.emailAddress; }
...

I want to override the column mapping in my "User" class:

...
@Embedded
@AttributeOverrides( { @AttributeOverride(name = "emailAddress", column = @Column(name = "email_primary"))} )
public Email getEmailPrimary() { return this.emailPrimary; }
...

However, Hibernate still tries to map emailPrimary to email_address.


Top
 Profile  
 
 Post subject: Re: @AttributeOverride ignored.
PostPosted: Mon Jun 02, 2008 8:28 am 
Hibernate Team
Hibernate Team

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

Could it be a upper vs lower case problem? In your example you pace the @Column annotation on the getter method. This means Hibernate will use property access (via getter instead of the field name) to determine the name. Your getter is called getEmailaddress whereas in @AttributeOverride your re using emailAddress. Try changing the getter to getEmailAddress().

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 8:58 am 
Newbie

Joined: Mon Jun 02, 2008 4:38 am
Posts: 3
Thank you for your quick response. Everywhere the correct case is used. I tried placing the annotations on the field as well as your suggestion to change the name of the getter. Unfortunately, to no avail.

Cheers, Martin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 11:13 pm 
Newbie

Joined: Mon Jun 02, 2008 4:38 am
Posts: 3
Sorry, It was an upper vs lower case problem after all. I looked for that bug in the wrong places.

public String getEmailaddress() { return this.emailAddress; }

should have been:

public String getEmailAddress() { return this.emailAddress; }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.