You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "stephen.friedrich" <st...@fortis-it.eu> on 2009/11/11 00:54:42 UTC

Re: AutoResultMap enhancement (map myField -> my_field)

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 the
> 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 <ra...@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 column
>> 'myField', and maps a column 'MY_FIELD' to a property 'my_field' (or some
>> 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-enhancement-%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


Re: AutoResultMap enhancement (map myField -> my_field)

Posted by Stephen Friedrich <st...@fortis-it.eu>.
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 = caseInsensitivePropertyMap.get(name.toUpperCase());
      if (propertyName == null) {
          propertyName = caseInsensitivePropertyMap.get(name.toUpperCase().replace("_", ""));
      }
      return propertyName;
  }

Seems to work for me, but of course I don't advocate this 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)

I decided not to go there.  It created new challenges.  That's not to say it can never be there... but it's not as easy as it looks.  The biggest problem is with 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 <st...@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.  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 the
> 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 <ra...@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 column
>> 'myField', and maps a column 'MY_FIELD' to a property 'my_field' (or some
>> 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-enhancement-%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<ma...@ibatis.apache.org>
For additional commands, e-mail: user-java-help@ibatis.apache.org<ma...@ibatis.apache.org>


Re: AutoResultMap enhancement (map myField -> my_field)

Posted by Clinton Begin <cl...@gmail.com>.
I decided not to go there.  It created new challenges.  That's not to say it
can never be there... but it's not as easy as it looks.  The biggest problem
is with 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.  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
> the
> > 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 <
> 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 column
> >> 'myField', and maps a column 'MY_FIELD' to a property 'my_field' (or
> some
> >> 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-enhancement-%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
>
>