Java 类org.hibernate.boot.model.relational.Database 实例源码

项目:bootstrap    文件:ImplicitNamingStrategyNiceJpaImplTest.java   
private void mockContext(final ImplicitNameSource source) {
    final MetadataBuildingContext context = Mockito.mock(MetadataBuildingContext.class);
    final InFlightMetadataCollector collector = Mockito.mock(InFlightMetadataCollector.class);
    final Database database = Mockito.mock(Database.class);
    final JdbcEnvironment jdbcEnvironment = Mockito.mock(JdbcEnvironment.class);
    final IdentifierHelper identifierHelper = Mockito.mock(IdentifierHelper.class);
    Mockito.when(identifierHelper.toIdentifier(ArgumentMatchers.anyString())).then(new Answer<Identifier>() {

        @Override
        public Identifier answer(final InvocationOnMock invocation) {
            return DatabaseIdentifier.toIdentifier((String)invocation.getArguments()[0]) ;
        }
    });
    Mockito.when(jdbcEnvironment.getIdentifierHelper()).thenReturn(identifierHelper);
    Mockito.when(database.getJdbcEnvironment()).thenReturn(jdbcEnvironment);
    Mockito.when(collector.getDatabase()).thenReturn(database);
    Mockito.when(context.getMetadataCollector()).thenReturn(collector);
    Mockito.when(source.getBuildingContext()).thenReturn(context);
}
项目:hibernate-semantic-query    文件:OrmHelper.java   
private static void populateDatabaseModel(MetadataImplementor metadata, ExplicitSqmDomainMetamodel domainMetamodel) {
        final Database database = metadata.getDatabase();
        final DatabaseModelImpl databaseModel = (DatabaseModelImpl) domainMetamodel.getDatabaseModel();

        // todo : apply PhysicalNamingStrategy here, rather than as we create the "mapping model"?

        // todo : we need DatabaseModel to incorporate catalogs/schemas in some fashion
        //      either like org.hibernate.boot.model.relational.Database does
        //      or via catalogs/schemas-specific names
        for ( Namespace namespace : database.getNamespaces() ) {
            for ( Table mappingTable : namespace.getTables() ) {
                // todo : incorporate mapping Table's isAbstract indicator
                final org.hibernate.orm.persister.common.spi.Table table;
                if ( mappingTable instanceof DenormalizedTable ) {
                    // this is akin to a UnionSubclassTable
                    throw new NotYetImplementedException( "DenormalizedTable support not yet implemented" );
                }
                else if ( mappingTable.getSubselect() != null ) {
                    table = new DerivedTable( mappingTable.getSubselect() );
                }
                else {
//                  final JdbcEnvironment jdbcEnvironment = sessionFactory.getJdbcServices().getJdbcEnvironment();
//                  final String qualifiedTableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
//                          mappingTable.getQualifiedTableName(),
//                          jdbcEnvironment.getDialect()
//                  );
                    final String qualifiedTableName = mappingTable.getQualifiedTableName().render();
                    table = new PhysicalTable( qualifiedTableName );
                }

                databaseModel.registerTable( table );
            }
        }
    }
项目:spanner-hibernate    文件:CloudSpannerSchemaHandler.java   
private void addAuxiliaryDatabaseObjects(Database database)
{
    // Adding multiple times is a no-op
    database.addAuxiliaryDatabaseObject(SET);
    database.addAuxiliaryDatabaseObject(WAIT);
}
项目:high-performance-java-persistence    文件:MetadataExtractorIntegrator.java   
public Database getDatabase() {
    return database;
}