org.hibernate.boot.model.relational.Namespace类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.hibernate.boot.model.relational.Namespace类的一些代码示例,展示了Namespace类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace类的具体详情如下:
包路径:org.hibernate.boot.model.relational.Namespace
类名称:Namespace

Namespace介绍

[英]Represents a namespace (named schema/catalog pair) with a Database and manages objects defined within.
[中]表示带有数据库的命名空间(命名架构/目录对),并管理其中定义的对象。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
public java.util.Collection<Table> collectTableMappings() {
  ArrayList<Table> tables = new ArrayList<>();
  for ( Namespace namespace : database.getNamespaces() ) {
    tables.addAll( namespace.getTables() );
  }
  return tables;
}

代码示例来源:origin: hibernate/hibernate-orm

public Namespace adjustDefaultNamespace(Identifier catalogName, Identifier schemaName) {
  final Namespace.Name name = new Namespace.Name( catalogName, schemaName );
  if ( implicitNamespace.getName().equals( name ) ) {
    return implicitNamespace;
  }
  Namespace namespace = namespaceMap.get( name );
  if ( namespace == null ) {
    namespace = makeNamespace( name );
  }
  implicitNamespace = namespace;
  return implicitNamespace;
}

代码示例来源:origin: hibernate/hibernate-orm

public Table(Namespace namespace, String subselect, boolean isAbstract) {
  this.catalog = namespace.getPhysicalName().getCatalog();
  this.schema = namespace.getPhysicalName().getSchema();
  this.subselect = subselect;
  this.isAbstract = isAbstract;
}

代码示例来源:origin: hibernate/hibernate-orm

if ( tryToCreateCatalogs || tryToCreateSchemas ) {
  if ( tryToCreateCatalogs ) {
    final Identifier catalogLogicalName = namespace.getName().getCatalog();
    final Identifier catalogPhysicalName = namespace.getPhysicalName().getCatalog();
      && namespace.getPhysicalName().getSchema() != null
      && !existingDatabase.schemaExists( namespace.getName() ) ) {
    applySqlStrings(
        false,
        dialect.getCreateSchemaCommand( namespace.getPhysicalName().getSchema().render( dialect ) ),
        formatter,
        options,

代码示例来源:origin: hibernate/hibernate-orm

protected void buildSequence(Database database) {
    final int sourceIncrementSize = getSourceIncrementSize();

    final Namespace namespace = database.locateNamespace(
        logicalQualifiedSequenceName.getCatalogName(),
        logicalQualifiedSequenceName.getSchemaName()
    );
    Sequence sequence = namespace.locateSequence( logicalQualifiedSequenceName.getObjectName() );
    if ( sequence != null ) {
      sequence.validate( initialValue, sourceIncrementSize );
    }
    else {
      sequence = namespace.createSequence( logicalQualifiedSequenceName.getObjectName(), initialValue, sourceIncrementSize );
    }

    this.sequenceName = database.getJdbcEnvironment().getQualifiedObjectNameFormatter().format(
        sequence.getName(),
        database.getJdbcEnvironment().getDialect()
    );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

for ( Table table : namespace.getTables() ) {
  if ( !table.isPhysicalTable() ) {
    continue;
for ( Sequence sequence : namespace.getSequences() ) {
  if ( !schemaFilter.includeSequence( sequence ) ) {
    continue;
  if ( tryToDropSchemas && namespace.getPhysicalName().getSchema() != null ) {
    applySqlStrings(
        dialect.getDropSchemaCommand(
            namespace.getPhysicalName().getSchema().render( dialect )
        ),
        formatter,
    final Identifier catalogLogicalName = namespace.getName().getCatalog();
    final Identifier catalogPhysicalName = namespace.getPhysicalName().getCatalog();

代码示例来源:origin: hibernate/hibernate-orm

tablesInformation.put( namespace, nameSpaceTablesInformation );
if ( schemaFilter.includeNamespace( namespace ) ) {
  for ( Sequence sequence : namespace.getSequences() ) {
    checkExportIdentifier( sequence, exportIdentifiers );
    final SequenceInformation sequenceInformation = existingDatabase.getSequenceInformation( sequence.getName() );
if ( schemaFilter.includeNamespace( namespace ) ) {
  final NameSpaceTablesInformation nameSpaceTablesInformation = tablesInformation.get( namespace );
  for ( Table table : namespace.getTables() ) {
    if ( schemaFilter.includeTable( table ) ) {
      final TableInformation tableInformation = nameSpaceTablesInformation.getTableInformation( table );

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testQualifiedNameSeparator() throws Exception {
  Namespace.Name namespaceName = new Namespace.Name(
      Identifier.toIdentifier( "DB1" ),
      Identifier.toIdentifier( "PUBLIC" )
  );
  String expectedName = null;
  for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
    if ( !namespace.getName().equals( namespaceName ) ) {
      continue;
    }
    assertEquals( 1, namespace.getTables().size() );
    expectedName = metadata().getDatabase().getJdbcEnvironment().getQualifiedObjectNameFormatter().format(
        namespace.getTables().iterator().next().getQualifiedTableName(),
        getDialect()
    );
  }
  assertNotNull( expectedName );
  SingleTableEntityPersister persister = (SingleTableEntityPersister) sessionFactory().getEntityPersister( Box.class.getName() );
  assertEquals( expectedName, persister.getTableName() );
}

代码示例来源:origin: hibernate/hibernate-orm

public void performValidation(
    Metadata metadata,
    DatabaseInformation databaseInformation,
    ExecutionOptions options,
    Dialect dialect) {
  for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) {
    if ( schemaFilter.includeNamespace( namespace ) ) {
      validateTables( metadata, databaseInformation, options, dialect, namespace );
    }
  }
  for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) {
    if ( schemaFilter.includeNamespace( namespace ) ) {
      for ( Sequence sequence : namespace.getSequences() ) {
        if ( schemaFilter.includeSequence( sequence ) ) {
          final SequenceInformation sequenceInformation = databaseInformation.getSequenceInformation(
              sequence.getName()
          );
          validateSequence( sequence, sequenceInformation );
        }
      }
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

ssr.getService( JdbcEnvironment.class ),
    new QualifiedNameImpl(
        namespace.getName(),
        Identifier.toIdentifier( "aSequence" )
    ),
);
sequenceStructure.registerExportables( database );
exportIdentifierSet.add( namespace.getSequences().iterator().next().getExportIdentifier() );
namespaceSize++;

代码示例来源:origin: hibernate/hibernate-orm

.locateSequence( Identifier.toIdentifier( "my_db_sequence" ) );
assertThat( sequence, notNullValue() );
final String[] sqlCreateStrings = new H2Dialect().getSequenceExporter().getSqlCreateStrings(

代码示例来源:origin: hibernate/hibernate-orm

final Identifier catalogLogicalName = namespace.getName().getCatalog();
    final Identifier catalogPhysicalName = namespace.getPhysicalName().getCatalog();
  if ( tryToCreateSchemas && namespace.getPhysicalName().getSchema() != null ) {
    applySqlStrings(
        dialect.getCreateSchemaCommand( namespace.getPhysicalName().getSchema().render( dialect ) ),
        formatter,
        options,
for ( Sequence sequence : namespace.getSequences() ) {
  if ( !schemaFilter.includeSequence( sequence ) ) {
    continue;
for ( Table table : namespace.getTables() ) {
  if ( !table.isPhysicalTable() ){
    continue;
for ( Table table : namespace.getTables() ) {
  if ( !table.isPhysicalTable() ){
    continue;
for ( Table table : namespace.getTables() ) {
  if ( !schemaFilter.includeTable( table ) ) {
    continue;

代码示例来源:origin: org.hibernate.ogm/hibernate-ogm-infinispan-remote

@Override
public void initializeSchema(SchemaDefinitionContext context) {
  ServiceRegistryImplementor serviceRegistry = context.getSessionFactory().getServiceRegistry();
  TypeTranslator typeTranslator = serviceRegistry.getService( TypeTranslator.class );
  OptionsService optionsService = serviceRegistry.getService( OptionsService.class );
  Map tableEntityTypeMapping = context.getTableEntityTypeMapping();
  InfinispanRemoteDatastoreProvider datastoreProvider = (InfinispanRemoteDatastoreProvider) serviceRegistry.getService( DatastoreProvider.class );
  String protobufPackageName = datastoreProvider.getProtobufPackageName();
  SchemaDefinitions sd = new SchemaDefinitions( protobufPackageName );
  HashSet<Sequence> sequences = new HashSet<>();
  for ( Namespace namespace : context.getDatabase().getNamespaces() ) {
    for ( Sequence sequence : namespace.getSequences() ) {
      sequences.add( sequence );
    }
    for ( Table table : namespace.getTables() ) {
      if ( table.isPhysicalTable() ) {
        createTableDefinition( context.getSessionFactory(), sd, table, typeTranslator, protobufPackageName,
          getCacheConfiguration( tableEntityTypeMapping, optionsService, table.getName() )
        );
      }
    }
  }
  for ( IdSourceKeyMetadata iddSourceKeyMetadata : context.getAllIdSourceKeyMetadata() ) {
    if ( !HotRodSequenceCounterHandler.isSequenceGeneratorId( iddSourceKeyMetadata ) ) {
      sd.createSequenceSchemaDefinition( iddSourceKeyMetadata, datastoreProvider.getProtobufPackageName() );
    }
  }
  datastoreProvider.registerSchemaDefinitions( sd, sequences );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-9936" )
public void testMultipleUsesOfDefaultSequenceName() {
  final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr )
      .addAnnotatedClass( Entity1.class )
      .addAnnotatedClass( Entity2.class )
      .buildMetadata();
  metadata.validate();
  assertEquals( 0, metadata.getDatabase().getAuxiliaryDatabaseObjects().size() );
  int count = 0;
  for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) {
    for ( Sequence sequence : namespace.getSequences() ) {
      count++;
    }
  }
  assertEquals( 1, count );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
  public void registerExportables(Database database) {
    final Namespace namespace = database.locateNamespace(
        logicalQualifiedSequenceName.getCatalogName(),
        logicalQualifiedSequenceName.getSchemaName()
    );
    Sequence sequence = namespace.locateSequence( logicalQualifiedSequenceName.getObjectName() );
    if ( sequence != null ) {
      sequence.validate( 1, 1 );
    }
    else {
      sequence = namespace.createSequence(
          logicalQualifiedSequenceName.getObjectName(),
          1,
          1
      );
    }

    final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment();
    final Dialect dialect = jdbcEnvironment.getDialect();

    this.sequenceName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
        sequence.getName(),
        dialect
    );
    this.sql = jdbcEnvironment.getDialect().getSequenceNextValString( sequenceName );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

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 );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public java.util.Collection<Table> collectTableMappings() {
  ArrayList<Table> tables = new ArrayList<>();
  for ( Namespace namespace : getDatabase().getNamespaces() ) {
    tables.addAll( namespace.getTables() );
  }
  return tables;
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
@TestForIssue( jiraKey = "HHH-9936" )
public void testMultipleUsesOfExplicitSequenceName() {
  final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr )
      .addAnnotatedClass( Entity3.class )
      .addAnnotatedClass( Entity4.class )
      .buildMetadata();
  metadata.validate();
  assertEquals( 0, metadata.getDatabase().getAuxiliaryDatabaseObjects().size() );
  int count = 0;
  for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) {
    for ( Sequence sequence : namespace.getSequences() ) {
      count++;
    }
  }
  assertEquals( 1, count );
}

代码示例来源:origin: hibernate/hibernate-orm

public Settings(SessionFactoryOptions sessionFactoryOptions, Metadata metadata) {
  this(
      sessionFactoryOptions,
      extractName( metadata.getDatabase().getDefaultNamespace().getName().getCatalog() ),
      extractName( metadata.getDatabase().getDefaultNamespace().getName().getSchema() )
  );
}

代码示例来源:origin: hibernate/hibernate-orm

public Table(
    Namespace namespace,
    Identifier physicalTableName,
    boolean isAbstract) {
  this.catalog = namespace.getPhysicalName().getCatalog();
  this.schema = namespace.getPhysicalName().getSchema();
  this.name = physicalTableName;
  this.isAbstract = isAbstract;
}

相关文章