11

特定のパラメーターがクエリパラメーターマップに含まれているかどうかをテストする方法は mybatis にありますか?

私はこのようなものを探しています:

<select id="selectByKey" resultMap="MyObjectMap" parameterType="map">
    select obj.* from obj where obj.id=#{id:VARCHAR}
<!-- I'm looking for a method like that below -->
    <if test="parameterExists('forUpdate')">
        <if test="forUpdate == 1">
            for update
        </if>
    </if>
</select>
4

2 に答える 2

13

このテストを使用できます:

<if test="_parameter.containsKey('forUpdate')">your code....</if> 
于 2013-11-19T15:03:02.150 に答える
3
<if test="forUpdate != null">

動作する可能性があります。

Java HashMap.get(key) では、キーがマップに存在しない場合に null を返します。

于 2013-08-09T11:07:04.137 に答える