Skip to content
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

[4.x] Adds a DialectFactory implementation to permit Hibernate to introspect database metadata properly when supporting container-mode JPA #7927

Merged
merged 5 commits into from
Nov 1, 2023

Conversation

ljnelson
Copy link
Member

@ljnelson ljnelson commented Nov 1, 2023

This PR introduces a DialectFactory implementation that can introspect a DataSource-reachable DatabaseMetaData to discover and build the proper Dialect for Hibernate to use to communicate with a database.

The DialectFactory implementation is needed because Hibernate's default DialectFactory implementation is incapable of discovering database connectivity information that is indirectly linked by a META-INF/persistence.xml's <jta-data-source> element. (The default Hibernate behavior relies on an application-mode-JPA-only property that, interestingly, the specification rightly discourages users from providing when using container-mode JPA.)

The DataSourceBackedDialectFactory detects the case when the DialectResolutionInfoSource supplied to the DialectFactory's buildDialect() method is null. (The possibility of its being null is not documented, but it is very commonly null in almost all situations.) When this state of affairs holds, the DataSourceBackedDialectFactory will get its hands on a DatabaseMetaData and build a proper DialectResolutionInfoSource representing it. It will then hand this off to an invocation of the default DialectFactory implementation's buildDialect() method.

The net result is that dialect introspection happens properly even when the only way that Hibernate can "see" the database is by way of a JTA data source.

The other methods in the class are related to actually getting it recognized by Hibernate's convoluted bootstrap sequencing. Notably, the DialectFactory implementation will not register itself if the user has specified a Dialect explicitly.

This PR also ensures that Hibernate javadoc is correctly linked.

This PR also ensures that the existing CDISEJtaPlatformProvider class functions properly even when CDI is not present.

…t database metadata properly when supporting container-mode JPA

Signed-off-by: Laird Nelson <[email protected]>
@ljnelson ljnelson added enhancement New feature or request MP P3 jpa/jta java Pull requests that update Java code 4.x Version 4.x labels Nov 1, 2023
@ljnelson ljnelson self-assigned this Nov 1, 2023
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 1, 2023
@ljnelson ljnelson changed the title Adds a DialectFactory implementation to permit Hibernate to introspect database metadata properly when supporting container-mode JPA [4.x] Adds a DialectFactory implementation to permit Hibernate to introspect database metadata properly when supporting container-mode JPA Nov 1, 2023
@ljnelson ljnelson requested a review from barchetta November 1, 2023 20:36
@ljnelson
Copy link
Member Author

ljnelson commented Nov 1, 2023

@barchetta I've tagged you mainly to take a look at the javadoc work (Hibernate didn't have an element-list or any offlineLink entries).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x enhancement New feature or request java Pull requests that update Java code jpa/jta MP OCA Verified All contributors have signed the Oracle Contributor Agreement. P3
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

MP starter project with Hibernate cannot start because of missing dialect information
2 participants