Call store procedure with only one OUT parameter ( Long type )

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Call store procedure with only one OUT parameter ( Long type )

Jose María Zaragoza
Hello:

I'm using Mybatis 3.2.3 for calling a store procedure in SQL Server 2008
This store procedure has got only one OUT parameter :

CREATE PROCEDURE dbo.GET_SEQUENCE(@sequence BIGINT OUTPUT)

And it works fine if I executed by Toad SQL client


My XML mapper is

<select id="querySequence" parameterType="java.lang.Long"
statementType="CALLABLE">
{CALL dbo.GET_SEQUENCE({sequence,javaType=java.lang.Long,jdbcType=BIGINT,mode=OUT})}
 </select>

And my java code is

Long sequence = 0l;
session.getMapper(CustomMapper.class).querySequence(sequence);

where CustomMapper interface is

public interface CustomMapper
{
public void querySequence(@Param("sequence")Long sequence);
}

But 'sequence' parameter is not updated and it always is 0

what is wrong ? Do I need to use other type of parameter ?

Thanks and regards

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call store procedure with only one OUT parameter ( Long type )

Jeff Butler
Use a HashMap for the parameter.  Then MyBatis will write the value into the map with key of "sequence".

Jeff Butler


On Thu, May 11, 2017 at 7:24 AM Jose María Zaragoza <[hidden email]> wrote:
Hello:

I'm using Mybatis 3.2.3 for calling a store procedure in SQL Server 2008
This store procedure has got only one OUT parameter :

CREATE PROCEDURE dbo.GET_SEQUENCE(@sequence BIGINT OUTPUT)

And it works fine if I executed by Toad SQL client


My XML mapper is

<select id="querySequence" parameterType="java.lang.Long"
statementType="CALLABLE">
{CALL dbo.GET_SEQUENCE({sequence,javaType=java.lang.Long,jdbcType=BIGINT,mode=OUT})}
 </select>

And my java code is

Long sequence = 0l;
session.getMapper(CustomMapper.class).querySequence(sequence);

where CustomMapper interface is

public interface CustomMapper
{
public void querySequence(@Param("sequence")Long sequence);
}

But 'sequence' parameter is not updated and it always is 0

what is wrong ? Do I need to use other type of parameter ?

Thanks and regards

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call store procedure with only one OUT parameter ( Long type )

Jose María Zaragoza
2017-05-11 18:21 GMT+02:00 Jeff Butler <[hidden email]>:
> Use a HashMap for the parameter.  Then MyBatis will write the value into the
> map with key of "sequence".


Thanks.
Finally, I used a bean called Sequence with a field of type long. And it works

Regards

>
> Jeff Butler
>
>
> On Thu, May 11, 2017 at 7:24 AM Jose María Zaragoza <[hidden email]>
> wrote:
>>
>> Hello:
>>
>> I'm using Mybatis 3.2.3 for calling a store procedure in SQL Server 2008
>> This store procedure has got only one OUT parameter :
>>
>> CREATE PROCEDURE dbo.GET_SEQUENCE(@sequence BIGINT OUTPUT)
>>
>> And it works fine if I executed by Toad SQL client
>>
>>
>> My XML mapper is
>>
>> <select id="querySequence" parameterType="java.lang.Long"
>> statementType="CALLABLE">
>> {CALL
>> dbo.GET_SEQUENCE({sequence,javaType=java.lang.Long,jdbcType=BIGINT,mode=OUT})}
>>  </select>
>>
>> And my java code is
>>
>> Long sequence = 0l;
>> session.getMapper(CustomMapper.class).querySequence(sequence);
>>
>> where CustomMapper interface is
>>
>> public interface CustomMapper
>> {
>> public void querySequence(@Param("sequence")Long sequence);
>> }
>>
>> But 'sequence' parameter is not updated and it always is 0
>>
>> what is wrong ? Do I need to use other type of parameter ?
>>
>> Thanks and regards
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "mybatis-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...