Skip to content

Commit ff4774a

Browse files
committed
HHH-9974 - Rename org.hibernate.boot.model.relational.Schema to Namespace
1 parent 333e404 commit ff4774a

33 files changed

+188
-182
lines changed

hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
4545
import org.hibernate.boot.model.relational.Database;
4646
import org.hibernate.boot.model.relational.ExportableProducer;
47-
import org.hibernate.boot.model.relational.Schema;
47+
import org.hibernate.boot.model.relational.Namespace;
4848
import org.hibernate.boot.model.source.internal.ConstraintSecondPass;
4949
import org.hibernate.boot.model.source.internal.ImplicitColumnNamingSecondPass;
5050
import org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext;
@@ -461,8 +461,8 @@ public IdentifierGeneratorDefinition getIdentifierGenerator(String name) {
461461
@Override
462462
public java.util.Collection<Table> collectTableMappings() {
463463
ArrayList<Table> tables = new ArrayList<Table>();
464-
for ( Schema schema : getDatabase().getSchemas() ) {
465-
tables.addAll( schema.getTables() );
464+
for ( Namespace namespace : getDatabase().getNamespaces() ) {
465+
tables.addAll( namespace.getTables() );
466466
}
467467
return tables;
468468
}
@@ -723,7 +723,7 @@ public Table addTable(
723723
String name,
724724
String subselectFragment,
725725
boolean isAbstract) {
726-
final Schema schema = getDatabase().locateSchema(
726+
final Namespace namespace = getDatabase().locateNamespace(
727727
getDatabase().toIdentifier( catalogName ),
728728
getDatabase().toIdentifier( schemaName )
729729
);
@@ -739,17 +739,17 @@ public Table addTable(
739739
}
740740

741741
if ( subselectFragment != null ) {
742-
return new Table( schema, logicalName, subselectFragment, isAbstract );
742+
return new Table( namespace, logicalName, subselectFragment, isAbstract );
743743
}
744744
else {
745-
Table table = schema.locateTable( logicalName );
745+
Table table = namespace.locateTable( logicalName );
746746
if ( table != null ) {
747747
if ( !isAbstract ) {
748748
table.setAbstract( false );
749749
}
750750
return table;
751751
}
752-
return schema.createTable( logicalName, isAbstract );
752+
return namespace.createTable( logicalName, isAbstract );
753753
}
754754
}
755755

@@ -761,7 +761,7 @@ public Table addDenormalizedTable(
761761
boolean isAbstract,
762762
String subselectFragment,
763763
Table includedTable) throws DuplicateMappingException {
764-
final Schema schema = getDatabase().locateSchema(
764+
final Namespace namespace = getDatabase().locateNamespace(
765765
getDatabase().toIdentifier( catalogName ),
766766
getDatabase().toIdentifier( schemaName )
767767
);
@@ -777,15 +777,15 @@ public Table addDenormalizedTable(
777777
}
778778

779779
if ( subselectFragment != null ) {
780-
return new DenormalizedTable( schema, logicalName, subselectFragment, isAbstract, includedTable );
780+
return new DenormalizedTable( namespace, logicalName, subselectFragment, isAbstract, includedTable );
781781
}
782782
else {
783-
Table table = schema.locateTable( logicalName );
783+
Table table = namespace.locateTable( logicalName );
784784
if ( table != null ) {
785785
throw new DuplicateMappingException( DuplicateMappingException.Type.TABLE, logicalName.toString() );
786786
}
787787
else {
788-
table = schema.createDenormalizedTable( logicalName, isAbstract, includedTable );
788+
table = namespace.createDenormalizedTable( logicalName, isAbstract, includedTable );
789789
}
790790
return table;
791791
}
@@ -2191,8 +2191,8 @@ private void processExportableProducers(MetadataBuildingContext buildingContext)
21912191
// for now we only handle id generators as ExportableProducers
21922192

21932193
final Dialect dialect = getDatabase().getJdbcEnvironment().getDialect();
2194-
final String defaultCatalog = extractName( getDatabase().getDefaultSchema().getName().getCatalog(), dialect );
2195-
final String defaultSchema = extractName( getDatabase().getDefaultSchema().getName().getSchema(), dialect );
2194+
final String defaultCatalog = extractName( getDatabase().getDefaultNamespace().getName().getCatalog(), dialect );
2195+
final String defaultSchema = extractName( getDatabase().getDefaultNamespace().getName().getSchema(), dialect );
21962196

21972197
for ( PersistentClass entityBinding : entityBindingMap.values() ) {
21982198
if ( entityBinding.isInherited() ) {

hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
2424
import org.hibernate.boot.model.TypeDefinition;
2525
import org.hibernate.boot.model.relational.Database;
26-
import org.hibernate.boot.model.relational.Schema;
26+
import org.hibernate.boot.model.relational.Namespace;
2727
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
2828
import org.hibernate.boot.spi.MetadataBuildingOptions;
2929
import org.hibernate.boot.spi.MetadataImplementor;
@@ -293,8 +293,8 @@ public Map<String, SQLFunction> getSqlFunctionMap() {
293293
@Override
294294
public java.util.Collection<Table> collectTableMappings() {
295295
ArrayList<Table> tables = new ArrayList<Table>();
296-
for ( Schema schema : database.getSchemas() ) {
297-
tables.addAll( schema.getTables() );
296+
for ( Namespace namespace : database.getNamespaces() ) {
297+
tables.addAll( namespace.getTables() );
298298
}
299299
return tables;
300300
}

hibernate-core/src/main/java/org/hibernate/boot/model/relational/Database.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public class Database {
2929
private final MetadataBuildingOptions buildingOptions;
3030
private final JdbcEnvironment jdbcEnvironment;
3131

32-
private Schema implicitSchema;
32+
private Namespace implicitNamespace;
3333

34-
private final Map<Schema.Name,Schema> schemaMap = new TreeMap<Schema.Name, Schema>();
34+
private final Map<Namespace.Name,Namespace> namespaceMap = new TreeMap<Namespace.Name, Namespace>();
3535

3636
private List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjects;
3737
private List<InitCommand> initCommands;
@@ -47,8 +47,8 @@ public Database(MetadataBuildingOptions buildingOptions, JdbcEnvironment jdbcEnv
4747

4848
this.dialect = determineDialect( buildingOptions );
4949

50-
this.implicitSchema = makeSchema(
51-
new Schema.Name(
50+
this.implicitNamespace = makeNamespace(
51+
new Namespace.Name(
5252
toIdentifier( buildingOptions.getMappingDefaults().getImplicitCatalogName() ),
5353
toIdentifier( buildingOptions.getMappingDefaults().getImplicitSchemaName() )
5454
)
@@ -65,11 +65,11 @@ private static Dialect determineDialect(MetadataBuildingOptions buildingOptions)
6565
return new H2Dialect();
6666
}
6767

68-
private Schema makeSchema(Schema.Name name) {
69-
Schema schema;
70-
schema = new Schema( this, name );
71-
schemaMap.put( name, schema );
72-
return schema;
68+
private Namespace makeNamespace(Namespace.Name name) {
69+
Namespace namespace;
70+
namespace = new Namespace( this, name );
71+
namespaceMap.put( name, namespace );
72+
return namespace;
7373
}
7474

7575
public MetadataBuildingOptions getBuildingOptions() {
@@ -107,43 +107,43 @@ public PhysicalNamingStrategy getPhysicalNamingStrategy() {
107107
return getBuildingOptions().getPhysicalNamingStrategy();
108108
}
109109

110-
public Iterable<Schema> getSchemas() {
111-
return schemaMap.values();
110+
public Iterable<Namespace> getNamespaces() {
111+
return namespaceMap.values();
112112
}
113113

114-
public Schema getDefaultSchema() {
115-
return implicitSchema;
114+
public Namespace getDefaultNamespace() {
115+
return implicitNamespace;
116116
}
117117

118-
public Schema locateSchema(Identifier catalogName, Identifier schemaName) {
118+
public Namespace locateNamespace(Identifier catalogName, Identifier schemaName) {
119119
if ( catalogName == null && schemaName == null ) {
120-
return getDefaultSchema();
120+
return getDefaultNamespace();
121121
}
122122

123-
final Schema.Name name = new Schema.Name( catalogName, schemaName );
124-
Schema schema = schemaMap.get( name );
125-
if ( schema == null ) {
126-
schema = makeSchema( name );
123+
final Namespace.Name name = new Namespace.Name( catalogName, schemaName );
124+
Namespace namespace = namespaceMap.get( name );
125+
if ( namespace == null ) {
126+
namespace = makeNamespace( name );
127127
}
128-
return schema;
128+
return namespace;
129129
}
130130

131-
public Schema adjustDefaultSchema(Identifier catalogName, Identifier schemaName) {
132-
final Schema.Name name = new Schema.Name( catalogName, schemaName );
133-
if ( implicitSchema.getName().equals( name ) ) {
134-
return implicitSchema;
131+
public Namespace adjustDefaultNamespace(Identifier catalogName, Identifier schemaName) {
132+
final Namespace.Name name = new Namespace.Name( catalogName, schemaName );
133+
if ( implicitNamespace.getName().equals( name ) ) {
134+
return implicitNamespace;
135135
}
136136

137-
Schema schema = schemaMap.get( name );
138-
if ( schema == null ) {
139-
schema = makeSchema( name );
137+
Namespace namespace = namespaceMap.get( name );
138+
if ( namespace == null ) {
139+
namespace = makeNamespace( name );
140140
}
141-
implicitSchema = schema;
142-
return implicitSchema;
141+
implicitNamespace = namespace;
142+
return implicitNamespace;
143143
}
144144

145-
public Schema adjustDefaultSchema(String implicitCatalogName, String implicitSchemaName) {
146-
return adjustDefaultSchema( toIdentifier( implicitCatalogName ), toIdentifier( implicitSchemaName ) );
145+
public Namespace adjustDefaultNamespace(String implicitCatalogName, String implicitSchemaName) {
146+
return adjustDefaultNamespace( toIdentifier( implicitCatalogName ), toIdentifier( implicitSchemaName ) );
147147
}
148148

149149
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {

hibernate-core/src/main/java/org/hibernate/boot/model/relational/Schema.java renamed to hibernate-core/src/main/java/org/hibernate/boot/model/relational/Namespace.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,36 @@
1919
import org.hibernate.mapping.Table;
2020

2121
/**
22-
* Represents a named schema/catalog pair and manages objects defined within.
22+
* Represents a namespace (named schema/catalog pair) with a Database and manages objects defined within.
2323
*
2424
* @author Steve Ebersole
2525
*/
26-
public class Schema {
27-
private static final CoreMessageLogger log = CoreLogging.messageLogger( Schema.class );
26+
public class Namespace {
27+
private static final CoreMessageLogger log = CoreLogging.messageLogger( Namespace.class );
2828

2929
private final Database database;
3030
private final Name name;
31-
3231
private final Name physicalName;
3332

3433
private Map<Identifier, Table> tables = new TreeMap<Identifier, Table>();
3534
private Map<Identifier, Sequence> sequences = new TreeMap<Identifier, Sequence>();
3635

37-
public Schema(Database database, Name name) {
36+
public Namespace(Database database, Name name) {
3837
this.database = database;
3938
this.name = name;
4039

41-
final Identifier physicalCatalogIdentifier = database.getPhysicalNamingStrategy()
42-
.toPhysicalCatalogName( name.getCatalog(), database.getJdbcEnvironment() );
43-
final Identifier physicalSchemaIdentifier = database.getPhysicalNamingStrategy()
44-
.toPhysicalCatalogName( name.getSchema(), database.getJdbcEnvironment() );
45-
this.physicalName = new Name( physicalCatalogIdentifier, physicalSchemaIdentifier );
40+
this.physicalName = new Name(
41+
database.getPhysicalNamingStrategy()
42+
.toPhysicalCatalogName( name.getCatalog(), database.getJdbcEnvironment() ),
43+
database.getPhysicalNamingStrategy()
44+
.toPhysicalCatalogName( name.getSchema(), database.getJdbcEnvironment() )
45+
);
46+
47+
log.debugf(
48+
"Created database namespace [logicalName=%s, physicalName=%s]",
49+
name.toString(),
50+
physicalName.toString()
51+
);
4652
}
4753

4854
public Name getName() {
@@ -138,7 +144,7 @@ public boolean equals(Object o) {
138144
return false;
139145
}
140146

141-
final Schema that = (Schema) o;
147+
final Namespace that = (Namespace) o;
142148
return EqualsHelper.equals( this.name, that.name );
143149
}
144150

hibernate-core/src/main/java/org/hibernate/boot/model/relational/QualifiedNameImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @author Steve Ebersole
1313
*/
1414
public class QualifiedNameImpl extends QualifiedNameParser.NameParts implements QualifiedName {
15-
public QualifiedNameImpl(Schema.Name schemaName, Identifier objectName) {
15+
public QualifiedNameImpl(Namespace.Name schemaName, Identifier objectName) {
1616
this(
1717
schemaName.getCatalog(),
1818
schemaName.getSchema(),

hibernate-core/src/main/java/org/hibernate/boot/model/relational/QualifiedSequenceName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public QualifiedSequenceName(Identifier catalogName, Identifier schemaName, Iden
1616
super( catalogName, schemaName, sequenceName );
1717
}
1818

19-
public QualifiedSequenceName(Schema.Name schemaName, Identifier sequenceName) {
19+
public QualifiedSequenceName(Namespace.Name schemaName, Identifier sequenceName) {
2020
super( schemaName, sequenceName );
2121
}
2222

hibernate-core/src/main/java/org/hibernate/boot/model/relational/QualifiedTableName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public QualifiedTableName(Identifier catalogName, Identifier schemaName, Identif
1616
super( catalogName, schemaName, tableName );
1717
}
1818

19-
public QualifiedTableName(Schema.Name schemaName, Identifier tableName) {
19+
public QualifiedTableName(Namespace.Name schemaName, Identifier tableName) {
2020
super( schemaName, tableName );
2121
}
2222

hibernate-core/src/main/java/org/hibernate/boot/model/relational/SimpleAuxiliaryDatabaseObject.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@ public class SimpleAuxiliaryDatabaseObject extends AbstractAuxiliaryDatabaseObje
3232
private final String[] dropStrings;
3333

3434
public SimpleAuxiliaryDatabaseObject(
35-
Schema schema,
35+
Namespace namespace,
3636
String createString,
3737
String dropString,
3838
Set<String> dialectScopes) {
3939
this(
40-
schema,
40+
namespace,
4141
new String[] { createString },
4242
new String[] { dropString },
4343
dialectScopes
4444
);
4545
}
4646

4747
public SimpleAuxiliaryDatabaseObject(
48-
Schema schema,
48+
Namespace namespace,
4949
String[] createStrings,
5050
String[] dropStrings,
5151
Set<String> dialectScopes) {
5252
this(
5353
dialectScopes,
54-
extractName( schema.getPhysicalName().getCatalog() ),
55-
extractName( schema.getPhysicalName().getSchema() ),
54+
extractName( namespace.getPhysicalName().getCatalog() ),
55+
extractName( namespace.getPhysicalName().getSchema() ),
5656
createStrings,
5757
dropStrings
5858
);

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public boolean shouldImplicitlyQuoteIdentifiers() {
176176
}
177177
);
178178

179-
rootMetadataBuildingContext.getMetadataCollector().getDatabase().adjustDefaultSchema(
179+
rootMetadataBuildingContext.getMetadataCollector().getDatabase().adjustDefaultNamespace(
180180
rootMetadataBuildingContext.getBuildingOptions().getMappingDefaults().getImplicitCatalogName(),
181181
rootMetadataBuildingContext.getBuildingOptions().getMappingDefaults().getImplicitSchemaName()
182182
);

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/AuxiliaryDatabaseObjectBinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void processAuxiliaryDatabaseObject(
5252
}
5353
else {
5454
auxDbObject = new SimpleAuxiliaryDatabaseObject(
55-
context.getMetadataCollector().getDatabase().getDefaultSchema(),
55+
context.getMetadataCollector().getDatabase().getDefaultNamespace(),
5656
auxDbObjectMapping.getCreate(),
5757
auxDbObjectMapping.getDrop(),
5858
null

0 commit comments

Comments
 (0)