oracle char 类型自动填充

今天 在将mysql数据迁移到oracle数据中后,使用springboot、mybaits、oracle 查询带有条件的数据。

具体mybatis如下

   <select id="selectCompanyTypicalCaseList" parameterType="com.system.domain.CompanyTypicalCase" resultMap="CompanyTypicalCaseResult">
        <include refid="selectCompanyTypicalCaseVo"/>
        <where>  
            <if test="caseId != null "> and case_id = #{caseId}</if>
             <if test="caseTitle != null  and caseTitle != '' "> and case_title like '%${caseTitle}%'</if>
             <if test="caseType != null  and caseType != '' "> and case_type = #{caseType}</if>
             <if test="picName != null  and picName != '' "> and pic_name = #{picName}</if>
             <if test="picAddress != null  and picAddress != '' "> and pic_address = #{picAddress}</if>
             <if test="linkAddress != null  and linkAddress != '' "> and link_address = #{linkAddress}</if>
             <if test="caseContent != null  and caseContent != '' "> and case_content = #{caseContent}</if>
             <if test="status != null  and status != '' "> and status = #{status}</if>
             <if test="pageView != null "> and page_view = #{pageView}</if>
             <if test="createBy != null  and createBy != '' "> and create_by = #{createBy}</if>
             <if test="createTime != null "> and create_time = #{createTime}</if>
             <if test="updateBy != null  and updateBy != '' "> and update_by = #{updateBy}</if>
             <if test="updateTime != null "> and update_time = #{updateTime}</if>
             <if test="remark != null  and remark != '' "> and remark = #{remark}</if>
         </where>
    </select>
    

但是,不知道为什么 当status 为 Y 时,程序总查不出数据,但是 debug查出的sql 复制出来总能够查出数据。

一开始考虑mybaits xml写法的问题,但是几经修改,没有试验成功。

后来灵机一动,感觉是orcale数据问题,几经查找 发现 由于在oracle中,char类型字段,如果内容长度不够,会自动以空格方式补足长度。如字段 name char(5),若值为sgl,那么oracle会自动用空格补足长度,最终值为sgl  。

原来,由于在orcle中status属性设置的长度过长导致。将其属性长度置为1即可;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章