From: Paul H. <pha...@us...> - 2005-03-14 14:36:05
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32554/nhibernate/src/NHibernate/Cfg Modified Files: Binder.cs Configuration.cs Log Message: Bringing mapping/config to 2.1 feature set - excludes metaData Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Binder.cs 6 Mar 2005 12:44:35 -0000 1.40 --- Binder.cs 14 Mar 2005 14:35:54 -0000 1.41 *************** *** 235,239 **** model.Identifier = id; ! if ( propertyName==null) { BindSimpleValue(subnode, id, false, RootClass.DefaultIdentifierColumnName, mappings); --- 235,239 ---- model.Identifier = id; ! if ( propertyName == null) { BindSimpleValue(subnode, id, false, RootClass.DefaultIdentifierColumnName, mappings); *************** *** 243,250 **** else { ! BindSimpleValue(subnode, id, false, propertyName, mappings); ! id.SetTypeByReflection( model.MappedClass, propertyName); ! Mapping.Property prop = new Mapping.Property(id); ! BindProperty(subnode, prop, mappings); model.IdentifierProperty = prop; } --- 243,250 ---- 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; } *************** *** 305,308 **** --- 305,312 ---- model.IsForceDiscriminator = true; } + if ( subnode.Attributes["insert"] != null && "true".Equals( subnode.Attributes["false"].Value ) ) + { + model.IsDiscriminatorInsertable = false; + } break; *************** *** 436,439 **** --- 440,449 ---- */ + private static string PropertyAccess( XmlNode node, Mappings mappings ) + { + XmlAttribute accessNode = node.Attributes["access"]; + return accessNode != null ? accessNode.Value : mappings.DefaultAccess; + } + /// <summary> /// *************** *** 448,460 **** if (type==null) throw new MappingException("could not determine a property type for: " + model.Name ); ! XmlAttribute accessNode = node.Attributes["access"]; ! if( accessNode!=null) ! { ! model.PropertyAccessorName = accessNode.Value; ! } ! else ! { ! model.PropertyAccessorName = mappings.DefaultAccess; ! } XmlAttribute cascadeNode = node.Attributes["cascade"]; model.Cascade = (cascadeNode==null) ? mappings.DefaultCascade : cascadeNode.Value; --- 458,463 ---- if (type==null) throw new MappingException("could not determine a property type for: " + model.Name ); ! model.PropertyAccessorName = PropertyAccess( node, mappings ); ! XmlAttribute cascadeNode = node.Attributes["cascade"]; model.Cascade = (cascadeNode==null) ? mappings.DefaultCascade : cascadeNode.Value; *************** *** 643,646 **** --- 646,655 ---- InitOuterJoinFetchSetting(node, model); + XmlAttribute ukName = node.Attributes["property-ref"]; + if ( ukName != null ) + { + model.ReferencedPropertyName = ukName.Value; + } + XmlAttribute typeNode = node.Attributes["class"]; *************** *** 649,653 **** try { ! model.Type = TypeFactory.ManyToOne( ReflectHelper.ClassForName( typeNode.Value ) ); } catch --- 658,662 ---- try { ! model.Type = TypeFactory.ManyToOne( ReflectHelper.ClassForName( typeNode.Value ), model.ReferencedPropertyName ); } catch *************** *** 656,659 **** --- 665,674 ---- } } + + XmlAttribute fkNode = node.Attributes["foreign-key"]; + if ( fkNode != null ) + { + model.ForeignKeyName = fkNode.Value; + } } *************** *** 668,671 **** --- 683,688 ---- if ( metaType==null ) throw new MappingException("could not interpret meta-type"); model.MetaType = metaType; + + // TODO: 2.1 Handle meta-value collection } *************** *** 684,693 **** model.ForeignKeyType = (constrained ? ForeignKeyType.ForeignKeyFromParent : ForeignKeyType.ForeignKeyToParent); ! XmlAttribute classNode = node.Attributes["class"]; ! if (classNode!=null) { try { ! model.Type = TypeFactory.OneToOne( ReflectHelper.ClassForName( classNode.Value ), model.ForeignKeyType); } catch (Exception) --- 701,722 ---- model.ForeignKeyType = (constrained ? ForeignKeyType.ForeignKeyFromParent : ForeignKeyType.ForeignKeyToParent); ! XmlAttribute fkNode = node.Attributes[ "foreign-key" ]; ! if ( fkNode != null ) ! { ! model.ForeignKeyName = fkNode.Value; ! } ! ! XmlAttribute ukName = node.Attributes[ "property-ref" ]; ! if ( ukName != null ) ! { ! model.ReferencedPropertyName = ukName.Value; ! } ! ! XmlAttribute classNode = node.Attributes[ "class" ]; ! if ( classNode != null ) { try { ! model.Type = TypeFactory.OneToOne( ReflectHelper.ClassForName( classNode.Value ), model.ForeignKeyType, model.ReferencedPropertyName ) ; } catch (Exception) *************** *** 721,724 **** --- 750,756 ---- XmlAttribute unqNode = node.Attributes["unique"]; model.IsUnique = unqNode!=null && StringHelper.BooleanValue( unqNode.Value ); + + XmlAttribute chkNode = node.Attributes["check"]; + model.CheckConstraint = chkNode != null ? chkNode.Value : string.Empty; XmlAttribute typeNode = node.Attributes["sql-type"]; *************** *** 920,924 **** if ( parentClass != null && value.IsSimpleValue ) { ! ( (SimpleValue) value).SetTypeByReflection( parentClass, propertyName ); } --- 952,956 ---- if ( parentClass != null && value.IsSimpleValue ) { ! ( (SimpleValue) value).SetTypeByReflection( parentClass, propertyName, PropertyAccess( subnode, mappings ) ); } *************** *** 936,940 **** Mapping.Property prop = new Mapping.Property(); prop.Value = value; ! BindProperty(subnode, prop, mappings); return prop; --- 968,972 ---- Mapping.Property prop = new Mapping.Property(); prop.Value = value; ! BindProperty( subnode, prop, mappings ); return prop; Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Configuration.cs 6 Mar 2005 12:44:35 -0000 1.33 --- Configuration.cs 14 Mar 2005 14:35:54 -0000 1.34 *************** *** 560,564 **** foreach( ForeignKey fk in table.ForeignKeyCollection ) { ! script.Add( fk.SqlDropString( dialect ) ); } } --- 560,564 ---- foreach( ForeignKey fk in table.ForeignKeyCollection ) { ! script.Add( fk.SqlDropString( dialect, (string) properties[ Environment.DefaultSchema ] ) ); } } *************** *** 567,571 **** foreach( Table table in TableMappings ) { ! script.Add( table.SqlDropString( dialect ) ); } --- 567,571 ---- foreach( Table table in TableMappings ) { ! script.Add( table.SqlDropString( dialect, (string) properties[ Environment.DefaultSchema ] ) ); } *************** *** 594,598 **** foreach( Table table in TableMappings ) { ! script.Add( table.SqlCreateString( dialect, this ) ); } --- 594,598 ---- foreach( Table table in TableMappings ) { ! script.Add( table.SqlCreateString( dialect, this, (string) properties[ Environment.DefaultSchema ] ) ); } *************** *** 601,605 **** foreach( Index index in table.IndexCollection ) { ! script.Add( index.SqlCreateString( dialect, this ) ); } if( dialect.HasAlterTable ) --- 601,605 ---- foreach( Index index in table.IndexCollection ) { ! script.Add( index.SqlCreateString( dialect, this, (string) properties[ Environment.DefaultSchema ] ) ); } if( dialect.HasAlterTable ) *************** *** 607,611 **** foreach( ForeignKey fk in table.ForeignKeyCollection ) { ! script.Add( fk.SqlCreateString( dialect, this ) ); } } --- 607,611 ---- foreach( ForeignKey fk in table.ForeignKeyCollection ) { ! script.Add( fk.SqlCreateString( dialect, this, (string) properties[ Environment.DefaultSchema ] ) ); } } |