Tagged articles
1 articles
Page 1 of 1
Architecture Digest
Architecture Digest
May 19, 2021 · Backend Development

Why MyBatis Treats Integer 0 as an Empty String in <if> Conditions

When using MyBatis dynamic SQL to filter records by a numeric state field, the framework incorrectly evaluates the condition "state != ''" as false for the integer value 0 because its OGNL expression evaluator treats 0 as equivalent to an empty string, leading to unexpected query results.

Dynamic SQLInteger ComparisonJava
0 likes · 7 min read
Why MyBatis Treats Integer 0 as an Empty String in <if> Conditions