MyBatis RowBounds doesn't limit query results

后端 未结 3 1058
滥情空心
滥情空心 2020-12-29 15:42

I am developing an stateless API that needs to support pagination.

I use an Oracle database. I use Spring with MyBatis for database access.

From the docume

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 16:06

    I found a simple work around to this issue. I had followed the Mybatis instructions @khampson recommended and was passing a RowBounds instance to the mapper with no limits being enforced.

    RowBounds rowbounds = new RowBounds(0, resultLimit);
    roster = tableMapper.selectAll(rowbounds);
    

    mapper java

    public List selectAll(RowBounds rowbounds);
    

    mapper xml

    
    

    simply appending "LIMIT #{param1.offset}, #{param1.limit}" to the mapper's xml produced the behavior I wanted!

    
    

提交回复
热议问题