ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject Re: AutoResultMap enhancement (map myField -> my_field)
Date Wed, 23 Jul 2008 14:36:01 GMT
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

The default name resolver would support underscores, uppercase, lowercase
and table prefixex etc.


On Wed, Jul 23, 2008 at 6:51 AM, Richard Rattigan <rattigan@broad.mit.edu>

> 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.
> It would be nice to have an option to support this convention globally
> (e.g. <settings useUnderscores="true" />. The option would assume that a
> property names MY_FIELD maps to a property called myField. For even more
> flexibility, you could allow custom column name mapper to be specified (a la
> hibernate) - using a similar approach to TypeHandlers.
> The benefit is that it could eliminate a lot of aliasing that is currently
> required in SqlMaps when using this convention.
> Also, would it be possible to allow a <resultMap/> to use the AutoResultMap
> behaviour for properties that aren't specified in the mapping. This
> behaviour could be specified as follows.  <resultMap ... auto="true"/> This
> would simplify result mapping where only a couple of properties deviate from
> the default.
> Cheers,
> Richard

View raw message