From: <fab...@us...> - 2010-07-22 17:13:27
|
Revision: 5041 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5041&view=rev Author: fabiomaulo Date: 2010-07-22 13:34:19 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Missed 'unique' specification on component mapping Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-07-22 12:05:41 UTC (rev 5040) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-07-22 13:34:19 UTC (rev 5041) @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using NHibernate.Cfg.MappingSchema; using NHibernate.Mapping; using System; @@ -117,7 +118,7 @@ System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(componentMapping.Class, mappedClass, propertyName, componentMapping.Access); BindComponent(componentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); - BindComponentProperty(componentMapping, property); + BindComponentProperty(componentMapping, property, value); } else if ((oneToOneMapping = entityPropertyMapping as HbmOneToOne) != null) { @@ -134,7 +135,7 @@ System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(dynamicComponentMapping.Class, mappedClass, propertyName, dynamicComponentMapping.Access); BindComponent(dynamicComponentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); - BindComponentProperty(dynamicComponentMapping, property); + BindComponentProperty(dynamicComponentMapping, property, value); } else if ((anyMapping = entityPropertyMapping as HbmAny) != null) { @@ -314,16 +315,24 @@ } } - private void BindComponentProperty(HbmDynamicComponent dynamicComponentMapping, Property property) + private void BindComponentProperty(HbmDynamicComponent dynamicComponentMapping, Property property, Component model) { property.IsUpdateable = dynamicComponentMapping.update; property.IsInsertable = dynamicComponentMapping.insert; + if (dynamicComponentMapping.unique) + { + model.Owner.Table.CreateUniqueKey(model.ColumnIterator.OfType<Column>().ToList()); + } } - private void BindComponentProperty(HbmComponent componentMapping, Property property) + private void BindComponentProperty(HbmComponent componentMapping, Property property, Component model) { property.IsUpdateable = componentMapping.update; property.IsInsertable = componentMapping.insert; + if (componentMapping.unique) + { + model.Owner.Table.CreateUniqueKey(model.ColumnIterator.OfType<Column>().ToList()); + } } private void BindManyToOneProperty(HbmManyToOne manyToOneMapping, Property property) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |