Repository navigation
Preserve database metadata in custom Hibernate dialects - #54511
Conversation
Closes keycloak#54510 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
There was a problem hiding this comment.
🟢 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
DialectResolutionInfoconstructors 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
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
|
@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! |
There was a problem hiding this comment.
LGTM, thanks for the changes.
Please link the follow-up here once you've created it. Thanks.
* Preserve database metadata in custom Hibernate dialects Closes keycloak#54510 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com> * Adding tests Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com> --------- Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
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 supportedSKIP LOCKEDqueries.Add constructors forwarding
DialectResolutionInfoto 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:checkandgit diff --checkpassed. Live Oracle and SQL Server database testing was not performed.