mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-25 21:04:51 +00:00
HHH-11455 - Do not use schema name when underlying database doesn't support It
Use JDBC Environment to get the qualified name of the table, instead of directly appending schema name when it is defined explicitly.
This commit is contained in:
parent
517fc4c242
commit
a38ea758e3
@ -17,12 +17,14 @@
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.boot.model.relational.Exportable;
|
||||
import org.hibernate.boot.model.relational.InitCommand;
|
||||
import org.hibernate.boot.model.relational.Namespace;
|
||||
import org.hibernate.boot.model.relational.QualifiedTableName;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.engine.jdbc.env.spi.QualifiedObjectNameFormatter;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
@ -438,13 +440,20 @@ public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tabl
|
||||
|
||||
public Iterator sqlAlterStrings(
|
||||
Dialect dialect,
|
||||
Mapping p,
|
||||
Metadata metadata,
|
||||
TableInformation tableInfo,
|
||||
String defaultCatalog,
|
||||
String defaultSchema) throws HibernateException {
|
||||
|
||||
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
|
||||
|
||||
StringBuilder root = new StringBuilder( "alter table " )
|
||||
.append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
|
||||
.append(
|
||||
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
|
||||
tableInfo.getName(),
|
||||
dialect
|
||||
)
|
||||
)
|
||||
.append( ' ' )
|
||||
.append( dialect.getAddColumnString() );
|
||||
|
||||
@ -461,7 +470,7 @@ public Iterator sqlAlterStrings(
|
||||
.append( ' ' )
|
||||
.append( column.getQuotedName( dialect ) )
|
||||
.append( ' ' )
|
||||
.append( column.getSqlType( dialect, p ) );
|
||||
.append( column.getSqlType( dialect, metadata ) );
|
||||
|
||||
String defaultValue = column.getDefaultValue();
|
||||
if ( defaultValue != null ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user