-->
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: ImprovedNamingStrategy cannot handle one-letter words
PostPosted: Wed Jan 31, 2007 1:32 pm 
Newbie

Joined: Wed Jan 31, 2007 12:32 pm
Posts: 2
Hibernate version:3.2.0

Hi. If you have a property named "scoreA" (camel-case), I think it should be transformed to "score_a", but ImprovedNamingStrategy outputs "scorea".

I've been playing with the ImprovedNamingStrategy a bit, and you can twist this (bug?) a bit more: I'd say that "scoreAB" should be "score_a_b", but instead you get "scoreab"

I've browsed the source code, and it looks like it detects a "word-change" by checking the case of the previous and next letters of the current one. This assumes words have more than one letter, and that need not be the case (like in "scoreA").

My suggestion would be to change the logic so a word-change is marked by a capital letter, regardless of its neighbours; the first letter could be a exception, as some people do not make the first letter lower-case. The change is really simple, I could submit it if requested (I've done it anyway for our project).

Thanks,

Carlos


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as long as it does not convert scoreURL into score_U_R_L

..but not sure if fixing this now oold strategy will be a good thing since it might break existing apps.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 5:22 am 
Newbie

Joined: Wed Jan 31, 2007 12:32 pm
Posts: 2
Mmm... yes, my suggestion does "score_U_R_L" and it would break many
apps. I guess the problem is that some coding standards mandate that
acronyms are treated like words, other don't. The one we're using
makes you write scoreUrl, not scoreURL. Nevertheless, I think in this
respect it's quite common to be inconsistent. In fact, even the JDK is
not consistent (you have MimePart and XMLFilterImpl). Out of
curiosity, I've made a quick browse of Hibernate's API, and the same
thing happens: there is HqlSqlBaseWalker but also ANSICaseFragment.

I take back my suggestion, then. On the other hand, regardless of
whether you use MIME or Mime, I'd say the problem with one letter
words is still the same, and that "scoreA" should be "score_a", don't
you think? But I'd understand that you prefered to stick to "scorea"
on behalf of backwards compatibility.

Thanks anyway,

Carlos


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 5:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i agree scoreA should become scora_a; but that does not prevent scoreURL to become score_url - you just need an additional check.

_________________
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.  [ 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.