diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Database.java b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Database.java index 74f31de8ce..fbdcc0a8cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Database.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Database.java @@ -23,7 +23,9 @@ */ package org.hibernate.metamodel.relational; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -33,6 +35,7 @@ import java.util.Map; */ public class Database { private Map schemaMap = new HashMap(); + private final List auxiliaryDatabaseObjects = new ArrayList(); public Schema getSchema(Schema.Name name) { Schema schema = schemaMap.get( name ); @@ -50,4 +53,15 @@ public class Database { public Schema getSchema(String schema, String 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 getAuxiliaryDatabaseObjects() { + return auxiliaryDatabaseObjects; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java index 6df7a03f28..0e3bcb9931 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateMappingProcessor.java @@ -192,7 +192,7 @@ public class HibernateMappingProcessor implements HbmBindingContext { dialectScopes ); } - metadata.addAuxiliaryDatabaseObject( auxiliaryDatabaseObject ); + metadata.getDatabase().addAuxiliaryDatabaseObject( auxiliaryDatabaseObject ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java index 5584f9f330..eb3d2dbe19 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/MetadataImpl.java @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.collections.functors.FalsePredicate; import org.jboss.logging.Logger; 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.TypeDef; import org.hibernate.metamodel.domain.JavaType; -import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject; import org.hibernate.metamodel.relational.Database; import org.hibernate.metamodel.source.annotations.AnnotationBinder; import org.hibernate.metamodel.source.hbm.HbmBinder; @@ -109,8 +107,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable { private Map resultSetMappings = new HashMap(); private Map filterDefs = new HashMap(); - // todo : keep as part of Database? - private List auxiliaryDatabaseObjects = new ArrayList(); private boolean globallyQuotedIdentifiers = false; public MetadataImpl(MetadataSources metadataSources, Options options) { @@ -216,14 +212,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable { 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 public void addNamedNativeQuery(NamedSQLQueryDefinition def) { if ( def == null || def.getName() == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/spi/MetadataImplementor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/spi/MetadataImplementor.java index 0ab0f2619e..8f1f931ea2 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/spi/MetadataImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/spi/MetadataImplementor.java @@ -71,6 +71,4 @@ public interface MetadataImplementor extends Metadata, BindingContext, Mapping { public void addNamedQuery(NamedQueryDefinition def); public void addResultSetMapping(ResultSetMappingDefinition resultSetMappingDefinition); - - public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject); }