I have the following iBatis mapping for an Oracle Stored Procedure that returns a true/false value.
<resultMap id="isAuthorizedResult" class="java.lang.Boolean">
<result property="isAuthorized" column="isAuthorized"/>
</resultMap>
<parameterMap id="isAuthorizedCall" class="map">
<parameter property="prgType" jdbcType="String" javaType="java.lang.String" mode="IN"/>
<parameter property="parCode" jdbcType="String" javaType="java.lang.String" mode="IN"/>
<parameter property="userId" jdbcType="String" javaType="java.lang.String" mode="IN"/>
<parameter property="Result0" jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="isAuthorizedResult"/>
</parameterMap>
<procedure id="isAuthorized" parameterMap="isAuthorizedCall">{call chk_user_ocpncy (?,?,?,?) }</procedure>
I call the mapping from my Java code like this:
getSqlMapClientTemplate().queryForObject("reexamination.isAuthorized", paramMap);
However, I get the following error…
Fail to convert to internal representation; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
What am I doing wrong? can we not store a boolean value directly into the cursor?
Returning a Boolean type is not supported by Oracle JDBC. Or more specifically, it can’t be used in any result set in Oracle (there is a Boolean that can be used in PL/SQL, but you can’t return it in a ref cursor or declare a column of being type ‘Boolean’.
It sounds like you are saying that your ref cursor contains boolean? If yes, you will need to return ‘Y’ or ‘N’ or something similar. Please consider posting the source/signature of the stored procedure – that will help with the answer.
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#34_05
Tom Kyte’s traditionally cheeky response:
You Asked