实体类

public class Person {

    private String id;
    private String name;
    private Boolean result;
	
	// 省略get和set
}

Mybatis的SQL

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis//DTD Mapper 3.0//EN" "http://mybatis/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxx.TypeMapper">
    <select id="selectInfo" parameterType="com.xxx.entity.Person" resultType="String">
        SELECT
        	<choose>
        		<!--
        			result是布尔值,布尔值进行判断的时候
        			使用下面的判断方法,而不是 result == 'true' 
        			或者 result == true
				-->
				<when test="result">
					'我是true' AS result
				</when>
				<otherwise>
					'我是false' AS result
				</otherwise>
			</choose>
		FROM
			DUAL;
    </select>
</mapper>

更多推荐

Mybatis 布尔值类型作为判断条件