@Override public void addTableNameBinding(String schema, String catalog, String logicalName, String realTableName, Table denormalizedSuperTable) { final Identifier logicalNameIdentifier = getDatabase().toIdentifier( logicalName ); final Identifier physicalNameIdentifier = getDatabase().toIdentifier( realTableName ); logicalToPhysicalTableNameMap.put( logicalNameIdentifier, physicalNameIdentifier ); physicalToLogicalTableNameMap.put( physicalNameIdentifier, logicalNameIdentifier ); }
@Override public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) { getDatabase().addAuxiliaryDatabaseObject( auxiliaryDatabaseObject ); }
@Override public java.util.Collection<Table> collectTableMappings() { ArrayList<Table> tables = new ArrayList<>(); for ( Namespace namespace : getDatabase().getNamespaces() ) { tables.addAll( namespace.getTables() ); } return tables; }
private List<Identifier> toIdentifiers(String[] names) { if ( names == null ) { return Collections.emptyList(); } final List<Identifier> columnNames = CollectionHelper.arrayList( names.length ); for ( String name : names ) { columnNames.add( getDatabase().toIdentifier( name ) ); } return columnNames; }
@SuppressWarnings("unchecked") private List<Identifier> extractColumnNames(List columns) { if ( columns == null || columns.isEmpty() ) { return Collections.emptyList(); } final List<Identifier> columnNames = CollectionHelper.arrayList( columns.size() ); for ( Column column : (List<Column>) columns ) { columnNames.add( getDatabase().toIdentifier( column.getQuotedName() ) ); } return columnNames; }
@Override public void addColumnNameBinding(Table table, String logicalName, Column column) throws DuplicateMappingException { addColumnNameBinding( table, getDatabase().toIdentifier( logicalName ), column ); }
@Override public String getLogicalColumnName(Table table, String physicalName) throws MappingException { return getLogicalColumnName( table, getDatabase().toIdentifier( physicalName ) ); }
@Override public String getPhysicalTableName(String logicalName) { return getPhysicalTableName( getDatabase().toIdentifier( logicalName ) ); }
@Override public String getPhysicalColumnName(Table table, String logicalName) throws MappingException { return getPhysicalColumnName( table, getDatabase().toIdentifier( logicalName ) ); }
public InFlightMetadataCollectorImpl( BootstrapContext bootstrapContext, MetadataBuildingOptions options) { this.bootstrapContext = bootstrapContext; this.uuid = UUID.randomUUID(); this.options = options; this.identifierGeneratorFactory = options.getServiceRegistry() .getService( MutableIdentifierGeneratorFactory.class ); for ( Map.Entry<String, SQLFunction> sqlFunctionEntry : bootstrapContext.getSqlFunctions().entrySet() ) { if ( sqlFunctionMap == null ) { // we need this to be a ConcurrentHashMap for the one we ultimately pass along to the SF // but is this the reference that gets passed along? sqlFunctionMap = new ConcurrentHashMap<>( 16, .75f, 1 ); } sqlFunctionMap.put( sqlFunctionEntry.getKey(), sqlFunctionEntry.getValue() ); } bootstrapContext.getAuxiliaryDatabaseObjectList().forEach( getDatabase()::addAuxiliaryDatabaseObject ); }
String subselectFragment, boolean isAbstract) { final Namespace namespace = getDatabase().locateNamespace( getDatabase().toIdentifier( catalogName ), getDatabase().toIdentifier( schemaName ) ); logicalName = getDatabase().toIdentifier( name );
String subselectFragment, Table includedTable) throws DuplicateMappingException { final Namespace namespace = getDatabase().locateNamespace( getDatabase().toIdentifier( catalogName ), getDatabase().toIdentifier( schemaName ) ); logicalName = getDatabase().toIdentifier( name );
public void addBinding(Identifier logicalName, Column physicalColumn) { final String physicalNameString = physicalColumn.getQuotedName( getDatabase().getJdbcEnvironment().getDialect() ); bindLogicalToPhysical( logicalName, physicalNameString ); bindPhysicalToLogical( logicalName, physicalNameString ); }
@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(); }
private void processExportableProducers() { // for now we only handle id generators as ExportableProducers final Dialect dialect = getDatabase().getJdbcEnvironment().getDialect(); final String defaultCatalog = extractName( getDatabase().getDefaultNamespace().getName().getCatalog(), dialect ); final String defaultSchema = extractName( getDatabase().getDefaultNamespace().getName().getSchema(), dialect ); for ( PersistentClass entityBinding : entityBindingMap.values() ) { if ( entityBinding.isInherited() ) { continue; } handleIdentifierValueBinding( entityBinding.getIdentifier(), dialect, defaultCatalog, defaultSchema, (RootClass) entityBinding ); } for ( Collection collection : collectionBindingMap.values() ) { if ( !IdentifierCollection.class.isInstance( collection ) ) { continue; } handleIdentifierValueBinding( ( (IdentifierCollection) collection ).getIdentifier(), dialect, defaultCatalog, defaultSchema, null ); } }
private void handleIdentifierValueBinding( KeyValue identifierValueBinding, Dialect dialect, String defaultCatalog, String defaultSchema, RootClass entityBinding) { // todo : store this result (back into the entity or into the KeyValue, maybe?) // This process of instantiating the id-generator is called multiple times. // It was done this way in the old code too, so no "regression" here; but // it could be done better try { final IdentifierGenerator ig = identifierValueBinding.createIdentifierGenerator( getIdentifierGeneratorFactory(), dialect, defaultCatalog, defaultSchema, entityBinding ); if ( ig instanceof ExportableProducer ) { ( (ExportableProducer) ig ).registerExportables( getDatabase() ); } } catch (MappingException e) { // ignore this for now. The reasoning being "non-reflective" binding as needed // by tools. We want to hold off requiring classes being present until we // try to build a SF. Here, just building the Metadata, it is "ok" for an // exception to occur, the same exception will happen later as we build the SF. log.debugf( "Ignoring exception thrown when trying to build IdentifierGenerator as part of Metadata building", e ); } }
keyName = keyNameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() ); keyName = keyNameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() );
namedEntityGraphMap, sqlFunctionMap, getDatabase(), bootstrapContext );
fk.setName( nameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() ) );
private List<Identifier> toIdentifiers(String[] names) { if ( names == null ) { return Collections.emptyList(); } final List<Identifier> columnNames = CollectionHelper.arrayList( names.length ); for ( String name : names ) { columnNames.add( getDatabase().toIdentifier( name ) ); } return columnNames; }