Oracle BLOB问题

1、遇到问题:

定义的entity类型中content字段的类型为byte[],

mybatis:

  <resultMap id="aa" type="xx.xx"><result property="content" column="CONTENT" jdbcType="BINARY"/></resultMap>

  <sql id="xx" > CONTENT</sql>

  <select id = "xx" resultMap="aa">select <include refid="xx"> from xx <where><if test="bb != null">and CONTENT=#{bb.content}</if></where></select>

html:<input type="text" name="content"/>

当查询时,报错 ORA-00932:数据类型不一致:应为-,但却获得BLOB

原因:这个是因为在页面中含有该字段,向后台传值过程中,将content的内容赋值为空字符串不是null,所以在想mybatis传值时,造成if语句><if test="bb != null">的判断为true对CONTENT字段进行匹配了,而oracle数据库中不能对二进制BLOB进行条件查询匹配,所以需要在查询时,将:<input type="text" name="content"/>标签删除或注释掉

posted @ 2020-04-14 11:58  ASKANDANSWERS  阅读(179)  评论(0编辑  收藏  举报