AbstractWrapper 下的方法及使用
方法名 | 说明 | 使用 |
---|---|---|
allEq(Map<R, V> params) | 全部 =(或个别 isNull) | allEq(params,true) |
eq | = | eq(“real_name”,“王昭君”) |
ne | <> | ne(“nick_name”,“空想 4”) |
gt | > | gt(“age”,21) |
ge | >= | ge(“age”,22) |
lt | < | lt(“age”,22) |
le | <= | le(“age”,21") |
between | cloum between ? and ? | between(“age”,0,21) |
notBetween | cloum between ? and ? | notBetween(“age”,0,21) |
like | cloum like ‘% 王 %’ | like(“real_name”,“王”) |
notLike | not like ‘% 王 %’ | notLike(“real_name”,“王”) |
likeLeft | like ‘% 王’ | likeLeft(“real_name”,“昭”) |
likeRight | like ‘王 %’ | likeRight(“real_name”,“昭”) |
isNull | is null | isNull(“gender”) |
isNotNull | is not null | isNotNull(“gender”) |
in | in (1,2,3) | in(“nick_name”,lists) |
notIn | age not in (1,2,3) | notIn(“nick_name”,lists) |
inSql | age in (1,2,3,4,5,6) | inSql(“nick_name”,"‘空想 4’,‘空想 5’,‘空想 6’") |
notInSql | age not in (1,2,3,4,5,6) | notInSql(“nick_name”,"‘空想 4’,‘空想 5’,‘空想 6’") |
groupBy | group by id,name | groupBy(“nick_name”,“age”) |
orderByAsc | order by id ASC,name ASC | orderByAsc(“nick_name”,“age”) |
orderByDesc | order by id DESC,name DESC | orderByDesc(“age”) |
orderBy | order by id ASC,name ASC | orderBy(true,true,“age”) |
having | having sum(age) > 10 | having(“sum(age) > 10”) |
or | id = 1 or name = ‘老王’ | eq(“nick_name”,“空想 4”).or(i->i.eq(“age”,21) eq(“nick_name”,“空想 4”).or().eq(“nick_name”,“空想 5”) |
and | and (name = ‘李白’ and status <> ‘活着’) | and(i->i.eq(“age”,21)) |
nested | (name = ‘李白’ and status <> ‘活着’) | nested(i->i.eq(“age”,21).eq(“nick_name”,“空想 4”)) |
apply | id = 1 | apply(“nick_name = ‘空想 4’”) |
last | 最后添加多个以最后的为准,有 sql 注入风险 | last(“limit 1”) |
exists | 拼接 EXISTS (sql 语句) | exists(“select id from table where age = 1”) |
notExists | 拼接 NOT EXISTS (sql 语句) | notExists(“select id from table where age = 1”) |
QueryWrapper
继承自 AbstractWrapper , 自身的内部属性 entity 也用于生成 where 条件
及 LambdaQueryWrapper, 可以通过 new QueryWrapper().lambda() 方法获取
方法名 | 说明 | 使用 |
---|---|---|
select | select(i -> i.getProperty().startsWith(“test”)) | select(“id”, “name”, “age”) |
UpdateWrapper
继承自 AbstractWrapper , 自身的内部属性 entity 也用于生成 where 条件
及 LambdaUpdateWrapper, 可以通过 new UpdateWrapper().lambda() 方法获取!
方法名 | 说明 | 使用 |
---|---|---|
set | set(“name”, “老李头”) | set(“name”, “”) |
setSql | setSql(“name = ‘老李头’”) | setSql(String sql) |
参考于https://blog.csdn.net/qq_43399077/article/details/104061760