@Override public String[] getSqlCreateStrings(Table table, Metadata metadata) { final QualifiedName tableName = new QualifiedNameParser.NameParts( Identifier.toIdentifier( table.getCatalog(), table.isCatalogQuoted() ), Identifier.toIdentifier( table.getSchema(), table.isSchemaQuoted() ),
@Override @SuppressWarnings("SimplifiableIfStatement") public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } NameParts that = (NameParts) o; return Objects.equals( this.getCatalogName(), that.getCatalogName() ) && Objects.equals( this.getSchemaName(), that.getSchemaName() ) && Objects.equals( this.getObjectName(), that.getObjectName() ); }
return new QualifiedNameParser.NameParts( null, null,
@Override protected QualifiedName determineSequenceName(Properties params, Dialect dialect, JdbcEnvironment jdbcEnv, ServiceRegistry serviceRegistry) { String tableName = ConfigurationHelper.getString(CONFIG_TARGET_TABLE, params); if (null == tableName) { return super.determineSequenceName(params, dialect, jdbcEnv, serviceRegistry); } else { Identifier catalog = jdbcEnv.getIdentifierHelper() .toIdentifier(ConfigurationHelper.getString(CATALOG, params)); Identifier schema = jdbcEnv.getIdentifierHelper() .toIdentifier(ConfigurationHelper.getString(SCHEMA, params)); return new QualifiedNameParser.NameParts(catalog, schema, jdbcEnv.getIdentifierHelper().toIdentifier(tableName.toUpperCase() + DEF_SEQUENCE_SUFFIX)); } }
@Override protected QualifiedName determineSequenceName(Properties params, Dialect dialect, JdbcEnvironment jdbcEnv, ServiceRegistry serviceRegistry) { String tableName = ConfigurationHelper.getString(CONFIG_TARGET_TABLE, params); if (null == tableName) { return super.determineSequenceName(params, dialect, jdbcEnv, serviceRegistry); } else { Identifier catalog = jdbcEnv.getIdentifierHelper() .toIdentifier(ConfigurationHelper.getString(CATALOG, params)); Identifier schema = jdbcEnv.getIdentifierHelper() .toIdentifier(ConfigurationHelper.getString(SCHEMA, params)); return new QualifiedNameParser.NameParts(catalog, schema, jdbcEnv.getIdentifierHelper().toIdentifier(tableName.toUpperCase() + DEF_SEQUENCE_SUFFIX)); } }
return new NameParts( Identifier.toIdentifier( catalogName, wasQuotedInEntirety||catalogWasQuoted ), Identifier.toIdentifier( schemaName, wasQuotedInEntirety||schemaWasQuoted ),
ConfigurationHelper.getString( SCHEMA, params ) ); return new QualifiedNameParser.NameParts( catalog, schema,
ConfigurationHelper.getString( SCHEMA, params ) ); return new QualifiedNameParser.NameParts( catalog, schema,
protected QualifiedName determineGeneratorTableName(Properties params, JdbcEnvironment jdbcEnvironment) { final String tableName = ConfigurationHelper.getString( ID_TABLE, params, DEFAULT_TABLE ); if ( tableName.contains( "." ) ) { return QualifiedNameParser.INSTANCE.parse( tableName ); } else { // todo : need to incorporate implicit catalog and schema names final Identifier catalog = jdbcEnvironment.getIdentifierHelper().toIdentifier( ConfigurationHelper.getString( CATALOG, params ) ); final Identifier schema = jdbcEnvironment.getIdentifierHelper().toIdentifier( ConfigurationHelper.getString( SCHEMA, params ) ); return new QualifiedNameParser.NameParts( catalog, schema, jdbcEnvironment.getIdentifierHelper().toIdentifier( tableName ) ); } }
@Override public String[] getSqlDropStrings(Table table, Metadata metadata) { StringBuilder buf = new StringBuilder( "drop table " ); if ( dialect.supportsIfExistsBeforeTableName() ) { buf.append( "if exists " ); } final QualifiedName tableName = new QualifiedNameParser.NameParts( Identifier.toIdentifier( table.getCatalog(), table.isCatalogQuoted() ), Identifier.toIdentifier( table.getSchema(), table.isSchemaQuoted() ), table.getNameIdentifier() ); final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); buf.append( jdbcEnvironment.getQualifiedObjectNameFormatter().format( tableName, jdbcEnvironment.getDialect() ) ) .append( dialect.getCascadeConstraintsString() ); if ( dialect.supportsIfExistsAfterTableName() ) { buf.append( " if exists" ); } return new String[] { buf.toString() }; } }
@Override public int hashCode() { int result = getCatalogName() != null ? getCatalogName().hashCode() : 0; result = 31 * result + ( getSchemaName() != null ? getSchemaName().hashCode() : 0); result = 31 * result + getObjectName().hashCode(); return result; } }