MyBatis 在插入 Oralce 时报:ORA-01465: 无效的十六进制数字
解决方法:
# 插入或更新时
String -> BLOB字段:RAWTOHEX(#{字段名})
String -> DATE:to_date(#{字段名},'yyyy-mm-dd hh24:mi:ss')
# 查询时
BLOB -> String:UTL_RAW.CAST_TO_VARCHAR2(字段名)
DATE -> String:to_char(字段名,'yyyy-mm-dd hh24:mi:ss')
<resultMap id="ReportResultMap" type="com.vipsoft.Report">
<id column="PACS_NO" property="custodyNo" jdbcType="VARCHAR"/>
<result column="PATIENT_ID" property="patientId" jdbcType="VARCHAR"/>
<result column="INSPECT_CONTENT" property="conclusion" jdbcType="VARCHAR"/>
</resultMap>
<select id="getCustodyOrder" parameterType="com.vipsoft.Report" resultMap="CustodyResultMap">
SELECT PATIENT_ID,UTL_RAW.CAST_TO_VARCHAR2(t.INSPECT_CONTENT) as INSPECT_CONTENT
FROM Report t WHERE t.PACS_NO= #{reportNo}
</select>
<insert id="insert" parameterType="com.vipsoft.Report">
insert into Report
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="patientId != null" >PATIENT_ID,</if>
<if test="conclusion != null" >INSPECT_CONTENT,</if>
<if test="createTime != null" >CREATE_TIME,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="patientId != null" >#{patientId,jdbcType=VARCHAR},</if>
<if test="conclusion != null" >RAWTOHEX(#{conclusion,jdbcType=VARCHAR}),</if>
<!--Date 型的 createTime 不需要做 to_date 转换-->
<if test="createTime != null" >#{createTime,jdbcType=TIMESTAMP},</if>
</trim>
</insert>