Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.hibernate.dialect.unique.UniqueDelegate;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
Expand Down Expand Up @@ -693,6 +694,11 @@ public String[] getDropSchemaCommand(String schemaName) {
return new String[] { "" };
}

@Override
public NameQualifierSupport getNameQualifierSupport() {
return NameQualifierSupport.BOTH;
}

@Override
public boolean useCrossReferenceForeignKeys(){
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.community.dialect.InformixDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
Expand Down Expand Up @@ -313,12 +314,17 @@ public void createSchema_fromSessionFactory() {

@Test
@SkipForDialect(value = SQLServerDialect.class,
comment = "SQL Server and Sybase support catalogs but their implementation of DatabaseMetaData"
comment = "SQL Server support catalogs but their implementation of DatabaseMetaData"
+ " throws exceptions when calling getSchemas/getTables with a non-existing catalog,"
+ " which results in nasty errors when generating an update script"
+ " and some catalogs don't exist.")
@SkipForDialect(value = SybaseDialect.class,
comment = "SQL Server and Sybase support catalogs but their implementation of DatabaseMetaData"
comment = "Sybase support catalogs but their implementation of DatabaseMetaData"
+ " throws exceptions when calling getSchemas/getTables with a non-existing catalog,"
+ " which results in nasty errors when generating an update script"
+ " and some catalogs don't exist.")
@SkipForDialect(value = InformixDialect.class,
comment = "Informix support catalogs but their implementation of DatabaseMetaData"
+ " throws exceptions when calling getSchemas/getTables with a non-existing catalog,"
+ " which results in nasty errors when generating an update script"
+ " and some catalogs don't exist.")
Expand Down Expand Up @@ -775,8 +781,8 @@ String patternStringForNameWithDifferentQualifier(String patternStringForName) {
}

private String patternStringForQualifier() {
return ( catalog != null ? Pattern.quote( catalog + "." ) : "" )
+ ( schema != null ? Pattern.quote( schema + "." ) : "" );
return ( catalog != null ? Pattern.quote( catalog ) + "." : "" )
+ ( schema != null ? Pattern.quote( schema ) + "." : "" );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import java.util.Locale;

import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.QualifiedTypeName;
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.model.relational.internal.SqlStringGenerationContextImpl;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType;

Expand Down Expand Up @@ -64,17 +66,11 @@ public void testSecondaryTablesAreCreated() throws Exception {
}

private String getExpectedTableName(String tableName, String schema, String catalog) {
String expectedTableName = tableName;
NameQualifierSupport nameQualifierSupport = metadata.getDatabase()
.getJdbcEnvironment()
.getNameQualifierSupport();
if ( StringHelper.isNotEmpty( schema ) && nameQualifierSupport.supportsSchemas() ) {
expectedTableName = schema + "." + expectedTableName;
}
if ( StringHelper.isNotEmpty( catalog ) && nameQualifierSupport.supportsCatalogs() ) {
expectedTableName = catalog + "." + expectedTableName;
}
return expectedTableName;
SqlStringGenerationContext context = SqlStringGenerationContextImpl.forTests(
metadata.getDatabase().getJdbcEnvironment(), catalog, schema );
return context.format(
new QualifiedTypeName( Identifier.toIdentifier( catalog ), Identifier.toIdentifier( schema ),
Identifier.toIdentifier( tableName ) ) );
}

private boolean isTableCreated(
Expand Down
Loading