ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Rouillier <guyr-...@burntmail.com>
Subject Re: Mapper parsing problem
Date Thu, 04 Feb 2010 00:38:18 GMT
On 2/3/2010 3:54 PM, Daryl Stultz wrote:
> On Wed, Feb 3, 2010 at 3:32 PM, Simone Tripodi <simone.tripodi@gmail.com
> <mailto:simone.tripodi@gmail.com>> wrote:
>     Forgot to say that, of course, there are cons, like in the sample below:
> I misread your first post and was thinking you wanted something like this:
> <insert id=”insertUser” parameterType=”User” >
> <parameterDef name="department" mode="OUT" jdbcType="CURSOR"
> javaType="Department" resultMap="departmentResultMap"/>
>      insert into users (id, username, password, department)
>      values (#{id}, #{username}, #{password}, #{department})
> </insert>
> I'm totally mixing your examples up, but the point is "parameterDef"
> just defines the nature of the parameter, #{department} just applies the
> value in the right spot. Maybe that's worse, I don't know!

I like this idea, though to keep things consistent, I would just use 
"parameter" instead of "parameterDef".  Note you can use formatting to 
make statements a little more readable with today's iBATIS config.  Here 
is a partial example from a production XML file:

    DEPT_ID = #{deptId, javaType=String, jdbcType=VARCHAR},
    STATE_ID = #{stateId, javaType=String, jdbcType=VARCHAR},
    TIME_ZONE_ID = #{timeZoneId, javaType=String, jdbcType=VARCHAR},

Same approach works for inserts.  Putting each parameter on a new line 
makes reading a little easier, especially if you are including 
additional attributes.

Guy Rouillier

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

View raw message