I am facing a problem in mybatis 3. I have a stored procedure that returns two result sets(resultset of object1, result set of object2).
I have created a resultMap for each result set
result map for object1(Create a class pojo Object1)
result map for object2(Create a class pojo Object2)
which give as something like this:
<resultMap id="object1" type="Object1" />
<resultMap id="object2" type="Object2" />
and for the call of the stored proc I have this:
<select id="pscall" parameterType="Integer"
resultMap="object1,object2" statementType="CALLABLE">
{ CALL PS(
#{id, mode=IN},
) }
</select>
Now when executing all this, I got effectively two lists with the number wanted of object1 and object2, but these two lists are filled with null objects, like the first list I got 3 elements and they are all null and the second 20 elements all null.
I know it's something wrong I made with the mapping, but at this point, I cannot see where the problem is.
You're asking us to deduce quite a lot, but I think it is clear that the basic mechanism of multiple result set handling is working correctly (you are getting the correct number of objects). What's not working is mapping rows to objects. That can only be happening if Object1 and Object2 do not have any attributes that match the columns coming back from the SP.
For example, if the first result set contains "ID, DESCRIPTION", then Object1 must have "id" and "description" properties (it is case insensitive).
If you don't know what will be coming back from the SP, then change the type
of each <resultMap>
to map
. Then MyBatis will build lists of maps and you can look in the map to see the values that came back from the SP and their column names.