Skip to content

Avoid loading XML files for default SQL exception translation #28216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wilkinsona opened this issue Mar 22, 2022 · 1 comment
Closed

Avoid loading XML files for default SQL exception translation #28216

wilkinsona opened this issue Mar 22, 2022 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

wilkinsona commented Mar 22, 2022

#25335 allowed the use of SQLErrorCodeSQLExceptionTranslator to be disabled by configuring spring.ignore.xml to true. This successfully reduced the footprint when running in a GraalVM native image, but at the cost of potentially different exception translation. To ensure consistent behavior, it would be useful if SQLErrorCodeSQLExceptionTranslator could be used without loading sql-error-codes.xml.

From @jhoeller:

For our default purposes, we could even keep those error code mappings in a hard-coded class - and possibly get rid of the default sql-error-codes.xml file completely, just supporting that file format for user-provided files.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 22, 2022
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Mar 22, 2022
@jhoeller jhoeller removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 28, 2022
@jhoeller jhoeller self-assigned this Mar 28, 2022
@jhoeller jhoeller added this to the 6.0.0-M4 milestone Mar 28, 2022
@jhoeller jhoeller added theme: aot An issue related to Ahead-of-time processing in: data Issues in data modules (jdbc, orm, oxm, tx) and removed in: core Issues in core modules (aop, beans, core, context, expression) labels May 6, 2022
@jhoeller
Copy link
Contributor

On further consideration, I'm inclined to align with our R2DBC support and just rely on JDBC-provided exception subclasses by default, potentially with a few database-specific checks attached (like we do for ResultSet value extraction), and with the ability to customize the behavior programmatically (which we effectively have already but could provide more specific hooks for).

In other words, we would consistently not use explicit error code definitions by default anymore (not XML-provided and no hard-coded equivalent either) since they effectively duplicate indications in the JDBC 4 exception subclasses to quite some degree. With modern-day JDBC drivers on a JDK 17 baseline, there should be no need for such a full-scale replacement, rather just for a few specific database-specific adaptations within the JDBC exception subclass indications.

We may keep SQLErrorCodeSQLExceptionTranslator for user-provided sql-error-codes.xml files, triggered by the presence of such a file in the root of the classpath. However, we would not ship a default XML file ourselves anymore. For anyone inclined, they could be copying our current sql-error-codes.xml file to their classpath for strict backwards-compatible behavior. That said, I'd rather like to hear from every such case about why they need any explicit error code mappings to begin with, considering some database-specific tweaking of our SQLExceptionSubclassTranslator based on that feedback instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants