Conditional parameters of Mybatis-Plus
1. After configuring Mybatis-Plus
Eliminate the hassle of writing SQL
It also reduces the occurrence rate of bugs
Improved efficiency
It is a good strategy
2. Mybatis-Plus conditional parameters used
Query method | illustrate |
---|---|
where | WHERE statement, splicing + WHERE condition |
and | AND statement, splicing + AND field = value |
or | OR statement, splicing + OR field = value!!! Actively calling or means that the next method is not connected with and then! (If or not calls or, the default is to use and connection) |
eq | Equal to = |
allEq | Based on map content equals = |
ne | Not equal to <> |
gt | Greater than> |
ge | greater than or equal to >= |
lt | Less than < |
le | Less than or equal to <= |
like | Fuzzy query LIKE |
likeLeft | LIKE ‘% value’ |
likeRight | LIKE 'value %' |
notLike | Fuzzy query NOT LIKE |
in | IN (v0, v1, …) |
notIn | NOT IN (v0, v1, …) |
inSql | IN (sql statement) |
notInSql | Field NOT IN (sql statement) |
isNull | NULL value query |
isNotNull | IS NOT NULL |
groupBy | GROUP BY Field, … |
having | HAVING (sql statement) |
orderBy | ORDER BY field, … |
orderByAsc | ORDER BY Field, … ASC |
orderByDesc | ORDER BY field, … DESC |
exists | EXISTS conditional statement |
notExists | NOT EXISTS Conditional Statement |
between | BETWEEN conditional statement |
notBetween | NOT BETWEEN conditional statement |
addFilter | Free splicing SQL |
last | Ignore the optimization rules and splice them directly to the end of sql!!! Can only be called once, multiple calls shall prevail the last time. There is a risk of sql injection, please use it with caution |
apply | Splicing SQL |
3. Directly through wrapper
Conditions behind splicing SQL
(column, val1, val2) (columns) //Responsive grouping in SQL (column, params) //Equivalent to where conditions (column, value) // sql in (column, value) // sql not in (columns, isAsc) //Sort (value) //Relative to exists query in sql (value) //Equivalent to not exists query in SQL (column, val1, val2) //Equivalent to the between used in SQL within a certain scope (column, params) //Greater than or equal to (column, params) // Less than or equal to (column, value) //Fuzzy query (sqlHaving, params) //condition
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.