From aaba4767fe2842c442104dff0a377a0f63ecffdd Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 30 Aug 2021 17:45:57 +0200 Subject: [PATCH] Fix Sybase Connection#getSchema() throws an exception --- .../src/main/java/org/hibernate/dialect/SybaseDialect.java | 6 ++++++ .../extract/internal/AbstractInformationExtractorImpl.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java index 69bd38fc9d..d89cb14abc 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java @@ -13,6 +13,7 @@ import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy; import org.hibernate.engine.jdbc.env.spi.IdentifierHelper; import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder; +import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.query.CastType; @@ -287,4 +288,9 @@ public class SybaseDialect extends AbstractTransactSQLDialect { return super.buildIdentifierHelper( builder, dbMetaData ); } + @Override + public NameQualifierSupport getNameQualifierSupport() { + return NameQualifierSupport.CATALOG; + } + } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java index 33a489720b..e8434b78ef 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java @@ -406,6 +406,9 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt } private Identifier getCurrentSchema(JdbcEnvironment jdbcEnvironment) { + if ( jdbcEnvironment.getNameQualifierSupport() == NameQualifierSupport.CATALOG ) { + return null; + } if ( currentSchema != null ) { return currentSchema; } @@ -427,6 +430,9 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt } private Identifier getCurrentCatalog(JdbcEnvironment jdbcEnvironment) { + if ( jdbcEnvironment.getNameQualifierSupport() == NameQualifierSupport.SCHEMA ) { + return null; + } if ( currentCatalog != null ) { return currentCatalog; }