Git Product home page Git Product logo

dbflute-offset-test's Introduction

再現手順

準備

  1. Docker がインストールされていれば、 startMySQL.sh を実行することで起動できます。
  2. テスト用のテーブルとデータを用意済みなので replace-schema を実行してください。

実行

./gradlew bootRun

結果

member テーブルから合計100件のレコードを取得するテスト。 PageSize を 31 にしているので、4ページに分割。

1. 通常のpaging

テストコード

問題なし。

testPage =============================================================================
PageSize:  31, PageNum:   1, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, PageNum:   2, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, PageNum:   3, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, PageNum:   4, AllPageCount:   4, AllRecordCount:  100, FetchRecords:   7

2. xfetchScope() を使用

テストコード

最後だけ AllRecordCount が 7 になってしまう。

testPageByOffset1 ====================================================================
PageSize:  31, Offset:   0, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, Offset:  31, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, Offset:  62, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, Offset:  93, AllPageCount:   1, AllRecordCount:    7, FetchRecords:   7

3. xfetchScope() + disablePagingCountLater() を使用

テストコード

AllRecordCount は正しく取得できるが、4回目の取得で page.existsNextPage()true を返してしまい、5回ループしてしまう。

testPageByOffset2 ====================================================================
PageSize:  31, Offset:   0, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, Offset:  31, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, Offset:  62, AllPageCount:   4, AllRecordCount:  100, FetchRecords:  31
PageSize:  31, Offset:  93, AllPageCount:   4, AllRecordCount:  100, FetchRecords:   7
PageSize:  31, Offset: 100, AllPageCount:   4, AllRecordCount:  100, FetchRecords:   0

調査

2. について

PagingInvoker#deriveAllRecordCountByLastPage() で、 pagingBean.getFetchPageNumber() が 0 を返しているため、 baseSize が 0 になってしまうことが原因。

3. について

(挙動の確認のみ)

PagingInvoker#doPaging() 内のif文で、disablePagingCountLater()指定有無によって分岐している。

disablePagingCountLater()を指定していると、deriveAllRecordCountByLastPage()は呼び出されないので、allRecordCountは、正しく計算される。 ただし、毎回select count(*) 〜が実行されてしまう。

dbflute-offset-test's People

Contributors

little-forest avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.