当前使用版本(必填,否则不予处理)

3.4.3,3.4.2 都试了

该问题是如何引起的?(确定最新版也有问题再提!!!)

mp连表分页查询 数据库是pgsql,用条件构造器传入参数方式 offset没有自动拼接上去

重现步骤(如果有就写完整)

PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.POSTGRE_SQL); 已经配置,如果不用条件构造器 ,各种条件都在xml 写那种,分页好使 会生成 limit xxx offset xx 那种sql, 但是如果用条件构造器 最后执行的sql 缺失 offset

报错信息

没有得到想要的数据

Comment From: 986510453

@SundaySun2018 方便贴一下不生效的分页代码吗?

Comment From: SundaySun2018

分页配置已修改为支持pgsql

@Configuration
@MapperScan("com.shop.service.*.mapper")
public class MybatisPlusConfig {
 @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //设置分页插件
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.POSTGRE_SQL);
        paginationInnerInterceptor.setOverflow(true);
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        return interceptor;
    }
 }

controller代码:随便写个一个查询条件

 @GetMapping("test")
    public Object testPage(Integer current,Integer size) {

        Page<Shippings> page = new Page<>(current,size);

        Page<Shippings> shippingspage = shippingService.pageTest(page, Wrappers.<Shippings>query().eq("t2.title","修改"));
        ResultData result = new ResultData();
        result.setPagination(shippingspage);
        result.put("menus", shippingspage.getRecords());
        return new Result(RestCode.SUCCESS.code,"success",result);
    }

service代码

@Override
    public Page<Shippings> pageTest(Page<Shippings> page, QueryWrapper<Shippings> queryWrapper) {
        return shippingMapper.pageTest(page,queryWrapper);
    }

dao代码

public interface ShippingMapper extends BaseMapper<Shippings> {
    Page<Shippings> pageTest(Page<Shippings> page,@Param(Constants.WRAPPER) QueryWrapper<Shippings> query);
}

xml中代码

 <select id="pageTest" resultType="com.shop.service.shipping.entity.Shippings">
        select t1.*,t2.*
        from shippings t1
        left join shipping_plans t2 on t1.id = t2.shipping_id
        ${ew.customSqlSegment}
    </select>

控制台的执行语句

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@666d92f7] was not registered for synchronization because synchronization is not active
JDBC Connection [org.postgresql.jdbc.PgConnection@24632f9] will not be managed by Spring
==>  Preparing: SELECT COUNT(*) FROM shippings t1 LEFT JOIN shipping_plans t2 ON t1.id = t2.shipping_id WHERE (t2.title = ?)
==> Parameters: 修改(String)
<==    Columns: count
<==        Row: 1
<==      Total: 1
==>  Preparing: select t1.*,t2.* from shippings t1 left join shipping_plans t2 on t1.id = t2.shipping_id WHERE (t2.title = ?) LIMIT ?
==> Parameters: 修改(String), 2(Long)

Comment From: SundaySun2018

@986510453 好的谢谢

Comment From: SundaySun2018

@986510453 不好意思我知道咋回事了,是我自己的问题,数据少于传入参数的每页的条数,或者第一页 ,就是这样啊

Comment From: 986510453

@SundaySun2018 好的,确定没问题的话,就关了吧