I am using MyBatis with MySql in my project.
I have:
myField ENUM(‘yes’,’no’)
and I want to map in to java boolean value:
I know I can modify all mybatis templates, e.g.:
<update id="update">
UPDATE
myTable
<set>
...
<if test="myField != null">myField = <choose>
<when test="myField == true">'yes'</when>
<otherwise>'no'</otherwise>
</choose>,
</if>
...
</set>
WHERE
...
</update>
But can I do this in more convenient way?
It seems the best way to solve this is to implement my own boolean type handler:
and then to use it in the mapper template: