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 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 0f1136b9..a3d680cc 100644 --- a/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java +++ b/src/main/java/liquibase/ext/hibernate/database/HibernateDatabase.java @@ -22,8 +22,6 @@ 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; /** @@ -189,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); @@ -334,54 +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 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(String tenantIdentifier) throws SQLException { - return getConnection(); - } - - @Override - public void releaseConnection(String 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; + } + +}