HHH-6416 : Move AuxiliaryDatabaseObject into Database

This commit is contained in:
Gail Badner 2011-07-12 13:44:07 -07:00
parent d58bb5a103
commit 30843f2032
4 changed files with 15 additions and 15 deletions

View File

@ -23,7 +23,9 @@
*/ */
package org.hibernate.metamodel.relational; package org.hibernate.metamodel.relational;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -33,6 +35,7 @@ import java.util.Map;
*/ */
public class Database { public class Database {
private Map<Schema.Name,Schema> schemaMap = new HashMap<Schema.Name, Schema>(); private Map<Schema.Name,Schema> schemaMap = new HashMap<Schema.Name, Schema>();
private final List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjects = new ArrayList<AuxiliaryDatabaseObject>();
public Schema getSchema(Schema.Name name) { public Schema getSchema(Schema.Name name) {
Schema schema = schemaMap.get( name ); Schema schema = schemaMap.get( name );
@ -50,4 +53,15 @@ public class Database {
public Schema getSchema(String schema, String catalog) { public Schema getSchema(String schema, String catalog) {
return getSchema( new Schema.Name( Identifier.toIdentifier( schema ), Identifier.toIdentifier( catalog ) ) ); return getSchema( new Schema.Name( Identifier.toIdentifier( schema ), Identifier.toIdentifier( catalog ) ) );
} }
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {
if ( auxiliaryDatabaseObject == null ) {
throw new IllegalArgumentException( "Auxiliary database object is null." );
}
auxiliaryDatabaseObjects.add( auxiliaryDatabaseObject );
}
public Iterable<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjects() {
return auxiliaryDatabaseObjects;
}
} }

View File

@ -192,7 +192,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
dialectScopes dialectScopes
); );
} }
metadata.addAuxiliaryDatabaseObject( auxiliaryDatabaseObject ); metadata.getDatabase().addAuxiliaryDatabaseObject( auxiliaryDatabaseObject );
} }
} }

View File

@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections.functors.FalsePredicate;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.DuplicateMappingException; import org.hibernate.DuplicateMappingException;
@ -53,7 +52,6 @@ import org.hibernate.metamodel.binding.IdGenerator;
import org.hibernate.metamodel.binding.PluralAttributeBinding; import org.hibernate.metamodel.binding.PluralAttributeBinding;
import org.hibernate.metamodel.binding.TypeDef; import org.hibernate.metamodel.binding.TypeDef;
import org.hibernate.metamodel.domain.JavaType; import org.hibernate.metamodel.domain.JavaType;
import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject;
import org.hibernate.metamodel.relational.Database; import org.hibernate.metamodel.relational.Database;
import org.hibernate.metamodel.source.annotations.AnnotationBinder; import org.hibernate.metamodel.source.annotations.AnnotationBinder;
import org.hibernate.metamodel.source.hbm.HbmBinder; import org.hibernate.metamodel.source.hbm.HbmBinder;
@ -109,8 +107,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
private Map<String, ResultSetMappingDefinition> resultSetMappings = new HashMap<String, ResultSetMappingDefinition>(); private Map<String, ResultSetMappingDefinition> resultSetMappings = new HashMap<String, ResultSetMappingDefinition>();
private Map<String, FilterDefinition> filterDefs = new HashMap<String, FilterDefinition>(); private Map<String, FilterDefinition> filterDefs = new HashMap<String, FilterDefinition>();
// todo : keep as part of Database?
private List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjects = new ArrayList<AuxiliaryDatabaseObject>();
private boolean globallyQuotedIdentifiers = false; private boolean globallyQuotedIdentifiers = false;
public MetadataImpl(MetadataSources metadataSources, Options options) { public MetadataImpl(MetadataSources metadataSources, Options options) {
@ -216,14 +212,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
identifierGeneratorFactory.register( name, classLoaderService().classForName( generatorClassName ) ); identifierGeneratorFactory.register( name, classLoaderService().classForName( generatorClassName ) );
} }
@Override
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {
if ( auxiliaryDatabaseObject == null ) {
throw new IllegalArgumentException( "Auxiliary database object is null." );
}
auxiliaryDatabaseObjects.add( auxiliaryDatabaseObject );
}
@Override @Override
public void addNamedNativeQuery(NamedSQLQueryDefinition def) { public void addNamedNativeQuery(NamedSQLQueryDefinition def) {
if ( def == null || def.getName() == null ) { if ( def == null || def.getName() == null ) {

View File

@ -71,6 +71,4 @@ public interface MetadataImplementor extends Metadata, BindingContext, Mapping {
public void addNamedQuery(NamedQueryDefinition def); public void addNamedQuery(NamedQueryDefinition def);
public void addResultSetMapping(ResultSetMappingDefinition resultSetMappingDefinition); public void addResultSetMapping(ResultSetMappingDefinition resultSetMappingDefinition);
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject);
} }