1

i have a question about mybatis annotations and Oracle stored procedure

i have this in my mapper.xml:

<mapper namespace="xyzname">
...
    <select id="getDocument" parameterType="map" statementType="CALLABLE"><![CDATA[
{ #{OUT,javaType=jdl,jdbcType=CURSOR,mode=OUT} = call PKG.get_organisation_document ( 
#{ORGA_ID,javaType=java.lang.Long,jdbcType=NUMERIC,mode=IN}, 
#{PERSON_ID,javaType=java.lang.Long,jdbcType=NUMERIC,mode=IN}, 
#{GROUP_IDS,javaType=java.util.List,mode=IN,typeHandler=de.xyz.handlers.ArrayOfNumberTypeHandler}, 
#{TEMPLATE_IDS,javaType=java.util.List,mode=IN,typeHandler=de.xyz.handlers.ArrayOfNumberTypeHandler}, 
#{VALIDFROM,javaType=java.util.Date,jdbcType=TIMESTAMP,mode=IN}, 
#{VALIDUNTIL,javaType=java.util.Date,jdbcType=TIMESTAMP,mode=IN} ) }
]]></select>
...
</mapper>

and it works fine

and now i want to write this with mybatis annotations

@Mapper
public interface PackageMapper {

    @Select(value = " {#{OUT,javaType=java.sql.ResultSet,jdbcType=CURSOR,resultMap=documentData,mode=OUT} = call PKG.GET_ORGANISATION_DOCUMENT ("
            + "#{ORGA_ID,javaType=java.lang.Long,jdbcType=NUMERIC,mode=IN},"
            + "#{PERSON_ID,javaType=java.lang.Long,jdbcType=NUMERIC,mode=IN},"
            + "#{GROUP_IDS,typeHandler=de.xyz.handlers.ArrayOfNumberTypeHandler,javaType=java.util.List,jdbcType=ARRAY,mode=IN},"
            + "#{TEMPLATE_IDS,typeHandler=de.xyz.handlers.ArrayOfNumberTypeHandler,javaType=java.util.List,jdbcType=ARRAY,mode=IN},"
            + "#{VALIDFROM,javaType=java.util.Date,jdbcType=DATE,mode=IN},"
            + "#{VALIDUNTIL,javaType=java.util.Date,jdbcType=DATE,mode=IN})  }")
    @Options(statementType = StatementType.CALLABLE)
    public List<DocumentData> getDocument(Map<String, Object> params);

}

But i only get null as result.
My question is: how can i put an array of ids to a stored procedure with annotations? Can i still use Typehandlers?

tine
  • 11
  • 3
  • It should work the same if you use the same statement (the statement in annotation is different than the XML version). Note that the OUT parameter is not returned as the method result, it is put into the map you passed to the method. This should also be the same when you use the XML version. – ave Sep 18 '21 at 22:51
  • it was my fault, it works with adding the OUT parameter. i edit my question to correct annotations – tine Sep 20 '21 at 08:27
  • The statements still look different. Anyway, if you could share a small project demonstrating the difference between XML and annotation versions on GitHub, I would take a look. [Here](https://github.com/harawata/mybatis-issues) are some project templates. – ave Sep 20 '21 at 10:15

0 Answers0