public Table addDenormalizedTable( String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws DuplicateMappingException { name = getObjectNameNormalizer().normalizeIdentifierQuoting( name ); schema = getObjectNameNormalizer().normalizeIdentifierQuoting( schema ); catalog = getObjectNameNormalizer().normalizeIdentifierQuoting( catalog ); String key = subselect == null ? Table.qualify(catalog, schema, name) : subselect; if ( tables.containsKey( key ) ) { throw new DuplicateMappingException( "table", name ); } Table table = new DenormalizedTable( includedTable ); table.setAbstract( isAbstract ); table.setName( name ); table.setSchema( schema ); table.setCatalog( catalog ); table.setSubselect( subselect ); tables.put( key, table ); return table; }
public Table addDenormalizedTable( String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws MappingException { String key = subselect==null ? Table.qualify(catalog, schema, name) : subselect; if ( tables.containsKey(key) ) { throw new DuplicateMappingException("table", name); } Table table = new DenormalizedTable(includedTable); table.setAbstract(isAbstract); table.setName(name); table.setSchema(schema); table.setCatalog(catalog); table.setSubselect(subselect); tables.put(key, table); return table; }
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 ); } } }