首页 > 其他分享 >MyBatis ORA-01465: 无效的十六进制数字

MyBatis ORA-01465: 无效的十六进制数字

时间:2022-12-06 14:11:49浏览次数:61  
标签:十六进制 String 01465 CONTENT jdbcType MyBatis 字段名

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>

标签:十六进制,String,01465,CONTENT,jdbcType,MyBatis,字段名
From: https://www.cnblogs.com/vipsoft/p/16955057.html

相关文章