From: Kevin W. <kev...@us...> - 2004-12-31 21:28:37
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32268 Modified Files: Table.cs UniqueKey.cs Value.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: Value.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Value.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Value.cs 13 Apr 2004 02:06:54 -0000 1.9 --- Value.cs 31 Dec 2004 21:28:13 -0000 1.10 *************** *** 1,5 **** using System; using System.Collections; - using NHibernate.Dialect; using NHibernate.Id; using NHibernate.Loader; --- 1,4 ---- *************** *** 7,11 **** using NHibernate.Util; ! namespace NHibernate.Mapping { /// <summary> --- 6,10 ---- using NHibernate.Util; ! namespace NHibernate.Mapping { /// <summary> *************** *** 14,18 **** /// of this class /// </summary> ! public class Value { private ArrayList columns = new ArrayList(); --- 13,17 ---- /// of this class /// </summary> ! public class Value { private ArrayList columns = new ArrayList(); *************** *** 24,59 **** private Formula formula; ! public Value(Table table) { this.table = table; } ! public virtual void AddColumn(Column column) { ! if ( !columns.Contains(column) ) columns.Add(column); } ! public virtual int ColumnSpan { get { return columns.Count; } } ! public virtual ICollection ColumnCollection { get { return columns; } } ! public virtual IList ConstraintColumns { get { return columns; } } ! public virtual IType Type { get { return type; } ! set { this.type = value; int count = 0; ! ! foreach(Column col in ColumnCollection) { col.Type = type; --- 23,75 ---- private Formula formula; ! /// <summary> ! /// ! /// </summary> ! /// <param name="table"></param> ! public Value( Table table ) { this.table = table; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="column"></param> ! public virtual void AddColumn( Column column ) { ! if( !columns.Contains( column ) ) ! { ! columns.Add( column ); ! } } ! ! /// <summary></summary> ! public virtual int ColumnSpan { get { return columns.Count; } } ! ! /// <summary></summary> ! public virtual ICollection ColumnCollection { get { return columns; } } ! /// <summary></summary> ! public virtual IList ConstraintColumns { get { return columns; } } ! /// <summary></summary> ! public virtual IType Type { get { return type; } ! set { this.type = value; int count = 0; ! ! foreach( Column col in ColumnCollection ) { col.Type = type; *************** *** 63,67 **** } ! public Table Table { get { return table; } --- 79,84 ---- } ! /// <summary></summary> ! public Table Table { get { return table; } *************** *** 69,77 **** } ! public virtual void CreateForeignKey() { } ! public void CreateForeignKeyOfClass(System.Type persistentClass) { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); --- 86,99 ---- } ! /// <summary></summary> ! public virtual void CreateForeignKey() { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persistentClass"></param> ! public void CreateForeignKeyOfClass( System.Type persistentClass ) { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); *************** *** 81,89 **** private IIdentifierGenerator uniqueIdentifierGenerator; ! public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect) { ! if ( uniqueIdentifierGenerator==null ) { ! uniqueIdentifierGenerator = IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect); } --- 103,116 ---- private IIdentifierGenerator uniqueIdentifierGenerator; ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public IIdentifierGenerator CreateIdentifierGenerator( Dialect.Dialect dialect ) { ! if( uniqueIdentifierGenerator == null ) { ! uniqueIdentifierGenerator = IdentifierGeneratorFactory.Create( identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect ); } *************** *** 91,103 **** } ! public virtual void SetTypeByReflection(System.Type propertyClass, string propertyName) { ! try { ! if (type==null) { ! type = ReflectHelper.ReflectedPropertyType(propertyClass, propertyName); int count = 0; ! foreach(Column col in ColumnCollection) { col.Type = type; --- 118,135 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyClass"></param> ! /// <param name="propertyName"></param> ! public virtual void SetTypeByReflection( System.Type propertyClass, string propertyName ) { ! try { ! if( type == null ) { ! type = ReflectHelper.ReflectedPropertyType( propertyClass, propertyName ); int count = 0; ! foreach( Column col in ColumnCollection ) { col.Type = type; *************** *** 105,122 **** } } ! } ! catch (HibernateException he) { ! throw new MappingException("Problem trying to set property type by reflection", he); } } ! public virtual OuterJoinLoaderType OuterJoinFetchSetting { ! get { return OuterJoinLoaderType.Lazy; } set { throw new NotSupportedException(); } } ! public IDictionary IdentifierGeneratorProperties { get { return identifierGeneratorProperties; } --- 137,156 ---- } } ! } ! catch( HibernateException he ) { ! throw new MappingException( "Problem trying to set property type by reflection", he ); } } ! /// <summary></summary> ! public virtual OuterJoinLoaderType OuterJoinFetchSetting { ! get { return OuterJoinLoaderType.Lazy; } set { throw new NotSupportedException(); } } ! /// <summary></summary> ! public IDictionary IdentifierGeneratorProperties { get { return identifierGeneratorProperties; } *************** *** 124,139 **** } ! public string IdentifierGeneratorStrategy { get { return identifierGeneratorStrategy; } set { identifierGeneratorStrategy = value; } } ! ! ! public virtual bool IsComposite { get { return false; } } ! public string NullValue { get { return nullValue; } --- 158,176 ---- } ! /// <summary></summary> ! public string IdentifierGeneratorStrategy ! { get { return identifierGeneratorStrategy; } set { identifierGeneratorStrategy = value; } } ! /// <summary></summary> ! public virtual bool IsComposite ! { get { return false; } } ! /// <summary></summary> ! public string NullValue { get { return nullValue; } *************** *** 141,151 **** } ! public virtual bool IsAny { get { return false; } ! } ! ! ! public Formula Formula { get { return formula; } --- 178,189 ---- } ! /// <summary></summary> ! public virtual bool IsAny { get { return false; } ! } ! ! /// <summary></summary> ! public Formula Formula { get { return formula; } *************** *** 153,155 **** } } ! } --- 191,193 ---- } } ! } \ No newline at end of file Index: Table.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Table.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Table.cs 16 Apr 2004 04:13:22 -0000 1.13 --- Table.cs 31 Dec 2004 21:28:13 -0000 1.14 *************** *** 1,18 **** - using System; - using System.Text; - using System.Data; using System.Collections; ! using NHibernate.Util; ! using NHibernate.Dialect; ! using NHibernate.Id; using NHibernate.Engine; ! namespace NHibernate.Mapping { /// <summary> /// Represents a Table in a database that an object gets mapped against. /// </summary> ! public class Table : IRelationalModel ! { private string name; private string schema; --- 1,16 ---- using System.Collections; ! using System.Data; ! using System.Text; using NHibernate.Engine; + using NHibernate.Id; + using NHibernate.Util; ! namespace NHibernate.Mapping { /// <summary> /// Represents a Table in a database that an object gets mapped against. /// </summary> ! public class Table : IRelationalModel ! { private string name; private string schema; *************** *** 27,145 **** private static int tableCounter = 0; ! public Table() { uniqueInteger = tableCounter++; } ! public string GetQualifiedName(Dialect.Dialect dialect) { ! string quotedName = GetQuotedName(dialect); ! return schema==null ? quotedName : schema + StringHelper.Dot + quotedName; } ! /// <summary> /// Returns the QualifiedName for the table using the specified Qualifier /// </summary> /// <param name="defaultQualifier">The Qualifier to use when accessing the table.</param> /// <returns>A String representing the Qualified name.</returns> /// <remarks>If this were used with MSSQL it would return a dbo.table_name.</remarks> ! public string GetQualifiedName(Dialect.Dialect dialect, string defaultQualifier) { ! string quotedName = GetQuotedName(dialect); ! return schema==null ? ! ( (defaultQualifier==null) ? quotedName : defaultQualifier + StringHelper.Dot + quotedName ) : ! GetQualifiedName(dialect); } ! public string Name { get { return name; } ! set ! { ! if (value[0]=='`') { quoted = true; ! name = value.Substring(1, value.Length-2); } ! else { ! name = value; } } } ! public string GetQuotedName(Dialect.Dialect dialect) { return IsQuoted ? ! dialect.QuoteForTableName(name): name; } ! public Column GetColumn(int n) { IEnumerator iter = columns.Values.GetEnumerator(); ! for (int i=0; i<n; i++) iter.MoveNext(); ! return (Column) iter.Current; } ! ! public void AddColumn(Column column) { ! Column old = (Column) columns[ column.Name ]; ! if (old == null) { ! columns[column.Name] = column; column.uniqueInteger = columns.Count; ! } ! else { column.uniqueInteger = old.uniqueInteger; } } ! public int ColumnSpan { get { return columns.Count; } } ! public ICollection ColumnCollection { get { return columns.Values; } } public ICollection IndexCollection { get { return indexes.Values; } } ! public ICollection ForeignKeyCollection { get { return foreignKeys.Values; } } ! public ICollection UniqueKeyCollection { get { return uniqueKeys.Values; } } ! public IList SqlAlterStrings(Dialect.Dialect dialect, IMapping p, DataTable tableInfo) { ! StringBuilder root = new StringBuilder("alter table ") ! .Append( GetQualifiedName(dialect) ) ! .Append(" ") .Append( dialect.AddColumnString ); ! IList results = new ArrayList(ColumnCollection.Count); ! foreach(Column col in ColumnCollection) { DataColumn columnInfo = tableInfo.Columns[ col.Name ]; ! if (columnInfo == null) { StringBuilder alter = new StringBuilder( root.ToString() ) ! .Append(" ") ! .Append( col.GetQuotedName(dialect) ) ! .Append(" ") ! .Append(col.GetSqlType(dialect, p)); ! if (col.IsUnique && dialect.SupportsUnique) { ! alter.Append(" unique"); } --- 25,185 ---- private static int tableCounter = 0; ! /// <summary></summary> ! public Table() { uniqueInteger = tableCounter++; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string GetQualifiedName( Dialect.Dialect dialect ) { ! string quotedName = GetQuotedName( dialect ); ! return schema == null ? quotedName : schema + StringHelper.Dot + quotedName; } ! /// <summary> /// Returns the QualifiedName for the table using the specified Qualifier /// </summary> + /// <param name="dialect"></param> /// <param name="defaultQualifier">The Qualifier to use when accessing the table.</param> /// <returns>A String representing the Qualified name.</returns> /// <remarks>If this were used with MSSQL it would return a dbo.table_name.</remarks> ! public string GetQualifiedName( Dialect.Dialect dialect, string defaultQualifier ) { ! string quotedName = GetQuotedName( dialect ); ! return schema == null ? ! ( ( defaultQualifier == null ) ? quotedName : defaultQualifier + StringHelper.Dot + quotedName ) : ! GetQualifiedName( dialect ); } ! /// <summary></summary> ! public string Name { get { return name; } ! set ! { ! if( value[ 0 ] == '`' ) { quoted = true; ! name = value.Substring( 1, value.Length - 2 ); } ! else { ! name = value; } } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string GetQuotedName( Dialect.Dialect dialect ) { return IsQuoted ? ! dialect.QuoteForTableName( name ) : name; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="n"></param> ! /// <returns></returns> ! public Column GetColumn( int n ) { IEnumerator iter = columns.Values.GetEnumerator(); ! for( int i = 0; i < n; i++ ) ! { ! iter.MoveNext(); ! } ! return ( Column ) iter.Current; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="column"></param> ! public void AddColumn( Column column ) { ! Column old = ( Column ) columns[ column.Name ]; ! if( old == null ) { ! columns[ column.Name ] = column; column.uniqueInteger = columns.Count; ! } ! else { column.uniqueInteger = old.uniqueInteger; } } ! ! /// <summary></summary> ! public int ColumnSpan { get { return columns.Count; } } ! ! /// <summary></summary> ! public ICollection ColumnCollection { get { return columns.Values; } } + + /// <summary></summary> public ICollection IndexCollection { get { return indexes.Values; } } ! ! /// <summary></summary> ! public ICollection ForeignKeyCollection { get { return foreignKeys.Values; } } ! ! /// <summary></summary> ! public ICollection UniqueKeyCollection { get { return uniqueKeys.Values; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <param name="p"></param> ! /// <param name="tableInfo"></param> ! /// <returns></returns> ! public IList SqlAlterStrings( Dialect.Dialect dialect, IMapping p, DataTable tableInfo ) { ! StringBuilder root = new StringBuilder( "alter table " ) ! .Append( GetQualifiedName( dialect ) ) ! .Append( " " ) .Append( dialect.AddColumnString ); ! IList results = new ArrayList( ColumnCollection.Count ); ! foreach( Column col in ColumnCollection ) { DataColumn columnInfo = tableInfo.Columns[ col.Name ]; ! if( columnInfo == null ) { StringBuilder alter = new StringBuilder( root.ToString() ) ! .Append( " " ) ! .Append( col.GetQuotedName( dialect ) ) ! .Append( " " ) ! .Append( col.GetSqlType( dialect, p ) ); ! if( col.IsUnique && dialect.SupportsUnique ) { ! alter.Append( " unique" ); } *************** *** 151,213 **** } ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { ! StringBuilder buf = new StringBuilder("create table ") ! .Append( GetQualifiedName(dialect) ) ! .Append( " ("); ! bool identityColumn = idValue!=null && idValue.CreateIdentifierGenerator(dialect) is IdentityGenerator; // try to find out the name of the pk to create it as identity if the identitygenerator is used string pkname = null; ! if (primaryKey != null && identityColumn ) { ! foreach(Column col in primaryKey.ColumnCollection) { ! pkname = col.GetQuotedName(dialect); //should only go through this loop once } } int i = 0; ! foreach(Column col in ColumnCollection) { i++; ! buf.Append( col.GetQuotedName(dialect) ) ! .Append(' ') ! .Append( col.GetSqlType(dialect, p) ); ! if ( identityColumn && col.GetQuotedName(dialect).Equals(pkname) ) { ! buf.Append(' ') ! .Append( dialect.IdentityColumnString); ! } ! else { ! if (col.IsNullable) { buf.Append( dialect.NullColumnString ); ! } ! else { ! buf.Append(" not null" ); } } ! if ( col.IsUnique) { ! if(dialect.SupportsUnique) { ! buf.Append(" unique"); } ! else { ! UniqueKey uk = GetUniqueKey(col.GetQuotedName(dialect) + "_"); ! uk.AddColumn(col); } } ! if ( i < ColumnCollection.Count ) buf.Append(StringHelper.CommaSpace); } ! if (primaryKey != null) { //if ( dialect is HSQLDialect && identityColumn ) { --- 191,262 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <param name="p"></param> ! /// <returns></returns> ! public string SqlCreateString( Dialect.Dialect dialect, IMapping p ) { ! StringBuilder buf = new StringBuilder( "create table " ) ! .Append( GetQualifiedName( dialect ) ) ! .Append( " (" ); ! bool identityColumn = idValue != null && idValue.CreateIdentifierGenerator( dialect ) is IdentityGenerator; // try to find out the name of the pk to create it as identity if the identitygenerator is used string pkname = null; ! if( primaryKey != null && identityColumn ) { ! foreach( Column col in primaryKey.ColumnCollection ) { ! pkname = col.GetQuotedName( dialect ); //should only go through this loop once } } int i = 0; ! foreach( Column col in ColumnCollection ) { i++; ! buf.Append( col.GetQuotedName( dialect ) ) ! .Append( ' ' ) ! .Append( col.GetSqlType( dialect, p ) ); ! if( identityColumn && col.GetQuotedName( dialect ).Equals( pkname ) ) { ! buf.Append( ' ' ) ! .Append( dialect.IdentityColumnString ); ! } ! else { ! if( col.IsNullable ) { buf.Append( dialect.NullColumnString ); ! } ! else { ! buf.Append( " not null" ); } } ! if( col.IsUnique ) { ! if( dialect.SupportsUnique ) { ! buf.Append( " unique" ); } ! else { ! UniqueKey uk = GetUniqueKey( col.GetQuotedName( dialect ) + "_" ); ! uk.AddColumn( col ); } } ! if( i < ColumnCollection.Count ) ! { ! buf.Append( StringHelper.CommaSpace ); ! } } ! if( primaryKey != null ) { //if ( dialect is HSQLDialect && identityColumn ) { *************** *** 215,237 **** // //ugly hack... //} else { ! buf.Append(',').Append( primaryKey.SqlConstraintString(dialect) ); //} } ! ! foreach(UniqueKey uk in UniqueKeyCollection) { ! buf.Append(',').Append( uk.SqlConstraintString(dialect) ); } ! ! buf.Append(StringHelper.ClosedParen); return buf.ToString(); } ! public string SqlDropString(Dialect.Dialect dialect) { ! return "drop table " + GetQualifiedName(dialect) + dialect.CascadeConstraintsString; } ! public PrimaryKey PrimaryKey { get { return primaryKey; } --- 264,293 ---- // //ugly hack... //} else { ! buf.Append( ',' ).Append( primaryKey.SqlConstraintString( dialect ) ); //} } ! ! foreach( UniqueKey uk in UniqueKeyCollection ) { ! buf.Append( ',' ).Append( uk.SqlConstraintString( dialect ) ); } ! ! buf.Append( StringHelper.ClosedParen ); return buf.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string SqlDropString( Dialect.Dialect dialect ) ! { ! return "drop table " + GetQualifiedName( dialect ) + dialect.CascadeConstraintsString; } ! /// <summary></summary> ! public PrimaryKey PrimaryKey { get { return primaryKey; } *************** *** 239,252 **** } ! public Index GetIndex(string name) { ! Index index = (Index) indexes[name]; ! if (index == null) { index = new Index(); index.Name = name; index.Table = this; ! indexes.Add(name, index); } --- 295,313 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <returns></returns> ! public Index GetIndex( string name ) { ! Index index = ( Index ) indexes[ name ]; ! if( index == null ) { index = new Index(); index.Name = name; index.Table = this; ! indexes.Add( name, index ); } *************** *** 254,266 **** } ! public UniqueKey GetUniqueKey(string name) { ! UniqueKey uk = (UniqueKey) uniqueKeys[name]; ! if (uk == null) { uk = new UniqueKey(); uk.Name = name; uk.Table = this; ! uniqueKeys.Add(name, uk); } --- 315,333 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <returns></returns> ! public UniqueKey GetUniqueKey( string name ) { ! UniqueKey uk = ( UniqueKey ) uniqueKeys[ name ]; ! if( uk == null ) ! { uk = new UniqueKey(); uk.Name = name; uk.Table = this; ! uniqueKeys.Add( name, uk ); } *************** *** 268,285 **** } ! public ForeignKey CreateForeignKey(IList columns) { string name = "FK" + UniqueColumnString( columns ); ! ForeignKey fk = (ForeignKey) foreignKeys[name]; ! if (fk == null) { fk = new ForeignKey(); fk.Name = name; fk.Table = this; ! foreignKeys.Add(name, fk); } ! foreach(Column col in columns) { fk.AddColumn( col ); --- 335,357 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columns"></param> ! /// <returns></returns> ! public ForeignKey CreateForeignKey( IList columns ) { string name = "FK" + UniqueColumnString( columns ); ! ForeignKey fk = ( ForeignKey ) foreignKeys[ name ]; ! if( fk == null ) { fk = new ForeignKey(); fk.Name = name; fk.Table = this; ! foreignKeys.Add( name, fk ); } ! foreach( Column col in columns ) { fk.AddColumn( col ); *************** *** 289,298 **** } ! public string UniqueColumnString(ICollection col) { - int result = 0; ! ! foreach(object obj in col) { // this is marked as unchecked because the GetHashCode could potentially --- 361,374 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="col"></param> ! /// <returns></returns> ! public string UniqueColumnString( ICollection col ) { int result = 0; ! ! foreach( object obj in col ) { // this is marked as unchecked because the GetHashCode could potentially *************** *** 300,310 **** // just roll back over - since we are not doing any computations based // on this number then a rollover is no big deal. ! unchecked{ result += obj.GetHashCode(); } } ! ! return ( name.GetHashCode().ToString("X") + result.GetHashCode().ToString("X") ); } ! public string Schema { get { return schema; } --- 376,390 ---- // just roll back over - since we are not doing any computations based // on this number then a rollover is no big deal. ! unchecked ! { ! result += obj.GetHashCode(); ! } } ! ! return ( name.GetHashCode().ToString( "X" ) + result.GetHashCode().ToString( "X" ) ); } ! /// <summary></summary> ! public string Schema { get { return schema; } *************** *** 312,332 **** } ! public int UniqueInteger { get { return uniqueInteger; } } ! public void SetIdentifierValue(Value idValue) { this.idValue = idValue; } ! public bool IsQuoted { get { return quoted; } set { quoted = value; } } ! } ! } --- 392,418 ---- } ! /// <summary></summary> ! public int UniqueInteger { get { return uniqueInteger; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="idValue"></param> ! public void SetIdentifierValue( Value idValue ) { this.idValue = idValue; } ! /// <summary></summary> ! public bool IsQuoted { get { return quoted; } set { quoted = value; } } ! } ! } \ No newline at end of file Index: UniqueKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/UniqueKey.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UniqueKey.cs 13 Apr 2004 02:06:54 -0000 1.4 --- UniqueKey.cs 31 Dec 2004 21:28:13 -0000 1.5 *************** *** 1,49 **** - using System; - using System.Collections; using System.Text; - - using NHibernate.Dialect; using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public class UniqueKey : Constraint { ! public string SqlConstraintString(Dialect.Dialect d) { ! StringBuilder buf = new StringBuilder(" unique ("); bool commaNeeded = false; ! ! foreach(Column col in ColumnCollection) { ! if(commaNeeded) buf.Append( StringHelper.CommaSpace ); commaNeeded = true; ! ! buf.Append( col.GetQuotedName(d) ); ! } ! ! return buf.Append(StringHelper.ClosedParen).ToString(); } ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) { StringBuilder buf = new StringBuilder( ! d.GetAddPrimaryKeyConstraintString(constraintName)) ! .Append('('); ! bool commaNeeded = false; ! foreach(Column col in ColumnCollection) { ! if(commaNeeded) buf.Append( StringHelper.CommaSpace ); commaNeeded = true; ! ! buf.Append( col.GetQuotedName(d) ); ! } ! ! return StringHelper.Replace( buf.Append(StringHelper.ClosedParen).ToString(), "primary key", "unique" ); } } ! } --- 1,63 ---- using System.Text; using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! /// <summary></summary> ! public class UniqueKey : Constraint { ! /// <summary> ! /// ! /// </summary> ! /// <param name="d"></param> ! /// <returns></returns> ! public string SqlConstraintString( Dialect.Dialect d ) { ! StringBuilder buf = new StringBuilder( " unique (" ); bool commaNeeded = false; ! ! foreach( Column col in ColumnCollection ) { ! if( commaNeeded ) ! { ! buf.Append( StringHelper.CommaSpace ); ! } commaNeeded = true; ! ! buf.Append( col.GetQuotedName( d ) ); ! } ! ! return buf.Append( StringHelper.ClosedParen ).ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="d"></param> ! /// <param name="constraintName"></param> ! /// <returns></returns> ! public override string SqlConstraintString( Dialect.Dialect d, string constraintName ) { StringBuilder buf = new StringBuilder( ! d.GetAddPrimaryKeyConstraintString( constraintName ) ) ! .Append( '(' ); ! bool commaNeeded = false; ! foreach( Column col in ColumnCollection ) { ! if( commaNeeded ) ! { ! buf.Append( StringHelper.CommaSpace ); ! } commaNeeded = true; ! ! buf.Append( col.GetQuotedName( d ) ); ! } ! ! return StringHelper.Replace( buf.Append( StringHelper.ClosedParen ).ToString(), "primary key", "unique" ); } } ! } \ No newline at end of file |