简体   繁体   English

mybatis-resultmap-用用户定义的值替换空值

[英]mybatis - resultmap - nullvalues to be replaced with userdefined values

Mybatis resultMap Assign customized value to nullvalue I want to assign my customized value for nullValue returning column from my query. Mybatis resultMap将自定义值分配给nullvalue我想为我的查询返回的nullValue列分配自定义值。 Below is my code snippet Advanced thanks for your help 以下是我的代码段高级感谢您的帮助

  <resultMap id="abcd" class="abcdVO">
    <result property="ABC" column="Col1" nullValue="No"/>
    <result property="XYZ" column="Col2" nullValue=" "/>
  </resultMap>

  <select id="abcd" parameterType ="String" resultMap="abcdMap">
     Select Col1, Col2 from xyz
  </select>

Use COALESCE : 使用COALESCE

<select id="abcd" parameterType ="String" resultMap="abcdMap">
   Select COALESCE(Col1, 'No') as Col1, COALESCE(Col2, ' ') as Col2 from xyz
</select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM