MyBatis ORA-01465: 无效的十六进制数字
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>
本文来自博客园,作者:VipSoft 转载请注明原文链接:https://www.cnblogs.com/vipsoft/p/16955057.html
标签:
SpringBoot
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库