-->
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.  [ 6 posts ] 
Author Message
 Post subject: Naming of Getters and Setters
PostPosted: Mon Jun 04, 2007 4:47 am 
Newbie

Joined: Fri Nov 18, 2005 3:55 pm
Posts: 4
Hello guys!

I found one issue that I cant really follow... If you have a Property named "uProfile" for example (each string with upper-case at the second pos.) than the getters and setters have to be getuProfile & setuProfile instead of getUProfile & setUProfile. Is this right and intended??


Top
 Profile  
 
 Post subject: Re : Naming of getters and setters
PostPosted: Mon Jun 04, 2007 8:51 am 
Newbie

Joined: Mon Dec 11, 2006 12:54 am
Posts: 14
If you are generating the getters and setters for a property like "uProfile" using an IDE, then its going to be getUProfile & setUProfile. This is as per convention and should be used like this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 9:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use "UProfile" if your property name is actually "UProfile" and not "uProfile" ;) (this is a consequence of a specifal handling in java bean spec/impl about saying that if the second letter is uppercase then it assumes the first one is too...for e.g. resolving getURL() correctly)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 9:27 am 
Newbie

Joined: Fri Nov 18, 2005 3:55 pm
Posts: 4
yes, exactly thats the issue! The generated files are OK by convention but NOT OK for hibernate! Hibernate throws an Exception if the methods are not named getuProfile & setuProfile. => Hibernate doesnt accept the correct method names...

So is this a bug or intended? If its intended, why does hibernate break with the naming convention here?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 9:30 am 
Newbie

Joined: Fri Nov 18, 2005 3:55 pm
Posts: 4
max wrote:
use "UProfile" if your property name is actually "UProfile" and not "uProfile" ;) (this is a consequence of a specifal handling in java bean spec/impl about saying that if the second letter is uppercase then it assumes the first one is too...for e.g. resolving getURL() correctly)

thx for the hint ;)

I cannot easily change the database. I'm reverse engineering an existing db... :( but i found a workaround for this problem in our generator.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 9:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh no it is not ok by convention ;)

anyhow i don't know what generator you are using but hibernate tools handles this correctly when reverse engineering - if it doesn't please file a bug report for it.

_________________
Max
Don't forget to rate


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