I am using spring MyBatis 1.2.0 in a project, where I have a query that gets data from a BLOB field in an Oracle 11g database. I want to retrieve the field as a byte array (byte[]), my Code is:
<select id="getResponse" resultType="_byte[]" parameterType="string">
select blob_Data from Table where id = #{value,jdbcType=VARCHAR} AND ROWNUM = 1
</select>
This is giving following error:
java.lang.ClassCastException: [B incompatible with [Ljava.lang.Object;
at org.apache.ibatis.binding.MapperMethod.convertToArray(MapperMethod.java:136)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
Apart from this, I have also tried using resultMap:
<resultMap id="responseMap" type="ResponseMessageModel">
<result property="blobData" column="blob_Data"/>
</resultMap>
<select id="getResponse" resultMap="responseMap" parameterType="string">
select blob_Data from table where id = #{value,jdbcType=VARCHAR} AND ROWNUM = 1
</select>
and also specifying the javaType:
<resultMap id="responseMap" type="ResponseMessageModel">
<result property="blobData" javaType="_byte[]" column="blob_Data"/>
</resultMap>
<select id="getResponse" resultMap="responseMap" parameterType="string">
select blob_Data from table where id = #{value,jdbcType=VARCHAR} AND ROWNUM = 1
</select>
but with no luck, all give the same ClassCastException
Could someone please tell me what I am doing wrong?