Menu

1 / 3

Stop restarting your app to find out what a MyBatis-Plus Wrapper generates

DEV Community: sql·SongRenShuo·about 6 hours ago
#LZCNy6iR
#devtosql#devto#dev#statement#plugin
Long article (1405 words) — no AI summary yet.
Reading 0:00
15s threshold

Every Java codebase I have worked on that uses MyBatis-Plus has the same small loop in it. You change one condition, and then you need to know what the change actually produced.

LambdaQueryWrapper < User > qw = Wrappers . lambdaQuery ( ) ; qw . eq ( StringUtils . isNotBlank ( req . getUsername ( ) ) , User :: getUsername , req . getUsername ( ) ) . ge ( req . getCreatedFrom ( ) != null , User :: getCreatedAt , req . getCreatedFrom ( ) ) . orderByDesc ( User :: getId ) ; userMapper . selectPage ( page , qw ) ;

Enter fullscreen mode

Exit fullscreen mode

Three things are uncertain here, and none of them are visible in the code:

whether the username condition is in the statement at all, since it depends on a runtime value;

whether the logical-delete column was appended, and where in the WHERE clause;

what the paging count query looks like next to the LIMIT query.

So you restart the app, send one request, scroll to the console, find Preparing: SELECT ... WHERE username = ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.