mybatis callable statement out parameter integer
<p>I am under making one stored procedure in Oralce 11g and I should call this from mybatis mapper. The procedure takes three parameters and the third is for OUT paramter. I coded like below, but the OUT parameter was returned as 0 in Java.</p>

<p>mybatis mapper:</p>

<pre><code>&lt;mapper namespace="..."&gt;
&lt;select id="setUserRole" statementType="CALLABLE" parameterType="hashmap"&gt;
    { call set_user_role(#{email}, #{roleName}, #{cntPrivs, mode=OUT, jdbcType=NUMERIC})}
&lt;/select&gt;
&lt;/mapper&gt;
</code></pre>

<p>mybatis Mapper interface:</p>

<pre><code>public interface UserMapper {
    void setUserRole(Map&lt;String, Object&gt; map);
}
</code></pre>

<p>service layer utilizing mybatis mapper:</p>

<pre><code>@Override
public boolean setBasicRole(String email) {
    Map&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
    Integer privilegesCount = 0;
    map.put("roleName", UserServiceImpl.ROLE_BASIC);
    map.put("email", (Object)email);
    map.put("cntPrivs", privilegesCount);
    userMapper.setUserRole(map);

    System.out.println("cntPrivs : " + privilegesCount); // printed zero

    return (privilegesCount &gt; 0)? true : false;
}
</code></pre>

<p>in Oracle code:</p>

<pre><code>set serveroutput on
declare
    cnt_privs number := 0;
begin
    set_user_role('&lt;set my email&gt;', 'NORMAL', cnt_privs);
    dbms_output.put_line(cnt_privs); // printed more than 0
end;
/
</code></pre>

<p>I checked OUT paramter of the procedure returns more than 0 in database area.
In Java, "privilegeCount" variable should be more than 0 after calling userMapper.setUserRole() method. but returns 0.</p>

<p>When I initialized "privilegeCount" as 10, it stayed 10 after calling userMapper.setUserRole().</p>

<p>It seems like "privilegeCount" does not get synchronized with mybatis.</p>

<p>How do I deal with this?</p>

<p>Thanks in advance.</p>