Skip to content

Conversation

@Chienlin1014
Copy link

@Chienlin1014 Chienlin1014 commented Oct 30, 2025

Spring Batch SQL Server metadata tables default to VARCHAR, but the Microsoft JDBC driver sends strings as NVARCHAR. This mismatch causes implicit conversions, slows queries, and increases deadlock risk.

Update schema-sqlserver.sql to use NVARCHAR for all string columns, aligning with the driver and improving performance.

fix #5064

@Chienlin1014 Chienlin1014 force-pushed the fix/sqlserver-nvarchar-metadata branch from 3be881c to e6bd4c6 Compare October 30, 2025 05:21
…projects#5064)

Spring Batch SQL Server metadata tables default to VARCHAR, but the Microsoft JDBC driver sends strings as NVARCHAR.
This mismatch causes implicit conversions, slows queries, and increases deadlock risk.

Update schema-sqlserver.sql to use NVARCHAR for all string columns, aligning with the driver and improving performance.

Signed-off-by: Chienlin <[email protected]>
@Chienlin1014 Chienlin1014 force-pushed the fix/sqlserver-nvarchar-metadata branch from e6bd4c6 to ee050d6 Compare October 30, 2025 05:30
@Chienlin1014
Copy link
Author

reference: International features of the JDBC driver

@Chienlin1014
Copy link
Author

Fixes #5064

@fmbenhassine fmbenhassine changed the title fix(jdbc): Use NVARCHAR for Spring Batch SQL Server metadata Use NVARCHAR for Spring Batch SQL Server metadata Nov 5, 2025
@fmbenhassine
Copy link
Contributor

@Chienlin1014 Thank you for reporting this issue and for contributing a PR! LGTM 👍

Can you please add a migration script for v6 similar to https://github.com/spring-projects/spring-batch/blob/a33f0e9a328b12c4042a20d577fd0d4460e5734b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sqlserver.sql that alters the tables and changes the columns type accordingly? With that I think this PR could be merged in the upcoming v6. Thank you upfront.

@fmbenhassine fmbenhassine added the status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter label Nov 5, 2025
@Chienlin1014
Copy link
Author

@fmbenhassine Thank you for the quick review and the clear guidance!
I've just added the migration script for v6.0 under src/main/resources/org/springframework/batch/core/migration/6.0/migration-sqlserver.sql, following the same structure and comments style as the v5.0 script.
It includes the corresponding ALTER TABLE statements to update the affected columns to NVARCHAR types.

Please let me know if you'd like me to adjust anything.
Thank you again for the review and for considering this PR for inclusion in v6.0!

@Chienlin1014 Chienlin1014 force-pushed the fix/sqlserver-nvarchar-metadata branch from 3dc7e54 to d12f5df Compare November 6, 2025 02:08
@fmbenhassine fmbenhassine added status: feedback-provided Issues for which the feedback requested from the reporter was provided and removed status: waiting-for-reporter Issues for which we are waiting for feedback from the reporter labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: feedback-provided Issues for which the feedback requested from the reporter was provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Server DDL for metadata tables should use NVARCHAR to prevent performance degradation and deadlocks from implicit conversion

2 participants