Skip to content

Instantly share code, notes, and snippets.

@jacknie84
Last active March 1, 2019 04:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacknie84/3f51046d1a53a86a549a4994ff4f0a8c to your computer and use it in GitHub Desktop.
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
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