jdk7 无问题
<select id="find" resultMap="result" parameterType="map">
select * from user where 1=1
<if test="_CONDITION != null and _CONDITION != ''">
${_CONDITION}
</if>
</select>
jdk 11 报错invalid comparison: java.lang.StringBuffer and java.lang.String
<select id="find" resultMap="result" parameterType="map">
select * from user where 1=1
<if test="_CONDITION != null and _CONDITION != ''">
${_CONDITION}
</if>
</select>
正确写法:
<select id="find" resultMap="result" parameterType="map">
select * from user where 1=1
<if test="_CONDITION != null">
${_CONDITION}
</if>
</select>

本文探讨了在使用MyBatis进行数据库条件查询时遇到的JDK版本问题,具体表现为在JDK7下正常运行的代码,在升级到JDK11后出现类型比较错误。文中详细分析了问题原因,并提供了修改后的正确代码实现。
1446

被折叠的 条评论
为什么被折叠?



