美文网首页
Myabtis-Plus之QueryWrapper常用方法

Myabtis-Plus之QueryWrapper常用方法

作者: 催化剂 | 来源:发表于2021-09-13 11:32 被阅读0次

    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")

    betweencloum between ? and ?between(“age”,0,21)

    notBetweencloum between ? and ?notBetween(“age”,0,21)

    likecloum like ‘% 王 %’like(“real_name”,“王”)

    notLikenot like ‘% 王 %’notLike(“real_name”,“王”)

    likeLeftlike ‘% 王’likeLeft(“real_name”,“昭”)

    likeRightlike ‘王 %’likeRight(“real_name”,“昭”)

    isNullis nullisNull(“gender”)

    isNotNullis not nullisNotNull(“gender”)

    inin (1,2,3)in(“nick_name”,lists)

    notInage not in (1,2,3)notIn(“nick_name”,lists)

    inSqlage in (1,2,3,4,5,6)inSql(“nick_name”,"‘空想 4’,‘空想 5’,‘空想 6’")

    notInSqlage not in (1,2,3,4,5,6)notInSql(“nick_name”,"‘空想 4’,‘空想 5’,‘空想 6’")

    groupBygroup by id,namegroupBy(“nick_name”,“age”)

    orderByAscorder by id ASC,name ASCorderByAsc(“nick_name”,“age”)

    orderByDescorder by id DESC,name DESCorderByDesc(“age”)

    orderByorder by id ASC,name ASCorderBy(true,true,“age”)

    havinghaving sum(age) > 10having(“sum(age) > 10”)

    orid = 1 or name = ‘老王’eq(“nick_name”,“空想 4”).or(i->i.eq(“age”,21) eq(“nick_name”,“空想 4”).or().eq(“nick_name”,“空想 5”)

    andand (name = ‘李白’ and status <> ‘活着’)and(i->i.eq(“age”,21))

    nested(name = ‘李白’ and status <> ‘活着’)nested(i->i.eq(“age”,21).eq(“nick_name”,“空想 4”))

    applyid = 1apply(“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() 方法获取

    方法名说明使用

    selectselect(i -> i.getProperty().startsWith(“test”))select(“id”, “name”, “age”)

    UpdateWrapper

    继承自 AbstractWrapper , 自身的内部属性 entity 也用于生成 where 条件

    及 LambdaUpdateWrapper, 可以通过 new UpdateWrapper().lambda() 方法获取!

    方法名说明使用

    setset(“name”, “老李头”)set(“name”, “”)

    setSqlsetSql(“name = ‘老李头’”)setSql(String sql)

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

    文章引用:http://www.qishunwang.net/knowledge_show_66530.aspx

    相关文章

      网友评论

          本文标题:Myabtis-Plus之QueryWrapper常用方法

          本文链接:https://www.haomeiwen.com/subject/yxjiwltx.html