[4.x] Adds a DialectFactory implementation to permit Hibernate to introspect database metadata properly when supporting container-mode JPA #7927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a
DialectFactory
implementation that can introspect aDataSource
-reachableDatabaseMetaData
to discover and build the properDialect
for Hibernate to use to communicate with a database.The
DialectFactory
implementation is needed because Hibernate's defaultDialectFactory
implementation is incapable of discovering database connectivity information that is indirectly linked by aMETA-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 theDialectResolutionInfoSource
supplied to theDialectFactory
'sbuildDialect()
method isnull
. (The possibility of its beingnull
is not documented, but it is very commonlynull
in almost all situations.) When this state of affairs holds, theDataSourceBackedDialectFactory
will get its hands on aDatabaseMetaData
and build a properDialectResolutionInfoSource
representing it. It will then hand this off to an invocation of the defaultDialectFactory
implementation'sbuildDialect()
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 aDialect
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.