public Sequence createSequence(Identifier logicalName, int initialValue, int increment) { if ( sequences.containsKey( logicalName ) ) { throw new HibernateException( "Sequence was already registered with that name [" + logicalName.toString() + "]" ); } final Identifier physicalName = physicalNamingStrategy.toPhysicalSequenceName( logicalName, jdbcEnvironment ); Sequence sequence = new Sequence( this.physicalName.getCatalog(), this.physicalName.getSchema(), physicalName, initialValue, increment ); sequences.put( logicalName, sequence ); return sequence; }
@Override public boolean includeNamespace(Namespace namespace) { // exclude schema "the_catalog_2" Identifier identifier = namespace.getName().getCatalog(); return identifier == null || !"the_catalog_2".equals( identifier.getText() ); }
); if ( database.getDefaultNamespace().getPhysicalName().getCatalog() != null ) { params.setProperty( PersistentIdentifierGenerator.CATALOG, database.getDefaultNamespace().getPhysicalName().getCatalog().render( database.getDialect() ) );
if ( tryToCreateCatalogs || tryToCreateSchemas ) { if ( tryToCreateCatalogs ) { final Identifier catalogLogicalName = namespace.getName().getCatalog(); final Identifier catalogPhysicalName = namespace.getPhysicalName().getCatalog();
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 InformationExtractorJdbcDatabaseMetaDataImplTest buildInformationExtractorJdbcDatabaseMetaDataImplTest() throws SQLException { Database database = metadata.getDatabase(); final ConnectionProvider connectionProvider = ssr.getService( ConnectionProvider.class ); DatabaseInformation dbInfo = new DatabaseInformationImpl( ssr, database.getJdbcEnvironment(), new DdlTransactionIsolatorTestingImpl( ssr, new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess( connectionProvider ) ), database.getDefaultNamespace().getName() ); ExtractionContextImpl extractionContext = new ExtractionContextImpl( ssr, database.getJdbcEnvironment(), ssr.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess(), (ExtractionContext.DatabaseObjectAccess) dbInfo, database.getDefaultNamespace().getPhysicalName().getCatalog(), database.getDefaultNamespace().getPhysicalName().getSchema() ); return new InformationExtractorJdbcDatabaseMetaDataImplTest( extractionContext ); }
protected void migrateTable( Table table, TableInformation tableInformation, Dialect dialect, Metadata metadata, Formatter formatter, ExecutionOptions options, GenerationTarget... targets) { final Database database = metadata.getDatabase(); //noinspection unchecked applySqlStrings( false, table.sqlAlterStrings( dialect, metadata, tableInformation, database.getDefaultNamespace().getPhysicalName().getCatalog(), database.getDefaultNamespace().getPhysicalName().getSchema() ), formatter, options, targets ); }
public DatabaseInformationImpl( ServiceRegistry serviceRegistry, JdbcEnvironment jdbcEnvironment, DdlTransactionIsolator ddlTransactionIsolator, Namespace.Name defaultNamespace) throws SQLException { this.jdbcEnvironment = jdbcEnvironment; this.extractionContext = new ImprovedExtractionContextImpl( serviceRegistry, jdbcEnvironment, ddlTransactionIsolator, defaultNamespace.getCatalog(), defaultNamespace.getSchema(), this ); // todo : make this pluggable this.extractor = new InformationExtractorJdbcDatabaseMetaDataImpl( extractionContext ); // because we do not have defined a way to locate sequence info by name initializeSequences(); }
public Namespace(PhysicalNamingStrategy physicalNamingStrategy, JdbcEnvironment jdbcEnvironment, Name name) { this.physicalNamingStrategy = physicalNamingStrategy; this.jdbcEnvironment = jdbcEnvironment; this.name = name; this.physicalName = new Name( physicalNamingStrategy .toPhysicalCatalogName( name.getCatalog(), jdbcEnvironment ), physicalNamingStrategy .toPhysicalSchemaName( name.getSchema(), jdbcEnvironment ) ); log.debugf( "Created database namespace [logicalName=%s, physicalName=%s]", name.toString(), physicalName.toString() ); }
private static class AssociationTableNameSource implements ObjectNameSource { private final String explicitName; private final String logicalName; private AssociationTableNameSource(String explicitName, String logicalName) { this.explicitName = explicitName; this.logicalName = logicalName; } public String getExplicitName() { return explicitName; } public String getLogicalName() { return logicalName; } }
@Override public NameSpaceTablesInformation getTablesInformation(Namespace namespace) { return extractor.getTables( namespace.getPhysicalName().getCatalog(), namespace.getPhysicalName().getSchema() ); }
@Override public boolean schemaExists(Namespace.Name namespace) { return extractor.schemaExists( namespace.getCatalog(), namespace.getSchema() ); }
public SimpleAuxiliaryDatabaseObject( Namespace namespace, String[] createStrings, String[] dropStrings, Set<String> dialectScopes) { this( dialectScopes, extractName( namespace.getPhysicalName().getCatalog() ), extractName( namespace.getPhysicalName().getSchema() ), createStrings, dropStrings ); }
private Identifier determineCatalogName(TableSpecificationSource tableSpecSource) { if ( StringHelper.isNotEmpty( tableSpecSource.getExplicitCatalogName() ) ) { return database.toIdentifier( tableSpecSource.getExplicitCatalogName() ); } else { return database.getDefaultNamespace().getName().getCatalog(); } }
public QualifiedNameImpl(Namespace.Name schemaName, Identifier objectName) { this( schemaName.getCatalog(), schemaName.getSchema(), objectName ); }
public Table(Namespace namespace, Identifier physicalTableName, String subselect, boolean isAbstract) { this.catalog = namespace.getPhysicalName().getCatalog(); this.schema = namespace.getPhysicalName().getSchema(); this.name = physicalTableName; this.subselect = subselect; this.isAbstract = isAbstract; }
public Table( Namespace namespace, Identifier physicalTableName, boolean isAbstract) { this.catalog = namespace.getPhysicalName().getCatalog(); this.schema = namespace.getPhysicalName().getSchema(); this.name = physicalTableName; this.isAbstract = isAbstract; }
public Table(Namespace namespace, String subselect, boolean isAbstract) { this.catalog = namespace.getPhysicalName().getCatalog(); this.schema = namespace.getPhysicalName().getSchema(); this.subselect = subselect; this.isAbstract = isAbstract; }
public Settings(SessionFactoryOptions sessionFactoryOptions, Metadata metadata) { this( sessionFactoryOptions, extractName( metadata.getDatabase().getDefaultNamespace().getName().getCatalog() ), extractName( metadata.getDatabase().getDefaultNamespace().getName().getSchema() ) ); }
@Override public int compareTo(Name that) { // per Comparable, the incoming Name cannot be null. However, its catalog/schema might be // so we need to account for that. int catalogCheck = ComparableHelper.compare( this.getCatalog(), that.getCatalog() ); if ( catalogCheck != 0 ) { return catalogCheck; } return ComparableHelper.compare( this.getSchema(), that.getSchema() ); } }