Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Use custom paging provider for aggregate DAO queries#5606

Merged
onobc merged 3 commits intospring-attic:mainfrom
onobc:GH-5531-fix-oracle-page-nav
Dec 22, 2023
Merged

Use custom paging provider for aggregate DAO queries#5606
onobc merged 3 commits intospring-attic:mainfrom
onobc:GH-5531-fix-oracle-page-nav

Conversation

@onobc
Copy link
Contributor

@onobc onobc commented Dec 15, 2023

This commit adds a custom Oracle/MSSQl/DB2 paging provider that is used only by the aggregate DAO. This is required because the standard paging provider that ships with Spring Batch 4.x does not properly handle sort key aliases when using nested ROW_NUMBER clauses for these databases.

Resolves #5531

@onobc onobc requested review from corneil and cppwfs and removed request for corneil December 15, 2023 17:50
@onobc onobc force-pushed the GH-5531-fix-oracle-page-nav branch from 716f5b5 to 8ca82f0 Compare December 15, 2023 17:54
@corneil
Copy link
Contributor

corneil commented Dec 18, 2023

From org/springframework/cloud/dataflow/server/repository/JdbcAggregateJobQueryDao.java:607 in org.springframework.batch.item.database.support.AbstractSqlPagingQueryProvider#getSortKeysWithoutAliases
return SqlPagingQueryUtils.buildSortClause(provider.getSortKeysWithoutAliases()); causes:

SELECT TMP_SUB.JOB_EXECUTION_ID FROM ( SELECT E.JOB_EXECUTION_ID, ROW_NUMBER() OVER ( ORDER BY **JOB_EXECUTION_ID** DESC) AS ROW_NUMBER FROM
resulting in com.microsoft.sqlserver.jdbc.SQLServerException: Ambiguous column name 'JOB_EXECUTION_ID'

The offending code is a part of batch framework.

@corneil
Copy link
Contributor

corneil commented Dec 18, 2023

DB2 seems to suffer the same error.

Copy link
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the code side it looks good. The tests you added catch DB2 and SqlServer has an ambiguous jobexecution id like corneil mentioned from batch 4. And your updated tests now catch this scenario. Yeah for your newly added smoke tests!

@onobc
Copy link
Contributor Author

onobc commented Dec 18, 2023

From org/springframework/cloud/dataflow/server/repository/JdbcAggregateJobQueryDao.java:607 in org.springframework.batch.item.database.support.AbstractSqlPagingQueryProvider#getSortKeysWithoutAliases return SqlPagingQueryUtils.buildSortClause(provider.getSortKeysWithoutAliases()); causes:

SELECT TMP_SUB.JOB_EXECUTION_ID FROM ( SELECT E.JOB_EXECUTION_ID, ROW_NUMBER() OVER ( ORDER BY **JOB_EXECUTION_ID** DESC) AS ROW_NUMBER FROM resulting in com.microsoft.sqlserver.jdbc.SQLServerException: Ambiguous column name 'JOB_EXECUTION_ID'

The offending code is a part of batch framework.

Right, but there is a possibility of our usage upstream is causing this to surface.

@corneil corneil assigned onobc and unassigned corneil Dec 20, 2023
@onobc onobc removed their assignment Dec 20, 2023
This commit adds a custom paging provider that is used only by the aggregate
DAO. This is required because the standard paging provider that ships with
Spring Batch 4.x does not properly handle sort key aliases when using nested
ROW_NUMBER clauses.

Resolves spring-attic#5531
@onobc onobc force-pushed the GH-5531-fix-oracle-page-nav branch from 035553f to 1517818 Compare December 21, 2023 04:42
@onobc onobc changed the title Use custom Oracle paging provider for aggregate DAO queries Use custom paging provider for aggregate DAO queries Dec 21, 2023
@onobc onobc merged commit 6cb57b3 into spring-attic:main Dec 22, 2023
@onobc onobc deleted the GH-5531-fix-oracle-page-nav branch December 22, 2023 02:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Unable to navigate through the job execution pages

3 participants