Search code examples
mybatisognl

Alias in OGNL inside MyBatis


I'm programming with MyBatis and I have this code

<if test="@mypackage.verylongname.utilities.MyBatisUtilities@isNotEmpty(recipient)">
    and DOCUMENTS.recipient = #{recipient}
</if>

I'd like to have a way to avoid to use the full pathname of my class MyBatisUtilities. Is it there?

Adding an Alias to the mybatis-config file doesn't work

<typeAlias alias="MyBatisUtilities" type="mypackage.verylongname.utilities.MyBatisUtilities"/>

Solution

  • Don't think there is a way no, not unless mybatis provides some special extended functionality for OGNL.

    That doesn't mean it ~couldn't~ be done within OGNL somehow with changes to the core library, just don't believe it does currently. (my memory may be bad, but pretty certain @fullclassname@methodname is the only way OGNL knows of to resolve static method invocations)