From f5bf5a5a55219463c79b00f0bb426d74309e0444 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:24:12 +0000 Subject: [PATCH 1/3] chore(deps): bump hibernate.version from 6.3.1.Final to 6.6.1.Final Bumps `hibernate.version` from 6.3.1.Final to 6.6.1.Final. Updates `org.hibernate.orm:hibernate-core` from 6.3.1.Final to 6.6.1.Final - [Release notes](https://github.com/hibernate/hibernate-orm/releases) - [Changelog](https://github.com/hibernate/hibernate-orm/blob/6.6.1/changelog.txt) - [Commits](https://github.com/hibernate/hibernate-orm/compare/6.3.1...6.6.1) Updates `org.hibernate.orm:hibernate-envers` from 6.3.1.Final to 6.6.1.Final - [Release notes](https://github.com/hibernate/hibernate-orm/releases) - [Changelog](https://github.com/hibernate/hibernate-orm/blob/6.6.1/changelog.txt) - [Commits](https://github.com/hibernate/hibernate-orm/compare/6.3.1...6.6.1) --- updated-dependencies: - dependency-name: org.hibernate.orm:hibernate-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.hibernate.orm:hibernate-envers dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8952f43e..a745a81a 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ - 6.3.1.Final + 6.6.1.Final 6.1.13 4.29.2 11 From 157279e30033687de467d247b9289f6bd956ed31 Mon Sep 17 00:00:00 2001 From: filipe Date: Tue, 8 Oct 2024 14:02:52 -0300 Subject: [PATCH 2/3] chore: code changes to make it work with Hibernate 6.6.1 --- .../ext/hibernate/database/HibernateDatabase.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java b/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java index 0f1136b9..237a446f 100644 --- a/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java +++ b/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java @@ -19,6 +19,7 @@ import org.hibernate.dialect.Dialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo; import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.ServiceRegistry; @@ -354,6 +355,11 @@ public boolean supportsAggressiveRelease() { return false; } + @Override + public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) { + return ConnectionProvider.super.getDatabaseConnectionInfo(dialect); + } + @Override public boolean isUnwrappableAs(Class unwrapType) { return false; @@ -375,12 +381,12 @@ public void releaseAnyConnection(Connection connection) throws SQLException { } @Override - public Connection getConnection(String tenantIdentifier) throws SQLException { + public Connection getConnection(Object o) throws SQLException { return getConnection(); } @Override - public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException { + public void releaseConnection(Object tenantIdentifier, Connection connection) throws SQLException { } } From 481d2d16bfc4656bfebec4294f18c73f203798f3 Mon Sep 17 00:00:00 2001 From: filipe Date: Tue, 8 Oct 2024 14:27:26 -0300 Subject: [PATCH 3/3] chore: code refactoring to make extension compatible with Hibernate 6.3x to 6.6.x --- .../database/HibernateClassicDatabase.java | 4 +- .../hibernate/database/HibernateDatabase.java | 60 +------------------ .../database/NoOpConnectionProvider.java | 53 ++++++++++++++++ .../NoOpMultiTenantConnectionProvider.java | 54 +++++++++++++++++ 4 files changed, 110 insertions(+), 61 deletions(-) create mode 100644 src/main/java/liquibase/ext/hibernate/database/NoOpConnectionProvider.java create mode 100644 src/main/java/liquibase/ext/hibernate/database/NoOpMultiTenantConnectionProvider.java diff --git a/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java b/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java index 02c6d0b7..eaa62df7 100644 --- a/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java +++ b/src/main/java/liquibase/ext/hibernate/database/HibernateClassicDatabase.java @@ -50,7 +50,7 @@ protected void configureSources(MetadataSources sources) throws DatabaseExceptio ServiceRegistry standardRegistry = configuration.getStandardServiceRegistryBuilder() .applySettings(config.getProperties()) .addService(ConnectionProvider.class, new NoOpConnectionProvider()) - .addService(MultiTenantConnectionProvider.class, new NoOpConnectionProvider()) + .addService(MultiTenantConnectionProvider.class, new NoOpMultiTenantConnectionProvider()) .build(); config.buildSessionFactory(standardRegistry); @@ -67,4 +67,4 @@ protected String getDefaultDatabaseProductName() { } -} \ No newline at end of file +} diff --git a/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java b/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java index 237a446f..a3d680cc 100644 --- a/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java +++ b/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java @@ -19,12 +19,9 @@ import org.hibernate.dialect.Dialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; -import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo; import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.ServiceRegistry; -import java.sql.Connection; -import java.sql.SQLException; import java.util.concurrent.atomic.AtomicReference; /** @@ -190,7 +187,7 @@ protected MetadataSources createMetadataSources() throws DatabaseException { .applySetting(AvailableSettings.DIALECT, dialect) .applySetting(HibernateDatabase.HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS, Boolean.FALSE.toString()) .addService(ConnectionProvider.class, new NoOpConnectionProvider()) - .addService(MultiTenantConnectionProvider.class, new NoOpConnectionProvider()) + .addService(MultiTenantConnectionProvider.class, new NoOpMultiTenantConnectionProvider()) .build(); return new MetadataSources(standardRegistry); @@ -335,59 +332,4 @@ public boolean supportsCatalogs() { return true; } - /** - * Used by hibernate to ensure no database access is performed. - */ - static class NoOpConnectionProvider implements ConnectionProvider, MultiTenantConnectionProvider { - - @Override - public Connection getConnection() throws SQLException { - throw new SQLException("No connection"); - } - - @Override - public void closeConnection(Connection conn) throws SQLException { - - } - - @Override - public boolean supportsAggressiveRelease() { - return false; - } - - @Override - public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) { - return ConnectionProvider.super.getDatabaseConnectionInfo(dialect); - } - - @Override - public boolean isUnwrappableAs(Class unwrapType) { - return false; - } - - @Override - public T unwrap(Class unwrapType) { - return null; - } - - @Override - public Connection getAnyConnection() throws SQLException { - return getConnection(); - } - - @Override - public void releaseAnyConnection(Connection connection) throws SQLException { - - } - - @Override - public Connection getConnection(Object o) throws SQLException { - return getConnection(); - } - - @Override - public void releaseConnection(Object tenantIdentifier, Connection connection) throws SQLException { - - } - } } diff --git a/src/main/java/liquibase/ext/hibernate/database/NoOpConnectionProvider.java b/src/main/java/liquibase/ext/hibernate/database/NoOpConnectionProvider.java new file mode 100644 index 00000000..e4096585 --- /dev/null +++ b/src/main/java/liquibase/ext/hibernate/database/NoOpConnectionProvider.java @@ -0,0 +1,53 @@ +package liquibase.ext.hibernate.database; + +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * Used by hibernate to ensure no database access is performed. + */ +class NoOpConnectionProvider implements ConnectionProvider { + + @Override + public Connection getConnection() throws SQLException { + throw new SQLException("No connection"); + } + + @Override + public void closeConnection(Connection conn) throws SQLException { + } + + @Override + public boolean supportsAggressiveRelease() { + return false; + } + + @Override + public boolean isUnwrappableAs(Class unwrapType) { + return false; + } + + @Override + public T unwrap(Class unwrapType) { + return null; + } + + + public Connection getConnection(String tenantIdentifier) throws SQLException { + return getConnection(); + } + + public Connection getConnection(Object o) throws SQLException { + return getConnection(); + } + + public void releaseConnection(Object tenantIdentifier, Connection connection) throws SQLException { + + } + + public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException { + + } +} diff --git a/src/main/java/liquibase/ext/hibernate/database/NoOpMultiTenantConnectionProvider.java b/src/main/java/liquibase/ext/hibernate/database/NoOpMultiTenantConnectionProvider.java new file mode 100644 index 00000000..f5dcb736 --- /dev/null +++ b/src/main/java/liquibase/ext/hibernate/database/NoOpMultiTenantConnectionProvider.java @@ -0,0 +1,54 @@ +package liquibase.ext.hibernate.database; + +import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * Used by hibernate to ensure no database access is performed. + */ +class NoOpMultiTenantConnectionProvider implements MultiTenantConnectionProvider { + + @Override + public boolean isUnwrappableAs(Class unwrapType) { + return false; + } + + @Override + public T unwrap(Class unwrapType) { + return null; + } + + @Override + public Connection getAnyConnection() throws SQLException { + return null; + } + + @Override + public void releaseAnyConnection(Connection connection) throws SQLException { + + } + + public Connection getConnection(String s) throws SQLException { + return null; + } + + public void releaseConnection(String s, Connection connection) throws SQLException { + + } + + public Connection getConnection(Object tenantIdentifier) throws SQLException { + return null; + } + + public void releaseConnection(Object tenantIdentifier, Connection connection) throws SQLException { + + } + + @Override + public boolean supportsAggressiveRelease() { + return false; + } + +}