@Override public Identifier getTableName() { return table.getNameIdentifier(); }
@Override public Identifier getTableName() { return table.getNameIdentifier(); }
@Override public Identifier getTableName() { return table.getNameIdentifier(); }
@Override public void addTableNameBinding(Identifier logicalName, Table table) { logicalToPhysicalTableNameMap.put( logicalName, table.getNameIdentifier() ); physicalToLogicalTableNameMap.put( table.getNameIdentifier(), logicalName ); }
@Override public Identifier getTableName() { return entityBinding.getTable().getNameIdentifier(); }
@Override public Identifier getReferencedTableName() { return fk.getReferencedTable().getNameIdentifier(); }
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; } };
@Override public Identifier getOwningPhysicalTableName() { return collectionBinding.getOwner().getTable().getNameIdentifier(); }
@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(); }
protected String getTableNameForLogging(Column column) { if ( getTable() != null ) { if ( getTable().getNameIdentifier() != null ) { return getTable().getNameIdentifier().getCanonicalName(); } else { return "<unknown>"; } } else if ( column.getValue() != null && column.getValue().getTable() != null ) { return column.getValue().getTable().getNameIdentifier().getCanonicalName(); } return "<unknown>"; }
public void addColumn(Column column) { Column old = getColumn( column ); if ( old == null ) { if ( primaryKey != null ) { for ( Column c : primaryKey.getColumns() ) { if ( c.getCanonicalName().equals( column.getCanonicalName() ) ) { column.setNullable( false ); log.debugf( "Forcing column [%s] to be non-null as it is part of the primary key for table [%s]", column.getCanonicalName(), getNameIdentifier().getCanonicalName() ); } } } this.columns.put( column.getCanonicalName(), column ); column.uniqueInteger = this.columns.size(); } else { column.uniqueInteger = old.uniqueInteger; } }
@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() }; } }
Identifier.toIdentifier( table.getCatalog(), table.isCatalogQuoted() ), Identifier.toIdentifier( table.getSchema(), table.isSchemaQuoted() ), table.getNameIdentifier() );
@SuppressWarnings("unchecked") private void validateIndexSpecsForUniqueColumns(Table table, IndexOptions indexOptions, Set<String> forIndexNotReferenced, UniqueConstraintSchemaUpdateStrategy constraintMethod) { Iterator<Column> columnIterator = table.getColumnIterator(); while ( columnIterator.hasNext() ) { Column column = columnIterator.next(); if ( column.isUnique() ) { String indexName = NamingHelper.INSTANCE.generateHashedConstraintName( "UK_", table.getNameIdentifier(), Identifier.toIdentifier( column.getName() ) ); forIndexNotReferenced.remove( indexName ); if ( constraintMethod != UniqueConstraintSchemaUpdateStrategy.SKIP ) { MongoDBIndexSpec indexSpec = new MongoDBIndexSpec( table.getName(), column.getName(), indexName, getIndexOptionDocument( table, indexOptions.getOptionForIndex( indexName ) ) ); if ( validateIndexSpec( indexSpec ) ) { indexSpecs.add( indexSpec ); } } } } }
@SuppressWarnings("unchecked") private void validateIndexSpecsForUniqueColumns(Table table, IndexOptions indexOptions, Set<String> forIndexNotReferenced, UniqueConstraintSchemaUpdateStrategy constraintMethod) { Iterator<Column> columnIterator = table.getColumnIterator(); while ( columnIterator.hasNext() ) { Column column = columnIterator.next(); if ( column.isUnique() ) { String indexName = NamingHelper.INSTANCE.generateHashedConstraintName( "UK_", table.getNameIdentifier(), Identifier.toIdentifier( column.getName() ) ); forIndexNotReferenced.remove( indexName ); if ( constraintMethod != UniqueConstraintSchemaUpdateStrategy.SKIP ) { MongoDBIndexSpec indexSpec = new MongoDBIndexSpec( table.getName(), column.getName(), indexName, getIndexOptionDocument( table, indexOptions.getOptionForIndex( indexName ) ) ); if ( validateIndexSpec( indexSpec ) ) { indexSpecs.add( indexSpec ); } } } } }
"Forcing column [%s] to be non-null as it is part of the primary key for table [%s]", column.getCanonicalName(), getNameIdentifier().getCanonicalName() );