This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Description
在mybatis中,choose...when...otherwise标签意味着从choose块中的when按顺序进行判断,只要有一个when结果为true,则匹配该when块中的语句,如果所有的when都不匹配,则匹配otherwise块中的语句。
因此,在解析choose...when...otherwise标签是否考虑不要将所有的when都解析出来放在块中,而是选第一个when块解析?
例如:
<select id="testChoose">
SELECT
name,
category,
price
FROM
fruits
<where>
<choose>
<when test="name != null">
AND name = #{name}
</when>
<when test="category == 'banana'">
AND category = #{category}
<if test="price != null and price !=''">
AND price = ${price}
</if>
</when>
<otherwise>
AND category = 'apple'
</otherwise>
</choose>
</where>
</select>
就解析为:
SELECT name, category,price FROM fruits where name = ?