如何在MyBatis上使用<if>语句使用update语句

时间:2018-01-09 07:07:04

标签: mysql if-statement mybatis ibatis

我想知道如何使用if语句如下

 <name>hive.metastore.schema.verification</name>
    <!-- <value>true</value> -->
    <value>false</value>
    <description>
      Enforce metastore schema version consistency.
      True: Verify that version information stored in is compatible with one from Hive jars.  Also disable automatic
            schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
            proper metastore schema migration. (Default)
      False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
    </description>
  </property>
  <property>

当A!= null和A.length()&gt;时,此语句有效。 0

但是如果A == null,则更新整行设置1,因为没有where条件。

如果条件正确,有没有办法更新,否则跳过或忽略?

感谢

2 个答案:

答案 0 :(得分:0)

<update id="update"
    parameterType="com.MyClass">
    UPDATE
        Board SET Status = 1
    <where>
        <choose>
            <when test="A != null and A.length() > 0">
                 AND A = ${A}
            </when>
            <otherwise>
                 AND 0 = 1
            </otherwise>
        </choose>
    </where>
</update>

条件0 = 1,其中失败并且没有更新

答案 1 :(得分:0)

np.ndarray

尝试CDATA很好