Refine search![Refine arrow](//d16xvuom8mr9m8.cloudfront.net/code/public/images/refine-arrow.226bef887e7b1c430d6d498717d9d561.svg)
public static Identifier quote(Identifier identifier) { return identifier.isQuoted() ? identifier : Identifier.toIdentifier( identifier.getText(), true ); }
public void setQuoted(boolean quoted) { if ( quoted == name.isQuoted() ) { return; } this.name = new Identifier( name.getText(), quoted ); }
@Override public String getLogicalTableName(Table ownerTable) { final Identifier logicalName = physicalToLogicalTableNameMap.get( ownerTable.getNameIdentifier() ); if ( logicalName == null ) { throw new MappingException( "Unable to find physical table: " + ownerTable.getName() ); } return logicalName.render(); }
@Override public Identifier normalizeQuoting(Identifier identifier) { Identifier normalizedIdentifier = this.helper.normalizeQuoting( identifier ); if ( normalizedIdentifier == null ) { return null; } // need to quote names containing special characters like ':' if ( !normalizedIdentifier.isQuoted() && !normalizedIdentifier.getText().matches( "\\w+" ) ) { normalizedIdentifier = Identifier.quote( normalizedIdentifier ); } return normalizedIdentifier; }
@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() }; } }
final String referencedTable = foreignKey.getReferencedTable().getName(); String existingReferencingColumn = m.getReferencingColumnMetadata().getColumnIdentifier().getText(); String existingReferencedTable = m.getReferencedColumnMetadata().getContainingTableInformation().getName().getTableName().getCanonicalName(); return referencingColumn.equals( existingReferencingColumn ) && referencedTable.equals( existingReferencedTable ); }; return tableInformation.getForeignKey( Identifier.toIdentifier( foreignKey.getName() ) ) != null;
@Override public void addSecondaryTable(QualifiedTableName logicalQualifiedTableName, Join secondaryTableJoin) { Identifier logicalName = logicalQualifiedTableName.getTableName(); if ( Identifier.areEqual( Identifier.toIdentifier( new QualifiedTableName( Identifier.toIdentifier( primaryTable.getCatalog() ), Identifier.toIdentifier( primaryTable.getSchema() ), primaryTableLogicalName ).render() ), Identifier.toIdentifier( logicalQualifiedTableName.render() ) ) ) { throw new DuplicateSecondaryTableException( logicalName ); } if ( secondaryTableJoinMap == null ) { //secondaryTableJoinMap = new HashMap<Identifier,Join>(); //secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); secondaryTableJoinMap = new HashMap<>(); secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); } else { //final Join existing = secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); final Join existing = secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); if ( existing != null ) { throw new DuplicateSecondaryTableException( logicalName ); } } }
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( new QualifiedTableName( catalog != null ? catalog : defaultCatalog, .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); final ColumnInformation columnInfo = tableInfo.getColumn( Identifier.toIdentifier( column.getName(), column.isQuoted() ) ); UniqueKey uk = getOrCreateUniqueKey( keyName ); uk.addColumn( column ); alter.append( dialect.getUniqueDelegate() log.debugf( "No alter strings for table : %s", getQuotedName() );
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { return Identifier.toIdentifier( "TAB_" + name.getText() ); } }
@Override public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) { final LinkedList<String> parts = splitAndReplace( name.getText() ); // Acme Corp says all sequences should end with _seq if ( !"seq".equalsIgnoreCase( parts.getLast() ) ) { parts.add( "seq" ); } return jdbcEnvironment.getIdentifierHelper().toIdentifier( join( parts ), name.isQuoted() ); }
@Override public String getLogicalColumnName(Table table, Identifier physicalName) throws MappingException { final String physicalNameString = physicalName.render( getDatabase().getJdbcEnvironment().getDialect() ); Identifier logicalName = null; Table currentTable = table; while ( currentTable != null ) { final TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable ); if ( binding != null ) { logicalName = binding.physicalToLogical.get( physicalNameString ); if ( logicalName != null ) { break; } } if ( DenormalizedTable.class.isInstance( currentTable ) ) { currentTable = ( (DenormalizedTable) currentTable ).getIncludedTable(); } else { currentTable = null; } } if ( logicalName == null ) { throw new MappingException( "Unable to find column with physical name " + physicalNameString + " in table " + table.getName() ); } return logicalName.render(); }
protected String determineIdTableName(Queryable persister) { String qualifiedTableName = jdbcEnvironment.getIdentifierHelper().applyGlobalQuoting( "HT_" + StringHelper.unquote( persister.getTableName(), jdbcEnvironment.getDialect() ) ).render(); return jdbcEnvironment.getQualifiedObjectNameFormatter().format( new QualifiedTableName( Identifier.toIdentifier( catalog ), Identifier.toIdentifier( schema ), Identifier.toIdentifier( qualifiedTableName ) ), jdbcEnvironment.getDialect() ); }
@Override public String getPhysicalColumnName(Table table, Identifier logicalName) throws MappingException { if ( logicalName == null ) { throw new MappingException( "Logical column name cannot be null" ); } Table currentTable = table; String physicalName = null; while ( currentTable != null ) { final TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable ); if ( binding != null ) { physicalName = binding.logicalToPhysical.get( logicalName ); if ( physicalName != null ) { break; } } if ( DenormalizedTable.class.isInstance( currentTable ) ) { currentTable = ( (DenormalizedTable) currentTable ).getIncludedTable(); } else { currentTable = null; } } if ( physicalName == null ) { throw new MappingException( "Unable to find column with logical name " + logicalName.render() + " in table " + table.getName() ); } return physicalName; }
String.format( "Schema-validation: missing table [%s]", table.getQualifiedTableName().toString() final Iterator selectableItr = table.getColumnIterator(); while ( selectableItr.hasNext() ) { final Selectable selectable = (Selectable) selectableItr.next(); if ( Column.class.isInstance( selectable ) ) { final Column column = (Column) selectable; final ColumnInformation existingColumn = tableInformation.getColumn( Identifier.toIdentifier( column.getQuotedName() ) ); if ( existingColumn == null ) { throw new SchemaManagementException( "Schema-validation: missing column [%s] in table [%s]", column.getName(), table.getQualifiedTableName()
protected String determineSegmentColumnName(Properties params, JdbcEnvironment jdbcEnvironment) { final String name = ConfigurationHelper.getString( PK_COLUMN_NAME, params, DEFAULT_PK_COLUMN ); return jdbcEnvironment.getIdentifierHelper().toIdentifier( name ).render( jdbcEnvironment.getDialect() ); }
@Override public Identifier getUserProvidedIdentifier() { return originalKeyName != null ? Identifier.toIdentifier( originalKeyName ) : null; } }
@Override public void registerExportables(Database database) { final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); this.tableNameText = jdbcEnvironment.getQualifiedObjectNameFormatter().format( table.getQualifiedTableName(), dialect ); this.valueColumnNameText = logicalValueColumnNameIdentifier.render( dialect ); LongType.INSTANCE ); table.addColumn( valueColumn ); table.addInitCommand( new InitCommand( "insert into " + tableNameText + " values ( " + initialValue + " )" ) );
private String[] quoteTypeIfNecessary(org.hibernate.mapping.Table table, String[] strings, String prefix) { if ( table.getNameIdentifier() == null || table.getNameIdentifier().isQuoted() || !"type".equals( table.getNameIdentifier().getText().toLowerCase() ) ) { return strings; } Pattern createTableTypePattern = Pattern.compile( "(" + prefix + "\\s+)(" + table.getNameIdentifier().getText() + ")(.+)" ); Pattern commentOnTableTypePattern = Pattern.compile( "(comment\\s+on\\s+table\\s+)(" + table.getNameIdentifier().getText() + ")(.+)" ); for ( int i = 0; i < strings.length; i++ ) { Matcher createTableTypeMatcher = createTableTypePattern.matcher( strings[i] ); Matcher commentOnTableTypeMatcher = commentOnTableTypePattern.matcher( strings[i] ); if ( createTableTypeMatcher.matches() ) { strings[i] = createTableTypeMatcher.group( 1 ) + "\"TYPE\"" + createTableTypeMatcher.group( 3 ); } if ( commentOnTableTypeMatcher.matches() ) { strings[i] = commentOnTableTypeMatcher.group( 1 ) + "\"TYPE\"" + commentOnTableTypeMatcher.group( 3 ); } } return strings; } };
private Identifier apply(Identifier name, JdbcEnvironment jdbcEnvironment) { if (name == null) { return null; } StringBuilder builder = new StringBuilder(name.getText().replace('.', '_')); for (int i = 1; i < builder.length() - 1; i++) { if (isUnderscoreRequired(builder.charAt(i - 1), builder.charAt(i), builder.charAt(i + 1))) { builder.insert(i++, '_'); } } return getIdentifier(builder.toString(), name.isQuoted(), jdbcEnvironment); }