mybatisoracle-type

Mybatis : Oracle Nested Collection


How to use mybatis mappers (without type handlers) for fetching DB nested collections from a stored procedure. eg: the stored procedure returns a DB table object of the following type :

TYPE class_list IS TABLE OF class ;

where

TYPE class AS OBJECT (students student_list, class_teacher teacher);
TYPE student_list IS TABLE OF student;
TYPE student AS OBJECT (name VARCHAR2, age NUMBER, marks NUMBER);
TYPE teacher AS OBJECT (name VARCHAR2, qualification VARCHAR2, phone_number NUMBER);

Solution

  • @blackwizard, you are correct. For custom DB types, a custom type handler is a must. Here is the syntax (jdbcTypeName) to tell mybatis that it is dealing with a custom object:

    {call YOUR_PACKAGE.YOUR_PROCEDURE(
        #{your_input_parameter, jdbcType=VARCHAR mode=IN javaType=java.lang.String mode=IN },
        #{your_output_parameter, jdbcType=ARRAY mode=OUT jdbcTypeName=class_list typeHandler=custom_typeHandler})}
    

    Note: This is not supported in the deprecated parameterMap.