如何让最新的 MyBatis Dynamic SQL 支持 mysql (limit/offset) 的分页?

how to make the latest MyBatis Dynamic SQL support pagination for mysql (limit/offset)?

http://www.mybatis.org/mybatis-dynamic-sql/docs/select.html 上有一些示例。

我想为 mysql 实现 limit/offset,但没有看到任何描述如何扩展此库以支持其他 where 条件的文档。

这是我想要实现的目标:

SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
        .from(animalData)
        .where(id, isIn(1, 5, 7))
        .and(bodyWeight, isBetween(1.0).and(3.0))
        .orderBy(id.descending(), bodyWeight)
        .limit(1).offset(10)
        .build()
        .render(RenderingStrategy.MYBATIS3);

您可以使用一些资源。

此页面 - http://www.mybatis.org/mybatis-dynamic-sql/docs/whereClauses.html - 显示了使用独立 where 子句构建分页查询的示例。这不是您要查找的内容,但它显示了一种方法。

有一个单元测试显示的内容更接近您在此处查找的内容 - https://github.com/mybatis/mybatis-dynamic-sql/tree/master/src/test/java/examples/paging。此代码适用于 MySQL,您可以按原样使用它。

我希望在未来的版本中使这更容易一些。