-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial addition of cursored pagination for SQL (#2884)
* Initial addition of cursored pagination - Create the CursoredPageable type. - Modify the DefaultSqlPreparedQuery to support cursored pageable for SQL. - Modify DefaultFindPageInterceptor to return correct pageable for further pagination in cursored case. * Checkstyle * Change base to 4.8.x * Add hasNext and hasPrevious methods to Page * Checkstyle fixes and disable PostgreSQL test * Implement some review comments * Add methods corresponding to the jakarta PageRequest API * Add requestTotal property to the pageable * Update Page to account for cases when total size is not queried * Fix build * Implement more review comments * Add tests * Fix checkstyle * Throw UnsupportedOperationException where cursored pageable is not yet supported * Add all cursors to the page implementation and remove nextPageable and previousPageable implementation from the CursoredPageable * Slightly improve the test * Fix for postgres r2dbc test * Add CursoredPage and interceptor * Add documentation for cursored pageable * Fix interceptors
- Loading branch information
1 parent
477eabc
commit 696cc25
Showing
63 changed files
with
2,495 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/H2CursoredPaginationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2017-2020 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.data.jdbc.h2 | ||
|
||
import io.micronaut.data.tck.repositories.BookRepository | ||
import io.micronaut.data.tck.repositories.PersonRepository | ||
import io.micronaut.data.tck.tests.AbstractCursoredPageSpec | ||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Shared | ||
|
||
@MicronautTest | ||
@H2DBProperties | ||
class H2CursoredPaginationSpec extends AbstractCursoredPageSpec { | ||
@Inject | ||
@Shared | ||
H2PersonRepository pr | ||
|
||
@Inject | ||
@Shared | ||
H2BookRepository br | ||
|
||
@Override | ||
PersonRepository getPersonRepository() { | ||
return pr | ||
} | ||
|
||
@Override | ||
BookRepository getBookRepository() { | ||
return br | ||
} | ||
|
||
@Override | ||
void init() { | ||
pr.deleteAll() | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/mysql/MysqlCursoredPaginationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2017-2020 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.data.jdbc.mysql | ||
|
||
import groovy.transform.Memoized | ||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.data.tck.repositories.BookRepository | ||
import io.micronaut.data.tck.repositories.PersonRepository | ||
import io.micronaut.data.tck.tests.AbstractCursoredPageSpec | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Shared | ||
|
||
class MysqlCursoredPaginationSpec extends AbstractCursoredPageSpec implements MySQLTestPropertyProvider { | ||
|
||
@Shared @AutoCleanup ApplicationContext context | ||
|
||
@Memoized | ||
@Override | ||
PersonRepository getPersonRepository() { | ||
return context.getBean(MySqlPersonRepository) | ||
} | ||
|
||
@Memoized | ||
@Override | ||
BookRepository getBookRepository() { | ||
return context.getBean(MySqlBookRepository) | ||
} | ||
|
||
@Override | ||
void init() { | ||
context = ApplicationContext.run(properties) | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...dbc/src/test/groovy/io/micronaut/data/jdbc/oraclexe/OracleXECursoredPaginationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2017-2020 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.data.jdbc.oraclexe | ||
|
||
import groovy.transform.Memoized | ||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.data.tck.repositories.BookRepository | ||
import io.micronaut.data.tck.repositories.PersonRepository | ||
import io.micronaut.data.tck.tests.AbstractCursoredPageSpec | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Shared | ||
|
||
class OracleXECursoredPaginationSpec extends AbstractCursoredPageSpec implements OracleTestPropertyProvider { | ||
|
||
@Shared @AutoCleanup ApplicationContext context | ||
|
||
@Override | ||
@Memoized | ||
PersonRepository getPersonRepository() { | ||
return context.getBean(OracleXEPersonRepository) | ||
} | ||
|
||
@Override | ||
@Memoized | ||
BookRepository getBookRepository() { | ||
return context.getBean(OracleXEBookRepository) | ||
} | ||
|
||
@Override | ||
void init() { | ||
context = ApplicationContext.run(properties) | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...dbc/src/test/groovy/io/micronaut/data/jdbc/postgres/PostgresCursoredPaginationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2017-2020 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.data.jdbc.postgres | ||
|
||
import groovy.transform.Memoized | ||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.data.tck.repositories.BookRepository | ||
import io.micronaut.data.tck.repositories.PersonRepository | ||
import io.micronaut.data.tck.tests.AbstractCursoredPageSpec | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Ignore | ||
import spock.lang.Shared | ||
|
||
@Ignore("Causes error: 'FATAL: sorry, too many clients already'") | ||
class PostgresCursoredPaginationSpec extends AbstractCursoredPageSpec implements PostgresTestPropertyProvider { | ||
@Shared @AutoCleanup ApplicationContext context | ||
|
||
@Memoized | ||
@Override | ||
PersonRepository getPersonRepository() { | ||
return context.getBean(PostgresPersonRepository) | ||
} | ||
|
||
@Memoized | ||
@Override | ||
BookRepository getBookRepository() { | ||
return context.getBean(PostgresBookRepository) | ||
} | ||
|
||
@Override | ||
void init() { | ||
context = ApplicationContext.run(getProperties()) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...c/src/test/groovy/io/micronaut/data/jdbc/sqlserver/SqlServerCursoredPaginationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2017-2020 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.data.jdbc.sqlserver | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.data.tck.repositories.BookRepository | ||
import io.micronaut.data.tck.repositories.PersonRepository | ||
import io.micronaut.data.tck.tests.AbstractCursoredPageSpec | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Shared | ||
|
||
class SqlServerCursoredPaginationSpec extends AbstractCursoredPageSpec implements MSSQLTestPropertyProvider { | ||
|
||
@Shared @AutoCleanup ApplicationContext context | ||
|
||
@Override | ||
PersonRepository getPersonRepository() { | ||
return context.getBean(MSSQLPersonRepository) | ||
} | ||
|
||
@Override | ||
BookRepository getBookRepository() { | ||
return context.getBean(MSBookRepository) | ||
} | ||
|
||
@Override | ||
void init() { | ||
context = ApplicationContext.run(properties) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.