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

Revert "use hibernate.temp.use_jdbc_metadata_defaults=false everywhere like for HibernateClassic" #621

Conversation

filipelautert
Copy link
Collaborator

Reverts #616 as per discussions in the same PR.

Copy link
Contributor

Label error: This PR is being prevented from merging because you have not added one of the labels: breakingChanges, newContributors, notableChanges, sdou, skipReleaseNotes, TypeBug, TypeEnhancement, TypeTest. You'll need to add it before this PR can be merged.

…e like for HibernateClassic (#616)"

This reverts commit 6bc8cff.
@filipelautert filipelautert force-pushed the revert-616-hibernate_temp_use_jdbc_metadata_defaults_everywhere branch from 7be3996 to 1de2e6c Compare November 15, 2023 19:26
@filipelautert filipelautert merged commit 074a72d into main Nov 15, 2023
7 of 9 checks passed
@jonenst
Copy link
Contributor

jonenst commented Dec 15, 2023

@filipelautert Hi filipe, so according to hibernate/hibernate-orm#7182 (comment) we should use hibernate.temp.use_jdbc_metadata_defaults=false for now

if you look at the code, using the latest hibernate versions (shaded in liquibase-hibernate 4.25.0), you see this structure:

if ( useJdbcMetadata( configurationValues ) ) {
   // getJdbcEnvironmentUsingJdbcMetadata
   try {
      //return values from connection.getMetaData() and stuff;
   }  catch {
     return getJdbcEnvironmentWithDefaults( configurationValues, registry, dialectFactory ); // right now we end up here
  }
} else if (
// explicitDialectConfiguration
isNotEmpty(explicitDatabaseVersion) || explicitDatabaseMajorVersion != null || explicitDatabaseMinorVersion != null )
			&& ( isNotEmpty(explicitDatabaseName) || isNotNullAndNotEmpty( configurationValues.get(AvailableSettings.DIALECT) ) )
) {
			// return from these values 
} else {
  return getJdbcEnvironmentWithDefaults( configurationValues, registry, dialectFactory );
}

So we get getJdbcEnvironmentWithDefaults from the trycatch. If we set metadataflse, we will get the same getJdbcEnvironmentWithDefaults from the else block, except if the user has provided enough configuration values, then they will be used (today they are ignored)

see https://github.com/hibernate/hibernate-orm/blob/67cdd0b28a6ea5732841fcc8f1b7e9631a36fea7/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java#L106

Cf the following stacktrace:

java.lang.UnsupportedOperationException: The application must supply JDBC connections
    at org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection (UserSuppliedConnectionProviderImpl.java:44)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection (JdbcEnvironmentInitiator.java:424)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork (JdbcIsolationDelegate.java:61)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata (JdbcEnvironmentInitiator.java:273)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService (JdbcEnvironmentInitiator.java:105)

In the future, when temp_jdbc_metadta is removed, the code will behave as when we set false today, ie if values are specified they are used.

In parallel, its a good thing and a new feature to verify that users can set all relevant properties (currently be Database Version (either full, or Major/Minor) and Database (Name or Dialect). So check that that they are correctly copied everywhere (I care mostly about SpringPackageDatabase). That would be a new feature not at all possible today with the current code (always uses jdbc and crash and fallbacks to defaults)

@jonenst
Copy link
Contributor

jonenst commented Dec 20, 2023

hi @filipelautert , so do you plan to unrevert this ?

@filipelautert
Copy link
Collaborator Author

Hi @jonenst ! The shaded hibernate on 4.25.0 was a bug (sorry) as we switched to a new parent pom that was shading everything by default. This has been fixed on 4.25.1 .
So thanks for chasing this down with upstream, so we can un-un revert your pr. Do you mind in opening a new PR for jonenst:hibernate_temp_use_jdbc_metadata_defaults_everywhere and tagging me on that? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants