Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 82280 invoked from network); 11 Nov 2009 07:56:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Nov 2009 07:56:52 -0000 Received: (qmail 67121 invoked by uid 500); 11 Nov 2009 07:56:51 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 67076 invoked by uid 500); 11 Nov 2009 07:56:50 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 67068 invoked by uid 99); 11 Nov 2009 07:56:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Nov 2009 07:56:50 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [91.199.21.18] (HELO mxa.xchangemail.de) (91.199.21.18) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Nov 2009 07:56:47 +0000 Received: from VAVP1E1A.vavp0m.de (10.40.201.2) by mxa.xchangemail.de (10.41.8.201) with Microsoft SMTP Server (TLS) id 8.1.358.0; Wed, 11 Nov 2009 08:57:59 +0100 Received: from VAVP0E7A.vavp0m.de ([10.46.1.70]) by VAVP1E1A.vavp0m.de ([10.41.0.27]) with mapi; Wed, 11 Nov 2009 08:56:24 +0100 From: Stephen Friedrich To: "user-java@ibatis.apache.org" Date: Wed, 11 Nov 2009 08:56:19 +0100 Subject: Re: AutoResultMap enhancement (map myField -> my_field) Thread-Topic: AutoResultMap enhancement (map myField -> my_field) Thread-Index: Acpih+0kLVCOCUGmSv+O0jaCDGSsMwAHA/Gg Message-ID: <60454457CBDFBD4DB30D4F4A5B193DED0168610514@VAVP0E7A.vavp0m.de> References: <48872959.6020503@broad.mit.edu> <16178eb10807230736h2b2a5d60rd22a10dbcb24c43c@mail.gmail.com> <26293607.post@talk.nabble.com> <16178eb10911102030t38ef6d9fv15749b916fbf816a@mail.gmail.com> In-Reply-To: <16178eb10911102030t38ef6d9fv15749b916fbf816a@mail.gmail.com> Accept-Language: en-US, de-DE Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, de-DE Content-Type: multipart/alternative; boundary="_000_60454457CBDFBD4DB30D4F4A5B193DED0168610514VAVP0E7Avavp0_" MIME-Version: 1.0 --_000_60454457CBDFBD4DB30D4F4A5B193DED0168610514VAVP0E7Avavp0_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hm, I don't understand the internals well enough to really understand that. Sure name resolution is table specific?! To work around the issue for my specific use case I patched this method in = Reflector: public String findPropertyName(String name) { String propertyName =3D caseInsensitivePropertyMap.get(name.toUpperCa= se()); if (propertyName =3D=3D null) { propertyName =3D caseInsensitivePropertyMap.get(name.toUpperCase(= ).replace("_", "")); } return propertyName; } Seems to work for me, but of course I don't advocate this as a general solu= tion. Stephen Von: Clinton Begin [mailto:clinton.begin@gmail.com] Gesendet: Mittwoch, 11. November 2009 05:30 An: user-java@ibatis.apache.org Betreff: Re: AutoResultMap enhancement (map myField -> my_field) I decided not to go there. It created new challenges. That's not to say i= t can never be there... but it's not as easy as it looks. The biggest prob= lem is with columns like "id", where multiple tables use the same column na= me. But that's just one challenge... Clinton On Tue, Nov 10, 2009 at 4:54 PM, stephen.friedrich > wrote: Any news on this? I haven't found any pluggable name resolver in 3.0 (Beta 5)?! This would make my SQL much shorter and more readable (omitting all those aliases). Clinton Begin wrote: > > This is definitely something I've wanted to do for a while. Version 3 > will > have a property/column name resolver that can be overridden. It's not > terribly hard to put in 2.x, but it might be a while before anyone has th= e > time.. > > The default name resolver would support underscores, uppercase, lowercase > and table prefixex etc. > > Clinton > > On Wed, Jul 23, 2008 at 6:51 AM, Richard Rattigan > > wrote: > >> Hi, >> >> I'm a new user of IBatis, and would like to suggest an enhancement to th= e >> behaviour of AutoResultMap. >> >> Currently, AutoResultMap maps a property column 'MYFIELD' to a column >> 'myField', and maps a column 'MY_FIELD' to a property 'my_field' (or som= e >> capitalized variant). This default behaviour is a little odd, since >> databases usually use underscores to separate words in column names, >> whereas >> JavaBean properties use camel case. >> >> ... >> >> Cheers, >> Richard >> >> > > -- View this message in context: http://old.nabble.com/AutoResultMap-enhanceme= nt-%28map-myField--%3E-my_field%29-tp18610069p26293607.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org For additional commands, e-mail: user-java-help@ibatis.apache.org --_000_60454457CBDFBD4DB30D4F4A5B193DED0168610514VAVP0E7Avavp0_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hm, I don’t understand the internals well enough to re= ally understand that.

Sure name resolution is table specific?!

 

To work around the issue for my specific use case I patched = this method in Reflector:

  public String findPropertyName(String name) {

      String propertyName =3D caseInsensitivePropertyMap.get(name.toUpperCase());

      if (propertyName =3D=3D null)= {

          prope= rtyName =3D caseInsensitivePropertyMap.get(name.toUpperCase().replace("_", ""));

      }

      return propertyName;

  }

 

Seems to work for me, but of course I don’t advocate t= his as a general solution.

 

Stephen

 

Von: Clinton Begin [mailto:clinton.begin@gmail.com]
Gesendet: Mittwoch, 11. November 2009 05:30
An: user-java@ibatis.apache.org
Betreff: Re: AutoResultMap enhancement (map myField -> my_field)<= o:p>

 

I decided not to go there.  It created new challenges.  That's not to say it can neve= r be there... but it's not as easy as it looks.  The biggest problem is wit= h columns like "id", where multiple tables use the same column name. 

But that's just one challenge...

Clinton

On Tue, Nov 10, 2009 at 4:54 PM, stephen.friedrich <= ;stephen.friedrich@fortis-it.= eu> wrote:


Any news on this?
I haven't found any pluggable name resolver in 3.0 (Beta 5)?!
This would make my SQL much shorter and more readable (omitting all those aliases).



Clinton Begin wrote:
>
> This is definitely something I've wanted to do for a while.  Vers= ion 3
> will
> have a property/column name resolver that can be overridden.  It'= s not
> terribly hard to put in 2.x, but it might be a while before anyone has= the
> time..
>
> The default name resolver would support underscores, uppercase, lowerc= ase
> and table prefixex etc.
>
> Clinton
>
> On Wed, Jul 23, 2008 at 6:51 AM, Richard Rattigan <rattigan@broad.mit.edu>
> wrote:
>
>> Hi,
>>
>> I'm a new user of IBatis, and would like to suggest an enhancement= to the
>> behaviour of AutoResultMap.
>>
>> Currently, AutoResultMap maps a property column 'MYFIELD' to a col= umn
>> 'myField', and maps a column 'MY_FIELD' to a property 'my_field' (= or some
>> capitalized variant). This default behaviour is a little odd, sinc= e
>> databases usually use underscores to separate words in column name= s,
>> whereas
>> JavaBean properties use camel case.
>>

>> ...
>>
>> Cheers,
>> Richard
>>
>>
>
>

--
View this message in context: http://old.nabble.com/AutoResultMap-enhancement-%28map-my= Field--%3E-my_field%29-tp18610069p26293607.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apac= he.org

 

--_000_60454457CBDFBD4DB30D4F4A5B193DED0168610514VAVP0E7Avavp0_--