Last active
March 1, 2019 04:08
-
-
Save jacknie84/3f51046d1a53a86a549a4994ff4f0a8c to your computer and use it in GitHub Desktop.
It's tip that write functional code on default script language of mybatis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Don't speak English well. Thank you for your patience. | |
It's functions xml file. | |
<mapper namespace="org.jacknie.mybatis.Functions"> | |
<sql id="isBlank"> | |
<bind name="isBlank" value=":[@org.apache.commons.lang3.StringUtils@isBlank(#this)]" /> | |
</sql> | |
<sql id="sysout"> | |
<bind name="sysout" value=":[@System@out.println(#this)]" /> | |
</sql> | |
</mapper> | |
It's mapper xml file. | |
<mapper namespace="org.jacknie.test.TestMapper"> | |
<select id="selectTest" resultType="_int"> | |
<include refid="org.jacknie.mybatis.Functions.isBlank" /> | |
<include refid="org.jacknie.mybatis.Functions.sysout" /> | |
SELECT '1' FROM DUAL | |
<if test="#fn = isBlank, not(#fn(map.name))"> | |
<bind name="forLogging" value="#fn = sysout, #fn('Hello' + map.name)" /> | |
</if> | |
</select> | |
</mapper> | |
How about think this tip... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment