Mybatis : "less than" issue in Select annotations

To be fair, it's not the issue in MyBatis, but the behaviour of XML parsing.

If you don't want characters such as < and & to be parsed, you can use the term CDATA to prevent the XML parser to parse such text. Please refer to http://www.w3schools.com/xml/xml_cdata.asp for detail. Or you may escape it with &lt as comments.

I.E.

<script>
SELECT * FROM STUDENT
WHERE DEPARTMENT_ID = #{depId}
<if test='joiningDate != null'> 
<![CDATA[
AND STUDENT_ID <= #{joiningDate} 
]]>
</if>
</script>