开发者

Does the AND operator in MyBatis test expressions short-circuit during evaluation?

开发者 https://www.devze.com 2023-02-27 06:27 出处:网络
Is the AND keyword in test expressions in MyBatis implemented using a short-circuit? For example, I have written the following:

Is the AND keyword in test expressions in MyBatis implemented using a short-circuit? For example, I have written the following:

<whe开发者_运维问答n test="pagingInstruction != null
            and pagingInstruction.direction.toString() == 'FORWARD'">
...
</when>

If the first operand resolves to false, will the second operand be ignored? (I'm using MyBatis v3.0.4.)


Although it is not stated in the reference doc that the test attribute of the when element short circuits, the reference doc includes an example that only works if the test attribute of the when element short circuits.

The example is similar to yours; here it is:

... stuff
<when test="author != null and author.name != null">

The easiest way to resolve your question might be to create some simple unit tests to determine how myBatis treats the "and".

Also, you may need to test that pageInstruction.direction is not null before calling pageInstruction.direction.toString().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号