<select id="getAppletBWareOrderByDepotId" resultType="com.ellassay.x2.sync.entity.X2DRetailEntity"> select ${selectField} from X6_BILLS_GLS.D_RETAIL where setdepot_id in <foreach collection="allDepotId" item="ids" open="(" separator="," close=")"> #{ids} </foreach> and setdepot...
@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor(){ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2)); return interceptor;} 接下来改造上面的代码,调用selectJoinPage()方法:public void page() { ...
<select id="yktestOrder" resultType="com.yuxun.fantuan.security.entity.User"> select u.id, u.username FROM user u WHERE 1 = 1 <if test="null != ids and ids.size > 0"> AND u.id IN <foreach item="item" index="index" collection="ids" open="(" separator="," close=")"> #...
2、重复使用的SQL语句 and math=#{math} and name=#{name} SELECT * FROM student_score sc WHERE 1=1 ORDER BY sc.math DESC 1. 注意: where后加 1=1 恒等式是为了避免当查询条件全都为空时报错。 最好基于单表来定义SQL片段,提高片段的可重用性。 在SQL片段中最好不要包括where foreach 标签 我们...
@Test public void select(){ // 创建分页参数 Page<User> page = new Page<>(1,2); IPage<String> result = userMapper.selectByHisName(page); // 获取数据 List<String> records = result.getRecords(); records.forEach(System.out::println); System.out.println("总页数 = "+ result.getPages...
Mybatis-Plus select不列出全部字段 https://www.jianshu.com/p/e97b8236db67 只显示某两个字段 @TestpublicvoidselectByWrapper10(){ QueryWrapper<User> queryWrapper =newQueryWrapper<>(); queryWrapper.select("name","age").like("name","雨");...
mybatis plus foreach 的用法 一: foreach 用于 select * from tablename where colname in (A,B,C……); 1:service 层: Set<String> teacherNums = new HashSet<>(); Set<String> departments = new HashSet<>(); list.stream().forEach(s->{...
简介:Mybatis-Plus select不去查全部字段和去重 1mybatis-plus select查询语句默认是查全部字段,有两种方法可以指定要查询的字段 CREATE TABLE `user` (`id` bigint(20) NOT NULL COMMENT '主键',`name` varchar(30) DEFAULT NULL COMMENT '姓名',`age` int(11) DEFAULT NULL COMMENT '年龄',`email` varc...
public void testSelectByBatchIds(){ Listusers = userMapper.selectBatchIds(Arrays.asList(1, 2, 3)); users.forEach(System.out::println); } 测试结果如下: 使用map进行条件查询测试代码如下: //按条件查询之使用map操作 @Test public void testSelectByMap(){ ...
@Configurationpublic class MybatisPlusConfiguration { //配置分页拦截器 @Bean public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); }} 二、单表查询分页-表格分页 @Testpublic void testSelect() { LambdaQueryWrapper<User> query = new LambdaQueryWrapper<>(...