How mybatis example generates sql of or condition

I want to use the example class of mybatis to generate the following sql statement:

SELECT * FROM User where nick_name like "%1502%" or real_name like "%1502%" or mobile like "%1502%"

this is how I used it:

UserExample userExample = new UserExample();
UserExample.Criteria userCriteria = userExample.createCriteria();
userExample.or().andMobileLike("%1502%");
userExample.or().andRealNameLike("%1502%");
userExample.or().andNickNameLike("%1502%");
return userService.selectByExample(userExample);

but using it this way will not return the results I want. It will return all the User data without adding or restrictions
clipboard.png
asking for advice

Mar.02,2021

try this?

userExample.or().orMobileLike("%1502%");
userExample.or().orRealNameLike("%1502%");
userExample.or().orNickNameLike("%1502%");

try this:

userExample.or().andMobileLike("%1502%").andRealNameLike("%1502%").andNickNameLike("%1502%");
Menu