ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Josh Joy" <joshjd...@gmail.com>
Subject Re: stored procedure specify parameter...
Date Wed, 14 May 2008 07:08:49 GMT
Thanks...exactly what I was looking for.

On Wed, May 14, 2008 at 12:12 AM, <Christopher.Mathrusse@sybase.com> wrote:

>
> Hi Josh,
>
> This looks surprisingly similar to Sybase ASE syntax. I can assure you
> that iBatis works quite well with this syntax as I use it quite regularly
> although I usually avoid the use of the parameterMap. I use the following:
>
>   <procedure id="listShipDestination" parameterClass="ShipDestination"
> resultMap="ShipDestinationResult">
>     { call ${listShipDestination_sp} (
>         @CustomerNumber =
> #customerNumber,jdbcType=VARCHAR,javaType=java.lang.String,mode=IN#
>       , @BillToLocation =
> #billToLocation,jdbcType=SMALLINT,javaType=java.lang.Integer,mode=IN#
>       , @SoldToLocation =
> #soldToLocation,jdbcType=SMALLINT,javaType=java.lang.Integer,mode=IN#
>
>       <isNotEmpty property="destLocation">
>         , @DestLocation =
> #destLocation,jdbcType=SMALLINT,javaType=java.lang.Integer,mode=IN#
>       </isNotEmpty>
>
>         etc...
>
>       )
>     }
>   </procedure>
>
> I have numerous stored procs that I do this with. iBatis does nothing
> special with your SQL, it simply passes it off to JDBC and executes it as
> you define it.
>
> I hope this helps you..
>
>
> Chris
>
>
>
>  *"Josh Joy" <joshjdevl@gmail.com>*
> Sent by: josh.joy.123@gmail.com
>
> 05/13/2008 08:03 PM
>  Please respond to
> user-java@ibatis.apache.org
>
>   To
> user-java@ibatis.apache.org  cc
>   Subject
> stored procedure specify parameter...
>
>
>
>
> Hi,
>
> I looked through the documentation, though I most likely missed it
> somewhere...
>
> If i have a stored procedure, in sql I would execute as follows...
>
> EXECUTE spFetchSomeData @parm1=1, @parm2=2, @parm3=3, @parm4=4
>
> So all 4 parameters are integers..
>
> This is how I write it in ibatis...
>    <parameterMap id="spFetchSomeData-parameterMap" class="com.myobject" >
>        <parameter property="parm1" jdbcType="INTEGER"
>            javaType="java.lang.Long" mode="IN"/>
>        <parameter property="parm2" jdbcType="NUMERIC"
>            javaType="java.lang.Long" mode="IN"/>
>        <parameter property="parm3" jdbcType="NUMERIC"
>            javaType="java.lang.Long" mode="IN"/>
>        <parameter property="parm4" jdbcType="NUMERIC"
>            javaType="java.lang.Long" mode="IN"/>
>    </parameterMap>
>
>    <procedure id="spFetchSomeData"
> parameterMap="spFetchSomeData-parameterMap" >
>        {call spFetchSomeData (?, ?, ?, ?)}
>    </procedure>
>
> So my class "com.myobject" has java properties parm1,parm2,parm3,parm4 to
> coincide with my stored procedure.
> If I understand this correctly, when spFetchSomeData is called, it is
> passed the paramters from spFetchSomeData-parameterMap in order...
>
> My only question is, can I specify not to rely on the order of the
> parameters. Similar to the sql execute above, is there a way to specify the
> stored procedure parameters and map those to my bean?
>
> I'm sure I just probably missed the syntax somewhere...
>
> Thanks
> Josh
>

Mime
View raw message