import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
-import org.apache.ibatis.session.RowBounds;
import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
return emptyList();
}
- int offset = (page - 1) * pageSize;
- int limit = page * pageSize;
-
- return mapper(dbSession).selectByQueryInDescOrder(query, new RowBounds(offset, limit));
+ return mapper(dbSession).selectByQueryInDescOrder(query, Pagination.forPage(page).andSize(pageSize));
}
public int countByQuery(DbSession dbSession, CeTaskQuery query) {
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.session.RowBounds;
import org.sonar.db.Pagination;
public interface CeQueueMapper {
List<CeQueueDto> selectAllInAscOrder();
- List<CeQueueDto> selectByQueryInDescOrder(@Param("query") CeTaskQuery query, RowBounds rowBounds);
+ List<CeQueueDto> selectByQueryInDescOrder(@Param("query") CeTaskQuery query, @Param("pagination") Pagination pagination);
int countByQuery(@Param("query") CeTaskQuery query);
<include refid="columns"/>
<include refid="sqlSelectByQuery"/>
<include refid="orderByDescDateAndUuid"/>
+ <include refid="pagination"/>
</select>
+ <sql id="pagination">
+ offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+ </sql>
+
<select id="countByQuery" resultType="int">
select
count(1)