QueryWrapper中常用方法,用法大全

AbstractWrapper 下的方法及使用

@H_419_13@

方法名 说明 使用
allEq(Map 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”,21)
notBetween cloum between ? and ? notBetween(“age”,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,3) notin(“nick_name”,lists)
insql age in (1,3,4,5,6) insql(“nick_name”,"‘空想 4’,‘空想 5’,‘空想 6’")
notinsql age not in (1,6) notinsql(“nick_name”,‘空想 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() 方法获取

@H_419_13@

方法名 说明 使用
select select(i -> i.getproperty().startsWith(“test”)) select(“id”,“name”,“age”)

UpdateWrapper

继承自 AbstractWrapper,自身的内部属性 entity 也用于生成 where 条件
及 LambdaUpdateWrapper,可以通过 new UpdateWrapper().lambda() 方法获取!

@H_419_13@

方法名 说明 使用
set set(“name”,“老李头”) set(“name”,“”)
setsql setsql(“name = ‘老李头’”) setsql(String sql)

参考于https://blog.csdn.net/qq_43399077/article/details/104061760

总结

以上是编程之家为你收集整理的Myabtis-Plus之QueryWrapper常用方法全部内容,希望文章能够帮你解决Myabtis-Plus之QueryWrapper常用方法所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

你可能感兴趣的:(java,java)