QueryWrapper概述:
??????? 也称条件构造器,继承自AbstractWrapper,自身的内部属性entity,也用于生成where条件及LambdaQueryWapper,可以通过new QueryWrapper().lambda()方法获取
?
QueryWrapper<Employee> wrapper = new QueryWrapper<>()
QueryWrapper常用方法
函数名 | 说明 | 例子 |
---|
eq | 等于 = | eq("name","海绵宝宝")? →? name="海绵宝宝" | ne | 不等于 <> | ne("name","海绵宝宝")? →? name<>"海绵宝宝" | gt | 大于 > | gt("age","18")?? →? age>18 | ge | 大于等于 >= | ge("age","18")? →? age>=18 | le | 小于等于 <= | le("age","18")? →? age<=18 | lt | 小于 < | lt("age","18")? →? age<18 | between | BETWEEN 值1 and 值2 | between("age",18,30)? →? age between 18 and 30 | notBetween | NOT BETWEEN 值1 and 值2 | between("age",18,30)? →? age not between 18 and 30 | like | LIKE '%值%' | like("name","海")? →? name like "%海%" | notLike | NOT LIKE '%值%' | not like("name","海")? →? name like "%海%" | likeLeft | LIKE '%值' | leftLlike("name","海")? →? name like "%海" | likeRight | LIKE '值%' | rightLlike("name","海")? →? name like "海%" | isNull | 字段 IS NULL | isNull("name")? →? name is null | isNotNull | 字段 IS NOT NULL | is Not Null("name")? →? name is not null | in | 字段 IN(v0,v1,v2,...) | in("age",{1,2,3})? →? age in (1,2,3) | notIn | 字段 NOT IN(v0,v1,v2,...) | notIn("age",{1,2,3})? →? age not in (1,2,3) | inSql | 字段 IN(sql语句) | inSql("id","select id from table where id<3")? →? age in(select id from table where id<3)? | notInSql | 字段 NOT IN(sql语句) | notInSql("id","select id from table where id<3")? →? age not in(select id from table where id<3)? | groupBy | 分组:groupBy | groupBy("id","name")? →? group by id,name | orderByAsc | 正序排序 | orderByAsc("id","name")? →? order by id Asc,name Asc | orderByDesc | 倒序排序 | orderByDesc("id","name") → order by id Desc,name Desc | orderBy | 排序? :ODER BY 字段 | orderBy(true,true,"id","name")→ order by id Asc,name Asc | having | HAVING(sql语句) | having("sum(age) > {0}",11) →? having sum(age) >11 | or | 拼接 OR | eq("id",1).or().eq("name","派大星") →? id=1 or name="派大星" | and | AND 嵌套 | 用于嵌套 | apply | 拼接 sql | 用于数据库函数,一般having很少用 | last | 无视化规则直接拼接到sql的最后 | 只能调用一次? last("limit 1") | exists | 拼接EXISTS(sql语句) | exists("select id from table where age = 1") →exists("select id from table where age = 1") | notExists | 拼接NOT EXISTS(sql语句) | notExists("select id from table where age = 1") →not exists("select id from table where age = 1") |
?
?
|