Python 官方文档:入门教程 => 点击学习
目录EntityWrapper的in用法mybatis-plus EntityWrapper in举个例子EntityWrapper的in用法 EntityWrapper<Us
EntityWrapper<UserLife> wrapper = new EntityWrapper<>();
wrapper.eq("is_valid", 1);
wrapper.in("life_name", "ge,edu,career");
List<UserLife> userLabelList = userLabelService.selectList(wrapper);
in的第二个参数可以是字符串也可以是list但是注意字符串中","间不能有空格,不然会查出来的语句就是这样的
环境:
SpringBoot+mybatis
源码:
public Wrapper<T> in(String column, Collection<?> value) {
return in(true, column, value);
}
public Wrapper<T> in(boolean condition, String column, Collection<?> value) {
if (condition && CollectionUtils.isNotEmpty(value)) {
sql.WHERE(fORMatSql(inExpression(column, value, false), value.toArray()));
}
return this;
}
如果condition不传,等同于:condition: true;
如果传入的value不为空,相当于改 in 查询语句为拼接;
//代码
@Override
public List<User> selectByCaseIdSet(Set<String> idSet) {
EntityWrapper<User> wrapper = new EntityWrapper<>();
wrapper.in(!CollectionUtils.isEmpty(idSet), "id", idSet);
return this.selectList(wrapper);
}
/**
* 如果idSet 为空,sql: select * from user
* 如果idSet 不为空, sql: select * from user where id in (idSet)
** /
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: 关于EntityWrapper的in用法
本文链接: https://www.lsjlt.com/news/143430.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0