8000 Preserve database metadata in custom Hibernate dialects by ahus1 · Pull Request #54511 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Preserve database metadata in custom Hibernate dialects - #54511

Merged
vmuzikar merged 2 commits into
keycloak:mainfrom
ahus1:fix-dialect-resolution-info
Nov 2, 2026
Merged

vmuzikar merged 2 commits into
keycloak:mainfrom
ahus1:fix-dialect-resolution-info

Conversation

@ahus1
@ahus1 ahus1 commented Oct 31, 2026
Copy link
Copy Markdown
Member

Hibernate falls back to no-argument construction for Keycloak's H2, Oracle, and SQL Server dialects because they do not expose a constructor accepting DialectResolutionInfo. This discards database version and configuration information. For example, H2 2.4.240 is treated as 2.1.214, disabling supported SKIP LOCKED queries.

Add constructors forwarding DialectResolutionInfo to the corresponding Hibernate superclass, while preserving no-argument construction and the existing SQL translator overrides. This also enables the superclass initialization of Oracle server settings and SQL Server compatibility levels.

Closes #54510

Validation: five local regression tests passed against this branch, covering version propagation for all three dialects, H2 skip-locked support, Oracle extended strings and Application Continuity settings, and SQL Server compatibility levels. The local test harness is not included in this three-class PR. ./mvnw -pl model/jpa spotless:check and git diff --check passed. Live Oracle and SQL Server database testing was not performed.

Closes keycloak#54510

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI balanced review requested due to automatic review settings October 31, 2026 16:46
@ahus1
ahus1 requested a review from a team as a code owner October 31, 2026 16:46
@ahus1 ahus1 self-assigned this Oct 31, 2026
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the changes that preserve database metadata in Keycloak’s custom dialects.

No open issues 🎉

What changed in this PR

This PR addresses #54510 by preserving database metadata when Hibernate constructs Keycloak’s custom H2, Oracle, and SQL Server dialects, allowing database capabilities to be initialized correctly.

Changes:

  • Adds public DialectResolutionInfo constructors that delegate to each Hibernate superclass.
  • Preserves no-argument construction and existing SQL translator overrides.
  • Enables metadata-based initialization for H2 skip-locked support, Oracle settings, and SQL Server compatibility levels.
File Description
model/​jpa/​src/​main/​java/​org/​keycloak/​connections/​jpa/​dialect/​KeycloakSQLServerDialect.java Forwards resolution metadata for SQL Server version and compatibility-level initialization.
model/​jpa/​src/​main/​java/​org/​keycloak/​connections/​jpa/​dialect/​KeycloakOracleDialect.java Forwards resolution metadata for Oracl 8000 e version and server settings.
model/​jpa/​src/​main/​java/​org/​keycloak/​connections/​jpa/​dialect/​KeycloakH2Dialect.java Forwards resolution metadata for H2 version-dependent capabilities.

Review effort: Balanced

@vmuzikar vmuzikar left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ahus1 Thank you for the fix.

I wonder if there's a way how we could prevent this type of issue in the future. Either some kind of integration test, or a unit test that tries to instantiate all custom dialects.

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 14:33
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the changes to preserve database metadata in Keycloak’s custom Hibernate dialects.

No open issues 🎉

Review effort: Balanced

@ahus1
ahus1 requested a review from vmuzikar November 2, 2026 16:07
@ahus1
ahus1 commented Nov 2, 2026
Copy link
Copy Markdown
Member Author

@vmuzikar - I've added a test for H2, and a reflection based test for the other two.

The H2 test works, and the others would as well, but We would miss it if a new dialect would be added. I'll create a follow-up issue for some static code analysis as a follow-up.

Please review this one, so we can move forward with the fix. Thanks!