Example #1
0
 private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
 {
     if (cacheSchema != null)
     {
         rootClass.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
         rootClass.CacheRegionName = cacheSchema.region;
     }
 }
Example #2
0
 private static void BindCache(HbmCacheType cacheSchema, RootClass rootClass)
 {
     if (cacheSchema != null)
     {
         rootClass.CacheConcurrencyStrategy = GetXmlEnumAttribute(cacheSchema.usage);
         rootClass.CacheRegionName = cacheSchema.region;
     }
 }
Example #3
0
        public void Bind(HbmClass classSchema, IDictionary<string, MetaAttribute> inheritedMetas)
        {
            var rootClass = new RootClass();
            BindClass(classSchema, rootClass, inheritedMetas);
            // OPTIMISTIC LOCK MODE
            rootClass.OptimisticLockMode = classSchema.optimisticlock.ToOptimisticLock();

            inheritedMetas = GetMetas(classSchema, inheritedMetas, true); // get meta's from <class>

            //TABLENAME
            string schema = classSchema.schema ?? mappings.SchemaName;
            string catalog = classSchema.catalog ?? mappings.CatalogName;
            string tableName = GetClassTableName(rootClass, classSchema);
            if (string.IsNullOrEmpty(tableName))
            {
                throw new MappingException(
                    string.Format(
                        "Could not determine the name of the table for entity '{0}'; remove the 'table' attribute or assign a value to it.",
                        rootClass.EntityName));
            }

            Table table = mappings.AddTable(schema, catalog, tableName, classSchema.Subselect, rootClass.IsAbstract.GetValueOrDefault(), classSchema.schemaaction);
            ((ITableOwner) rootClass).Table = table;

            log.InfoFormat("Mapping class: {0} -> {1}", rootClass.EntityName, rootClass.Table.Name);

            rootClass.IsMutable = classSchema.mutable;
            rootClass.Where = classSchema.where ?? rootClass.Where;

            if (classSchema.check != null)
                table.AddCheckConstraint(classSchema.check);

            rootClass.IsExplicitPolymorphism = classSchema.polymorphism == HbmPolymorphismType.Explicit;

            BindCache(classSchema.cache, rootClass);
            new ClassIdBinder(this).BindId(classSchema.Id, rootClass, table);
            new ClassCompositeIdBinder(this).BindCompositeId(classSchema.CompositeId, rootClass);
            new ClassDiscriminatorBinder(rootClass, Mappings).BindDiscriminator(classSchema.discriminator, table);
            BindTimestamp(classSchema.Timestamp, rootClass, table, inheritedMetas);
            BindVersion(classSchema.Version, rootClass, table, inheritedMetas);

            if (!String.IsNullOrEmpty(classSchema.primaryKeyName)) {
                rootClass.PrimaryKeyName = classSchema.primaryKeyName;
                table.PrimaryKeyName = classSchema.primaryKeyName;
            }
            rootClass.CreatePrimaryKey(dialect);
            BindNaturalId(classSchema.naturalid, rootClass, inheritedMetas);
            new PropertiesBinder(mappings, rootClass, dialect).Bind(classSchema.Properties, inheritedMetas);

            BindJoins(classSchema.Joins, rootClass, inheritedMetas);
            BindSubclasses(classSchema.Subclasses, rootClass, inheritedMetas);
            BindJoinedSubclasses(classSchema.JoinedSubclasses, rootClass, inheritedMetas);
            BindUnionSubclasses(classSchema.UnionSubclasses, rootClass, inheritedMetas);

            new FiltersBinder(rootClass, Mappings).Bind(classSchema.filter);

            mappings.AddClass(rootClass);
        }
		public void Bind(XmlNode node, HbmClass classSchema, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			RootClass rootClass = new RootClass();
			BindClass(node, classSchema, rootClass, inheritedMetas);
			inheritedMetas = GetMetas(classSchema, inheritedMetas, true); // get meta's from <class>

			//TABLENAME
			string schema = classSchema.schema ?? mappings.SchemaName;
			string catalog = classSchema.catalog ?? mappings.CatalogName;
			string tableName = GetClassTableName(rootClass, classSchema);
			if (string.IsNullOrEmpty(tableName))
			{
				throw new MappingException(
					string.Format(
						"Could not determine the name of the table for entity '{0}'; remove the 'table' attribute or assign a value to it.",
						rootClass.EntityName));
			}

			Table table = mappings.AddTable(schema, catalog, tableName, null, rootClass.IsAbstract.GetValueOrDefault(), classSchema.schemaaction);
			((ITableOwner) rootClass).Table = table;

			log.InfoFormat("Mapping class: {0} -> {1}", rootClass.EntityName, rootClass.Table.Name);

			rootClass.IsMutable = classSchema.mutable;
			rootClass.Where = classSchema.where ?? rootClass.Where;

			if (classSchema.check != null)
				table.AddCheckConstraint(classSchema.check);

			rootClass.IsExplicitPolymorphism = classSchema.polymorphism == HbmPolymorphismType.Explicit;

			BindCache(classSchema.cache, rootClass);
			new ClassIdBinder(this).BindId(classSchema.Id, rootClass, table);
			new ClassCompositeIdBinder(this).BindCompositeId(classSchema.CompositeId, rootClass);
			new ClassDiscriminatorBinder(this).BindDiscriminator(classSchema.discriminator, rootClass, table);
			BindTimestamp(classSchema.Timestamp, rootClass, table, inheritedMetas);
			BindVersion(classSchema.Version, rootClass, table, inheritedMetas);

			rootClass.CreatePrimaryKey(dialect);

			PropertiesFromXML(node, rootClass, inheritedMetas);
			mappings.AddClass(rootClass);
		}
        public virtual void Bind(ClassMapping classMapping)
        {
            RootClass rootClass = new RootClass();
            BindClass(classMapping, rootClass);
            string schema = mappings.SchemaName;
            string catalog = mappings.CatalogName;
            string tableName = classMapping.Tablename.ValueOrDefault(
                mappings.NamingStrategy.TableName(classMapping.Type.Name));

            Table table = mappings
                .AddTable(schema, catalog, tableName, null,
                          rootClass.IsAbstract.GetValueOrDefault());//Introduce SchemaAction
            ((ITableOwner)rootClass).Table = table;

            rootClass.IsMutable = true;
            rootClass.IsExplicitPolymorphism = false;
            new ClassIdBinder(this).BindId(classMapping.Id as IdMapping, rootClass, table);
            rootClass.CreatePrimaryKey(dialect);
            base.BindProperties(rootClass, classMapping);
            mappings.AddClass(rootClass);
        }
Example #6
0
 public void Bind(System.Type entity)
 {
     var rootClass = new RootClass();
     BindClass(entity, rootClass);
 }
Example #7
0
		public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect, string defaultCatalog,
		                                                      string defaultSchema, RootClass rootClass)
		{
			Dictionary<string, string> @params = new Dictionary<string, string>();

			//if the hibernate-mapping did not specify a schema/catalog, use the defaults
			//specified by properties - but note that if the schema/catalog were specified
			//in hibernate-mapping, or as params, they will already be initialized and
			//will override the values set here (they are in identifierGeneratorProperties)
			if (!string.IsNullOrEmpty(defaultSchema))
			{
				@params[PersistentIdGeneratorParmsNames.Schema] = defaultSchema;
			}
			if (!string.IsNullOrEmpty(defaultCatalog))
			{
				@params[PersistentIdGeneratorParmsNames.Catalog] = defaultCatalog;
			}

			//pass the entity-name, if not a collection-id
			if (rootClass != null)
			{
				@params[IdGeneratorParmsNames.EntityName] = rootClass.EntityName;
			}

			//init the table here instead of earlier, so that we can get a quoted table name
			//TODO: would it be better to simply pass the qualified table name, instead of
			//      splitting it up into schema/catalog/table names
			string tableName = Table.GetQuotedName(dialect);

			@params[PersistentIdGeneratorParmsNames.Table] = tableName;

			//pass the column name (a generated id almost always has a single column and is not a formula)
			IEnumerator enu = ColumnIterator.GetEnumerator();
			enu.MoveNext();
			string columnName = ((Column)enu.Current).GetQuotedName(dialect);

			@params[PersistentIdGeneratorParmsNames.PK] = columnName;

			if (rootClass != null)
			{
				StringBuilder tables = new StringBuilder();
				bool commaNeeded = false;
				foreach (Table identityTable in rootClass.IdentityTables)
				{
					if (commaNeeded)
						tables.Append(StringHelper.CommaSpace);
					commaNeeded = true;
					tables.Append(identityTable.GetQuotedName(dialect));
				}
				@params[PersistentIdGeneratorParmsNames.Tables] = tables.ToString();
			}
			else
			{
				@params[PersistentIdGeneratorParmsNames.Tables] = tableName;
			}

			if (identifierGeneratorProperties != null)
			{
				ArrayHelper.AddAll(@params, identifierGeneratorProperties);
			}

			return IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, Type, @params, dialect);
		}
Example #8
0
        public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect, string defaultCatalog,
                                                              string defaultSchema, RootClass rootClass)
        {
            Dictionary <string, string> @params = new Dictionary <string, string>();

            //if the hibernate-mapping did not specify a schema/catalog, use the defaults
            //specified by properties - but note that if the schema/catalog were specified
            //in hibernate-mapping, or as params, they will already be initialized and
            //will override the values set here (they are in identifierGeneratorProperties)
            if (!string.IsNullOrEmpty(defaultSchema))
            {
                @params[PersistentIdGeneratorParmsNames.Schema] = defaultSchema;
            }
            if (!string.IsNullOrEmpty(defaultCatalog))
            {
                @params[PersistentIdGeneratorParmsNames.Catalog] = defaultCatalog;
            }

            //pass the entity-name, if not a collection-id
            if (rootClass != null)
            {
                @params[IdGeneratorParmsNames.EntityName] = rootClass.EntityName;
            }

            //init the table here instead of earlier, so that we can get a quoted table name
            //TODO: would it be better to simply pass the qualified table name, instead of
            //      splitting it up into schema/catalog/table names
            string tableName = Table.GetQuotedName(dialect);

            @params[PersistentIdGeneratorParmsNames.Table] = tableName;

            //pass the column name (a generated id almost always has a single column and is not a formula)
            IEnumerator enu = ColumnIterator.GetEnumerator();

            enu.MoveNext();
            string columnName = ((Column)enu.Current).GetQuotedName(dialect);

            @params[PersistentIdGeneratorParmsNames.PK] = columnName;

            if (rootClass != null)
            {
                StringBuilder tables      = new StringBuilder();
                bool          commaNeeded = false;
                foreach (Table identityTable in rootClass.IdentityTables)
                {
                    if (commaNeeded)
                    {
                        tables.Append(StringHelper.CommaSpace);
                    }
                    commaNeeded = true;
                    tables.Append(identityTable.GetQuotedName(dialect));
                }
                @params[PersistentIdGeneratorParmsNames.Tables] = tables.ToString();
            }
            else
            {
                @params[PersistentIdGeneratorParmsNames.Tables] = tableName;
            }

            if (identifierGeneratorProperties != null)
            {
                ArrayHelper.AddAll(@params, identifierGeneratorProperties);
            }

            return(IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, Type, @params, dialect));
        }
		public static void BindRootClass( XmlNode node, RootClass model, Mappings mappings )
		{
			BindClass( node, model, mappings );

			//TABLENAME
			XmlAttribute schemaNode = node.Attributes[ "schema" ];
			string schema = schemaNode == null ? mappings.SchemaName : schemaNode.Value;
			Table table = mappings.AddTable( schema, GetClassTableName( model, node, mappings ) );
			model.Table = table;

			log.Info( "Mapping class: " + model.Name + " -> " + model.Table.Name );

			//MUTABLE
			XmlAttribute mutableNode = node.Attributes[ "mutable" ];
			model.IsMutable = ( mutableNode == null ) || mutableNode.Value.Equals( "true" );

			//WHERE
			XmlAttribute whereNode = node.Attributes[ "where" ];
			if( whereNode != null )
			{
				model.Where = whereNode.Value;
			}

			//CHECK
			XmlAttribute checkNode = node.Attributes[ "check" ];
			if( checkNode != null )
			{
				table.AddCheckConstraint( checkNode.Value );
			}

			//POLYMORPHISM
			XmlAttribute polyNode = node.Attributes[ "polymorphism" ];
			model.IsExplicitPolymorphism = ( polyNode != null ) && polyNode.Value.Equals( "explicit" );

			foreach( XmlNode subnode in node.ChildNodes )
			{
				string name = subnode.LocalName; //Name;
				string propertyName = GetPropertyName( subnode );

				//I am only concerned with elements that are from the nhibernate namespace
				if( subnode.NamespaceURI != Configuration.MappingSchemaXMLNS )
				{
					continue;
				}

				switch( name )
				{
				case "id":
					SimpleValue id = new SimpleValue( table );
					model.Identifier = id;

					if( propertyName == null )
					{
						BindSimpleValue( subnode, id, false, RootClass.DefaultIdentifierColumnName, mappings );
						if( id.Type == null )
						{
							throw new MappingException( "must specify an identifier type: " + model.MappedClass.Name );
						}
						model.IdentifierProperty = null;
					}
					else
					{
						BindSimpleValue( subnode, id, false, propertyName, mappings );
						id.SetTypeByReflection( model.MappedClass, propertyName, PropertyAccess( subnode, mappings ) );
						Mapping.Property prop = new Mapping.Property( id );
						BindProperty( subnode, prop, mappings );
						model.IdentifierProperty = prop;
					}

					if( id.Type.ReturnedClass.IsArray )
					{
						throw new MappingException( "illegal use of an array as an identifier (arrays don't reimplement equals)" );
					}

					MakeIdentifier( subnode, id, mappings );
					break;

				case "composite-id":
					Component compId = new Component( model );
					model.Identifier = compId;
					if( propertyName == null )
					{
						BindComponent( subnode, compId, null, model.Name, "id", false, mappings );
						model.HasEmbeddedIdentifier = compId.IsEmbedded;
						model.IdentifierProperty = null;
					}
					else
					{
						System.Type reflectedClass = GetPropertyType( subnode, mappings, model.MappedClass, propertyName );
						BindComponent( subnode, compId, reflectedClass, model.Name, propertyName, false, mappings );
						Mapping.Property prop = new Mapping.Property( compId );
						BindProperty( subnode, prop, mappings );
						model.IdentifierProperty = prop;
					}
					MakeIdentifier( subnode, compId, mappings );

					System.Type compIdClass = compId.ComponentClass;
					if( !ReflectHelper.OverridesEquals( compIdClass ) )
					{
						throw new MappingException(
							"composite-id class must override Equals(): " + compIdClass.FullName
							);
					}

					if( !ReflectHelper.OverridesGetHashCode( compIdClass ) )
					{
						throw new MappingException(
							"composite-id class must override GetHashCode(): " + compIdClass.FullName
							);
					}

					// Serializability check not ported
					break;

				case "version":
				case "timestamp":
					//VERSION
					SimpleValue val = new SimpleValue( table );
					BindSimpleValue( subnode, val, false, propertyName, mappings );
					if( val.Type == null )
					{
						val.Type = ( ( "version".Equals( name ) ) ? NHibernateUtil.Int32 : NHibernateUtil.Timestamp );
					}
					Mapping.Property timestampProp = new Mapping.Property( val );
					BindProperty( subnode, timestampProp, mappings );
					MakeVersion( subnode, val );
					model.Version = timestampProp;
					model.AddNewProperty( timestampProp );
					break;

				case "discriminator":
					//DISCRIMINATOR
					SimpleValue discrim = new SimpleValue( table );
					model.Discriminator = discrim;
					BindSimpleValue( subnode, discrim, false, RootClass.DefaultDiscriminatorColumnName, mappings );
					if( discrim.Type == null )
					{
						discrim.Type = NHibernateUtil.String;
						foreach( Column col in discrim.ColumnCollection )
						{
							col.Type = NHibernateUtil.String;
							break;
						}
					}
					model.IsPolymorphic = true;
					if( subnode.Attributes[ "force" ] != null && "true".Equals( subnode.Attributes[ "force" ].Value ) )
					{
						model.IsForceDiscriminator = true;
					}
					if( subnode.Attributes[ "insert" ] != null && "false".Equals( subnode.Attributes[ "insert" ].Value ) )
					{
						model.IsDiscriminatorInsertable = false;
					}
					break;

				case "jcs-cache":
				case "cache":
					string className = model.MappedClass.FullName;
					ICacheConcurrencyStrategy cache = CacheFactory.CreateCache( subnode, className, model.IsMutable );
					mappings.AddCache( className, cache );
					model.Cache = cache;

					break;
				}
			}

			model.CreatePrimaryKey( dialect );

			PropertiesFromXML( node, model, mappings );
		}
		public static void BindRoot( XmlDocument doc, Mappings model )
		{
			XmlNode hmNode = doc.DocumentElement;
			XmlAttribute schemaNode = hmNode.Attributes[ "schema" ];
			model.SchemaName = ( schemaNode == null ) ? null : schemaNode.Value;
			XmlAttribute dcNode = hmNode.Attributes[ "default-cascade" ];
			model.DefaultCascade = ( dcNode == null ) ? "none" : dcNode.Value;
			XmlAttribute daNode = hmNode.Attributes[ "default-access" ];
			model.DefaultAccess = ( daNode == null ) ? "property" : daNode.Value;
			XmlAttribute aiNode = hmNode.Attributes[ "auto-import" ];
			model.IsAutoImport = ( aiNode == null ) ? true : "true".Equals( aiNode.Value );
			XmlAttribute nsNode = hmNode.Attributes[ "namespace" ];
			model.DefaultNamespace = ( nsNode == null ) ? null : nsNode.Value;
			XmlAttribute assemblyNode = hmNode.Attributes[ "assembly" ];
			model.DefaultAssembly = ( assemblyNode == null ) ? null : assemblyNode.Value;

			nsmgr = new XmlNamespaceManager( doc.NameTable );
			// note that the prefix has absolutely nothing to do with what the user
			// selects as their prefix in the document.  It is the prefix we use to 
			// build the XPath and the nsmgr takes care of translating our prefix into
			// the user defined prefix...
			nsmgr.AddNamespace( nsPrefix, Configuration.MappingSchemaXMLNS );

			foreach( XmlNode n in hmNode.SelectNodes( nsClass, nsmgr ) )
			{
				RootClass rootclass = new RootClass();
				Binder.BindRootClass( n, rootclass, model );
				model.AddClass( rootclass );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsSubclass, nsmgr ) )
			{
				PersistentClass superModel = GetSuperclass( model, n );
				HandleSubclass( superModel, model, n );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsJoinedSubclass, nsmgr ) )
			{
				PersistentClass superModel = GetSuperclass( model, n );
				HandleJoinedSubclass( superModel, model, n );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsQuery, nsmgr ) )
			{
				string qname = n.Attributes[ "name" ].Value;
				string query = n.InnerText;
				log.Debug( "Named query: " + qname + " -> " + query );
				model.AddQuery( qname, query );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsSqlQuery, nsmgr ) )
			{
				string qname = n.Attributes[ "name" ].Value;
				NamedSQLQuery namedQuery = new NamedSQLQuery( n.InnerText );

				foreach( XmlNode returns in n.SelectNodes( nsReturn, nsmgr ) )
				{
					string alias = returns.Attributes[ "alias" ].Value;
					System.Type clazz = ClassForNameChecked(
						returns.Attributes[ "class" ].Value, model,
						"class not found: {0} for alias " + alias );
					namedQuery.AddAliasedClass( alias, clazz );
				}

				foreach( XmlNode table in n.SelectNodes( nsSynchronize, nsmgr ) )
				{
					namedQuery.AddSynchronizedTable( table.Attributes[ "table" ].Value );
				}

				log.Debug( "Named sql query: " + qname + " -> " + namedQuery.QueryString );
				model.AddSQLQuery( qname, namedQuery );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsImport, nsmgr ) )
			{
				string className = FullClassName( n.Attributes[ "class" ].Value, model );
				XmlAttribute renameNode = n.Attributes[ "rename" ];
				string rename = ( renameNode == null ) ? StringHelper.GetClassname( className ) : renameNode.Value;
				log.Debug( "Import: " + rename + " -> " + className );
				model.AddImport( className, rename );
			}
		}
Example #11
0
		private static void AssertDeserializedMappingClasses(RootClass deserializedClassMapping)
		{
			var deserializedComponentPropertyMapping = deserializedClassMapping.GetProperty("ComponentPropertyInClass");
			var deserializedComponentMapping = (NHibernate.Mapping.Component)deserializedComponentPropertyMapping.Value;
			var deserializedComponentType = (IAbstractComponentType)deserializedComponentMapping.Type;
			var deserializedStringPropertyInComponentMapping = deserializedComponentMapping.GetProperty("StringPropertyInComponent");

			// Must be all the same objects since CascadeStyles are singletons and are
			// compared with "==" and "!=" operators.
			Assert.AreSame(CascadeStyle.None, deserializedStringPropertyInComponentMapping.CascadeStyle);
			Assert.AreSame(CascadeStyle.None, deserializedComponentType.GetCascadeStyle(0));
			Assert.AreSame(CascadeStyle.None, deserializedComponentPropertyMapping.CascadeStyle);
		}
Example #12
0
		private static RootClass CreateMappingClasses()
		{
			var classMapping = new RootClass();
			var componentMapping = new NHibernate.Mapping.Component(classMapping);

			var componentPropertyMapping = new Property(componentMapping);
			componentPropertyMapping.Name = "ComponentPropertyInClass";
			classMapping.AddProperty(componentPropertyMapping);

			var stringValue = new SimpleValue();
			stringValue.TypeName = typeof(string).FullName;

			var stringPropertyInComponentMapping = new Property(stringValue);
			stringPropertyInComponentMapping.Name = "StringPropertyInComponent";
			componentMapping.AddProperty(stringPropertyInComponentMapping);

			var componentType = (IAbstractComponentType)componentMapping.Type;

			Assume.That(CascadeStyle.None == stringPropertyInComponentMapping.CascadeStyle);
			Assume.That(CascadeStyle.None == componentType.GetCascadeStyle(0));
			Assume.That(CascadeStyle.None == componentPropertyMapping.CascadeStyle);

			return classMapping;
		}
Example #13
0
 public IPersistentClassInformation GetClassMapping(string path)
 {
     var rc = new RootClass();
     foreach (string p in probe.GetProperties(path))
     {
         var ser = new JavaScriptSerializer();
         var obj = ser.DeserializeObject(p) as IDictionary<string,object>;
         var prop = new Property();
         prop.Value = NHValueJSonHelper.JSonDeserialize(prop.GetType().Assembly, obj["Value"] as IDictionary<string,object>) as IValue;
         prop.Name = obj["Name"] as string;
         rc.AddProperty( prop);
     }
     return ConfigurationMapper.MapClass(rc);
 }
		public CreateKeySecondPass(RootClass rootClass)
		{
			this.rootClass = rootClass;
		}
		private static void BindVersioningProperty(Table table, XmlNode subnode, Mappings mappings, string name, RootClass entity)
		{
			string propertyName = subnode.Attributes["name"].Value;
			SimpleValue val = new SimpleValue(table);
			BindSimpleValue(subnode, val, false, propertyName, mappings);
			if (val.Type == null)
			{
				val.Type = (("version".Equals(name)) ? NHibernateUtil.Int32 : NHibernateUtil.Timestamp);
			}
			Mapping.Property prop = new Mapping.Property(val);
			BindProperty(subnode, prop, mappings);
			// for version properties marked as being generated, make sure they are "always"
			// generated; "insert" is invalid. This is dis-allowed by the schema, but just to make
			// sure...
			if (prop.Generation == PropertyGeneration.Insert)
			{
				throw new MappingException("'generated' attribute cannot be 'insert' for versioning property");
			}
			MakeVersion(subnode, val);
			entity.Version = prop;
			entity.AddProperty(prop);
		}
		public static void BindRoot(XmlDocument doc, Mappings mappings)
		{
			nsmgr = BuildNamespaceManager(doc.NameTable);
			XmlNode hmNode = doc.DocumentElement;
			ExtractRootAttributes(hmNode, mappings);

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsFilterDef, nsmgr))
			{
				ParseFilterDef(n, mappings);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsClass, nsmgr))
			{
				RootClass rootclass = new RootClass();
				BindRootClass(n, rootclass, mappings);
				mappings.AddClass(rootclass);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsSubclass, nsmgr))
			{
				PersistentClass superModel = GetSuperclass(mappings, n);
				HandleSubclass(superModel, mappings, n);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsJoinedSubclass, nsmgr))
			{
				PersistentClass superModel = GetSuperclass(mappings, n);
				HandleJoinedSubclass(superModel, mappings, n);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsQuery, nsmgr))
			{
				BindNamedQuery(n, null, mappings);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsSqlQuery, nsmgr))
			{
				BindNamedSQLQuery(n, null, mappings);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsImport, nsmgr))
			{
				string className = FullClassName(n.Attributes["class"].Value, mappings);
				XmlAttribute renameNode = n.Attributes["rename"];
				string rename = (renameNode == null) ? StringHelper.GetClassname(className) : renameNode.Value;
				log.Debug("Import: " + rename + " -> " + className);
				mappings.AddImport(className, rename);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsDatabaseObject, nsmgr))
			{
				BindAuxiliaryDatabaseObject(n, mappings);
			}

			foreach (XmlNode n in hmNode.SelectNodes(HbmConstants.nsResultset, nsmgr))
			{
				BindResultSetMappingDefinition(n, null, mappings);
			}
		}