title: Fetching data from cursor in mybatis
body: <p>I am quite new to mybatis and have been trying to call a function returning a cursor from mybatis.
  Here are some code snippets:</p>
  
  <p>PL/SQL Function :</p>
  
  <pre><code>FUNCTION student_fetch(
    p_id      VARCHAR2,
    p_usr_id       VARCHAR2,
    p_program_code VARCHAR2)
   RETURN t_students_cursor
  IS
   cur t_students_cursor;
   --v_cnt INT;
  BEGIN
   --check_student_info_permission(p_osis_id, p_usr_id, p_program_code, v_cnt);
   --IF v_cnt  &gt; 0 THEN
   OPEN cur FOR SELECT srec.First_Name, srec.Last_Name, srec.Middle_Initial,
  </code></pre>
  
  <p>XML entry :</p>
  
  <pre><code>   &lt;resultMap id="accountDetailResult" type="student"&gt;
       &lt;result property="firstName" column="First_Name" /&gt;
      &lt;result property="lastName" column="Last_Name" /&gt;
  
      &lt;/resultMap&gt;
  
      &lt;select id="getAccountDetail" parameterType="map" statementType="CALLABLE"&gt;
     { #{t_students_cursor,jdbcType=CURSOR,mode=OUT,resultMap=accountDetailResult,javaType=java.sql.ResultSet} = 
      call students.student_fetch(#{osisId,jdbcType=VARCHAR,mode=IN}, #{userId,jdbcType=VARCHAR,mode=IN},#{programCode,jdbcType=VARCHAR,mode=IN})}
  
   &lt;/select&gt; 
  </code></pre>
  
  <p>POJO Class :</p>
  
  <pre><code>public class Student {
  
  
  
      private String firstName;
  
      private String lastName;
  
  
      private String emailAddress;
  
      private String daytimeTelephoneNumber;
  
      private String id;
  
      private String userId;
  
      private String programCode;
  </code></pre>
  
  <p>Mapper Interface :</p>
  
  <pre><code>void getAccountDetail(@Param("map") Map&lt;String, Object&gt; parameter);
  </code></pre>
  
  <p>Tester Class :</p>
  
  <pre><code> Map&lt;String, Object&gt; param = new HashMap&lt;String, Object&gt;();
      param.put("p_d", "214996787");
      param.put("p_usr_id", "admin");
      param.put("p_program_code", null);
      productServiceObj.getAccountDetail(param);
      Student st = (Student)param.get("t_students_cursor");
  </code></pre>
  
  <p>Exception :</p>
  
  <pre><code>org.apache.ibatis.exceptions.PersistenceException: 
  ### Error querying database.  Cause: java.lang.NullPointerException
  ### The error may involve com.example.services.ProductServices.getAccountDetail-Inline
  ### The error occurred while setting parameters
  ### Cause: java.lang.NullPointerException
      at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
      at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:61)
      at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:53)
      at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38)
      at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:66)
      at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:35)
      at $Proxy1.getAccountDetail(Unknown Source)
      at com.example.runner.AppTester.main(AppTester.java:79)
  Caused by: java.lang.NullPointerException
      at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:870)
      at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:960)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
      at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
      at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4223)
  </code></pre>