使用mybatis-plus的分页插件,也在mybatisConfig进行配置了
package com.xjc.ldao.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @Author bill
* @Describe
* @Date 2021-12-2021/12/7-16:49
*/
@Configuration
@EnableTransactionManagement
@MapperScan("com.xjc.dao.mapper")
public class MybatisPlusConfig {
/**
*乐观锁配置
* */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return mybatisPlusInterceptor;
}
/**
*分页配置
* */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor1() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}
但是,在使用自带的查询语句时,total有数据,但是records没有数据,通过打印sql语句得知只执行了一个select count(*) from table的sql语句,并没有执行查询数据的语句,从而导致没有数据,但是换成自己写的sql语句还是不行,这是咋回事?
service如下
@Override
public IPage<AdminMenu> selectMenuList(AdminMenuVo adminMenuVo) {
Page<AdminMenu> iPage = new Page<>(adminMenuVo.getPage(), adminMenuVo.getSize());
IPage<AdminMenu> adminMenuIPage = adminMenuMapper.selectPage(iPage,null);
return adminMenuIPage;
}
这是自带的,下面这是我自己写的
@Override
public IPage<AdminMenu> selectMenuList(AdminMenuVo adminMenuVo) {
Page<AdminMenu> iPage = new Page<>(adminMenuVo.getPage(), adminMenuVo.getSize());
//IPage<AdminMenu> adminMenuIPage = adminMenuMapper.selectPage(iPage,null);
IPage<AdminMenu> adminMenuIPage = adminMenuMapper.selectPageVo(iPage);
return adminMenuIPage;
}
mapper和xml
IPage<AdminMenu> selectPageVo(IPage<AdminMenu> page);
<select id="selectPageVo" resultMap="BaseResultMap">
select * from sys_admin_menu
</select>
这是配置有问题吗?请指教