You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael D. <mik...@us...> - 2004-04-13 13:16:09
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23306/SqlCommand Modified Files: Parameter.cs ParameterLength.cs ParameterPrecisionScale.cs Log Message: Fixed problem with Quoting Parameters. Named Parameters now have meaningless names such as p0, p1, p2, etc... Index: ParameterLength.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ParameterLength.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParameterLength.cs 15 Mar 2004 14:47:07 -0000 1.2 --- ParameterLength.cs 13 Apr 2004 13:01:59 -0000 1.3 *************** *** 20,24 **** } ! public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider) { IDbDataParameter param = base.GetIDbDataParameter (command, provider); param.Size = length; --- 20,26 ---- } ! [Obsolete("This does not handle quoted identifiers - going to use a number based name.")] ! public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider) ! { IDbDataParameter param = base.GetIDbDataParameter (command, provider); param.Size = length; *************** *** 27,30 **** --- 29,40 ---- } + public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider, string name) + { + IDbDataParameter param = base.GetIDbDataParameter (command, provider, name); + param.Size = length; + + return param; + } + public override bool Equals(object obj) { if(base.Equals(obj)) { Index: Parameter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Parameter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Parameter.cs 15 Mar 2004 14:47:07 -0000 1.3 --- Parameter.cs 13 Apr 2004 13:01:59 -0000 1.4 *************** *** 37,40 **** --- 37,41 ---- } + [Obsolete("This does not handle quoted identifiers - going to use a number based name.")] public string GetSqlName(IConnectionProvider provider){ *************** *** 42,50 **** } public string GetParameterName(IConnectionProvider provider){ return provider.Driver.FormatNameForParameter(tableAlias, name); } ! public virtual IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider) { IDbDataParameter param = command.CreateParameter(); param.DbType = dbType; --- 43,78 ---- } + /// <summary> + /// Returns a string version of the Parameter that is in the correct + /// format for the SQL in the CommandText. + /// </summary> + /// <param name="provider">The ConnectionProvider that contains the Dialect.</param> + /// <param name="name">The name to format for SQL.</param> + /// <returns>A valid SQL string for this Parameter.</returns> + public string GetSqlName(IConnectionProvider provider, string name) + { + return provider.Driver.FormatNameForSql(name); + } + + [Obsolete("This does not handle quoted identifiers - going to use a number based name.")] public string GetParameterName(IConnectionProvider provider){ return provider.Driver.FormatNameForParameter(tableAlias, name); } ! /// <summary> ! /// Returns a string version of the Parameter that is in the correct ! /// format for the IDbDataParameter.Name ! /// </summary> ! /// <param name="provider">The ConnectionProvider that contains the Dialect.</param> ! /// <param name="name">The name to format for the IDbDataParameter.</param> ! /// <returns>A valid IDbDataParameter Name for this Parameter.</returns> ! public string GetParameterName(IConnectionProvider provider, string name) ! { ! return provider.Driver.FormatNameForParameter(name); ! } ! ! [Obsolete("This does not handle quoted identifiers - going to use a number based name.")] ! public virtual IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider) ! { IDbDataParameter param = command.CreateParameter(); param.DbType = dbType; *************** *** 53,56 **** --- 81,93 ---- return param; } + + public virtual IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider, string name) + { + IDbDataParameter param = command.CreateParameter(); + param.DbType = dbType; + param.ParameterName = GetParameterName(provider, name); + + return param; + } /// <summary> Index: ParameterPrecisionScale.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ParameterPrecisionScale.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParameterPrecisionScale.cs 15 Mar 2004 14:47:07 -0000 1.2 --- ParameterPrecisionScale.cs 13 Apr 2004 13:01:59 -0000 1.3 *************** *** 26,30 **** } ! public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider) { IDbDataParameter param = base.GetIDbDataParameter (command, provider); param.Precision = precision; --- 26,32 ---- } ! [Obsolete("This does not handle quoted identifiers - going to use a number based name.")] ! public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider) ! { IDbDataParameter param = base.GetIDbDataParameter (command, provider); param.Precision = precision; *************** *** 34,37 **** --- 36,48 ---- } + public override IDbDataParameter GetIDbDataParameter(IDbCommand command, IConnectionProvider provider, string name) + { + IDbDataParameter param = base.GetIDbDataParameter (command, provider, name); + param.Precision = precision; + param.Scale = scale; + + return param; + } + public override bool Equals(object obj) { if(base.Equals(obj)) { |
From: Michael D. <mik...@us...> - 2004-04-13 13:16:09
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23306/Impl Modified Files: PreparerImpl.cs Log Message: Fixed problem with Quoting Parameters. Named Parameters now have meaningless names such as p0, p1, p2, etc... Index: PreparerImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/PreparerImpl.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PreparerImpl.cs 10 Mar 2004 15:36:46 -0000 1.2 --- PreparerImpl.cs 13 Apr 2004 13:02:00 -0000 1.3 *************** *** 79,83 **** ! public IDbCommand BuildCommand(SqlString sqlString) { if(builtCommands.ContainsKey(sqlString)) --- 79,85 ---- ! public IDbCommand BuildCommand(SqlString sqlString) ! { ! int paramIndex = 0; if(builtCommands.ContainsKey(sqlString)) *************** *** 87,99 **** StringBuilder builder = new StringBuilder(sqlString.SqlParts.Length * 15); ! foreach(object part in sqlString.SqlParts) { Parameter parameter = part as Parameter; ! if(parameter!=null) { ! builder.Append(parameter.GetSqlName(factory.ConnectionProvider)); ! IDbDataParameter dbParam = parameter.GetIDbDataParameter(cmd, factory.ConnectionProvider); cmd.Parameters.Add(dbParam); } ! else { builder.Append((string)part); } --- 89,107 ---- StringBuilder builder = new StringBuilder(sqlString.SqlParts.Length * 15); ! foreach(object part in sqlString.SqlParts) ! { Parameter parameter = part as Parameter; ! if(parameter!=null) ! { ! string paramName = "p" + paramIndex; ! builder.Append( parameter.GetSqlName(factory.ConnectionProvider, paramName) ); ! IDbDataParameter dbParam = parameter.GetIDbDataParameter(cmd, factory.ConnectionProvider, paramName); cmd.Parameters.Add(dbParam); + + paramIndex++; } ! else ! { builder.Append((string)part); } *************** *** 105,109 **** return cmd; - } --- 113,116 ---- |
From: Peter S. <sz...@us...> - 2004-04-13 10:39:47
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24792/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Added dummy formula class, fixed small typo, and foo test entity. Found another quoting problem. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FooBarTest.cs 9 Apr 2004 16:18:01 -0000 1.5 --- FooBarTest.cs 13 Apr 2004 10:25:46 -0000 1.6 *************** *** 31,35 **** // "Container.hbm.xml", // "XY.hbm.xml"}); ! }, false); } --- 31,35 ---- // "Container.hbm.xml", // "XY.hbm.xml"}); ! }, true); } *************** *** 45,48 **** --- 45,49 ---- baz.fooBag=fooBag; s.Save(baz); + s.Flush(); fooBag = baz.fooBag; s.Find("from Baz baz left join fetch baz.fooBag"); |
From: Peter S. <sz...@us...> - 2004-04-13 10:39:47
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24792/NHibernate.DomainModel Modified Files: Foo.cs Log Message: Added dummy formula class, fixed small typo, and foo test entity. Found another quoting problem. Index: Foo.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Foo.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Foo.cs 9 Apr 2004 13:14:53 -0000 1.4 --- Foo.cs 13 Apr 2004 10:25:46 -0000 1.5 *************** *** 190,194 **** /// Holder for version /// </summary> ! private String _version; /// <summary> --- 190,194 ---- /// Holder for version /// </summary> ! private int _version; /// <summary> *************** *** 604,608 **** /// Get/set for version /// </summary> ! public String version { get --- 604,608 ---- /// Get/set for version /// </summary> ! public int version { get |
From: Peter S. <sz...@us...> - 2004-04-13 10:39:47
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24792/NHibernate/Util Modified Files: ReflectHelper.cs Log Message: Added dummy formula class, fixed small typo, and foo test entity. Found another quoting problem. Index: ReflectHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/ReflectHelper.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ReflectHelper.cs 9 Apr 2004 16:18:01 -0000 1.9 --- ReflectHelper.cs 13 Apr 2004 10:25:46 -0000 1.10 *************** *** 25,29 **** property.SetValue(target, value, new object[0]); } catch (Exception e) { ! throw new PropertyAccessException(e, "Exception occurrded", true, clazz, propertyName); } } --- 25,29 ---- property.SetValue(target, value, new object[0]); } catch (Exception e) { ! throw new PropertyAccessException(e, "Exception occurred", true, clazz, propertyName); } } *************** *** 48,52 **** return property.GetValue(target, new object[0]); } catch (Exception e) { ! throw new PropertyAccessException(e, "Exception occurrded", false, clazz, propertyName); } } --- 48,52 ---- return property.GetValue(target, new object[0]); } catch (Exception e) { ! throw new PropertyAccessException(e, "Exception occurred", false, clazz, propertyName); } } |
From: Peter S. <sz...@us...> - 2004-04-13 10:39:47
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24792/NHibernate/Mapping Added Files: Formula.cs Log Message: Added dummy formula class, fixed small typo, and foo test entity. Found another quoting problem. --- NEW FILE: Formula.cs --- using System; using System.Collections; using NHibernate.Dialect; using NHibernate.SqlCommand; using NHibernate.Util; namespace NHibernate.Mapping { public class Formula { private static int formulaUniqueInteger=0; private string formula; private int uniqueInteger; public Formula() { uniqueInteger = formulaUniqueInteger++; } public String getTemplate(Dialect.Dialect dialect) { return Template.RenderWhereStringTemplate(formula, dialect); } public String getAlias() { return "f" + uniqueInteger.ToString() + StringHelper.Underscore; } public string Formul { get { return formula; } set { this.formula = value; } } } } |
From: Peter S. <sz...@us...> - 2004-04-13 10:39:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24792/NHibernate Modified Files: NHibernate-1.1.csproj Log Message: Added dummy formula class, fixed small typo, and foo test entity. Found another quoting problem. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** NHibernate-1.1.csproj 10 Apr 2004 05:07:27 -0000 1.17 --- NHibernate-1.1.csproj 13 Apr 2004 10:25:45 -0000 1.18 *************** *** 1089,1092 **** --- 1089,1097 ---- /> <File + RelPath = "Mapping\Formula.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Mapping\Index.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-04-13 02:49:16
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15524/Mapping Modified Files: Table.cs Log Message: Synching Table with H2.0.3 Index: Table.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Table.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Table.cs 13 Apr 2004 02:06:54 -0000 1.8 --- Table.cs 13 Apr 2004 02:35:21 -0000 1.9 *************** *** 118,125 **** } ! //TODO: NH2.0.3 has an ICollection SqlAlterStrings method instead of this one... ! public string SqlAlterString(Dialect.Dialect dialect, IMapping p, DataTable tableInfo) { ! StringBuilder buf = new StringBuilder(50); foreach(Column col in ColumnCollection) { --- 118,130 ---- } ! 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) { *************** *** 128,148 **** if (columnInfo == null) { ! // the column doesnt exist at all ! if (buf.Length != 0) ! buf.Append(StringHelper.CommaSpace); ! buf.Append(col.GetQuotedName(dialect)) ! .Append(' ') ! .Append(col.GetSqlType(dialect, p)); ! if (col.IsUnique && dialect.SupportsUnique) { ! buf.Append(" unique"); } } } ! if (buf.Length == 0) ! return null; ! ! return new StringBuilder("alter table ").Append(GetQualifiedName(dialect)).Append(" add ").Append(buf).ToString(); ! } --- 133,152 ---- 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"); } + + results.Add( alter.ToString() ); } } ! return results; } *************** *** 157,167 **** // 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) ) --- 161,175 ---- // 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) ) *************** *** 169,189 **** .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 && dialect.SupportsUnique ) { ! buf.Append(" unique"); } if ( i < ColumnCollection.Count ) buf.Append(StringHelper.CommaSpace); } ! if (primaryKey != null) { //if ( dialect is HSQLDialect && identityColumn ) { // //ugly hack... --- 177,214 ---- .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 ) { // //ugly hack... *************** *** 192,200 **** //} } ! if ( dialect.SupportsUnique ) { ! foreach(UniqueKey uk in UniqueKeyCollection) { ! buf.Append(',').Append( uk.SqlConstraintString(dialect) ); ! } } buf.Append(StringHelper.ClosedParen); --- 217,226 ---- //} } ! ! foreach(UniqueKey uk in UniqueKeyCollection) ! { ! buf.Append(',').Append( uk.SqlConstraintString(dialect) ); } + buf.Append(StringHelper.ClosedParen); *************** *** 206,218 **** } ! public PrimaryKey PrimaryKey { get { return primaryKey; } set { primaryKey = value; } } ! public Index GetIndex(string name) { Index index = (Index) indexes[name]; ! if (index == null) { index = new Index(); index.Name = name; --- 232,247 ---- } ! public PrimaryKey PrimaryKey ! { get { return primaryKey; } set { primaryKey = value; } } ! public Index GetIndex(string name) ! { Index index = (Index) indexes[name]; ! if (index == null) ! { index = new Index(); index.Name = name; *************** *** 224,228 **** } ! public UniqueKey GetUniqueKey(string name) { UniqueKey uk = (UniqueKey) uniqueKeys[name]; --- 253,258 ---- } ! public UniqueKey GetUniqueKey(string name) ! { UniqueKey uk = (UniqueKey) uniqueKeys[name]; *************** *** 233,240 **** uniqueKeys.Add(name, uk); } return uk; } ! public ForeignKey CreateForeignKey(IList columns) { string name = "FK" + UniqueColumnString( columns ); ForeignKey fk = (ForeignKey) foreignKeys[name]; --- 263,272 ---- uniqueKeys.Add(name, uk); } + return uk; } ! public ForeignKey CreateForeignKey(IList columns) ! { string name = "FK" + UniqueColumnString( columns ); ForeignKey fk = (ForeignKey) foreignKeys[name]; *************** *** 246,261 **** foreignKeys.Add(name, fk); } ! foreach(Column col in columns) { fk.AddColumn( col ); } return fk; } ! public string UniqueColumnString(ICollection col) { int result = 0; ! foreach(object obj in col) { ! // this is marked as unchecked because the GetHashCode could potentially // cause an integer overflow. This way if there is an overflow it will --- 278,297 ---- foreignKeys.Add(name, fk); } ! ! foreach(Column col in columns) ! { fk.AddColumn( col ); } + return fk; } ! public string UniqueColumnString(ICollection col) ! { int result = 0; ! foreach(object obj in col) ! { // this is marked as unchecked because the GetHashCode could potentially // cause an integer overflow. This way if there is an overflow it will *************** *** 267,283 **** } ! public string Schema { get { return schema; } set { schema = value; } } ! public int UniqueInteger { get { return uniqueInteger; } } ! public void SetIdentifierValue(Value idValue) { this.idValue = idValue; } --- 303,327 ---- } ! public string Schema ! { get { return schema; } set { schema = value; } } ! public int UniqueInteger ! { get { return uniqueInteger; } } ! public void SetIdentifierValue(Value idValue) ! { this.idValue = idValue; } + public bool IsQuoted + { + get { return quoted; } + set { quoted = value; } + } |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11566/Mapping Modified Files: Any.cs Array.cs Association.cs Bag.cs Collection.cs Column.cs Component.cs Constraint.cs ForeignKey.cs Index.cs IndexedCollection.cs IntegerValue.cs IRelationalModel.cs List.cs ManyToOne.cs Map.cs OneToMany.cs OneToOne.cs PersistentClass.cs PrimaryKey.cs PrimitiveArray.cs Property.cs Set.cs Table.cs UniqueKey.cs Value.cs Log Message: Synching Mapping namespace with H2.0.3 - still need to finish Table, PersistentClass, Rootclass, and subclass. Index: PersistentClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PersistentClass.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PersistentClass.cs 12 Apr 2004 05:42:36 -0000 1.8 --- PersistentClass.cs 13 Apr 2004 02:06:54 -0000 1.9 *************** *** 1,11 **** using System; using System.Collections; using NHibernate.Cache; - using NHibernate.Util; using NHibernate.Sql; - namespace NHibernate.Mapping { - - public abstract class PersistentClass { private System.Type persistentClass; private string discriminatorValue; --- 1,17 ---- using System; using System.Collections; + using NHibernate.Cache; using NHibernate.Sql; + using NHibernate.Util; + + namespace NHibernate.Mapping + { + //TODO: H2.0.3 - there are some "set" declared on properties that I am not sure about - need + // to double check those. + public abstract class PersistentClass + { + private static readonly Alias PKAlias = new Alias(15, "PK"); private System.Type persistentClass; private string discriminatorValue; *************** *** 13,43 **** private Table table; private System.Type proxyInterface; - private bool dynamicUpdate; private readonly ArrayList subclasses = new ArrayList(); private readonly ArrayList subclassProperties = new ArrayList(); private readonly ArrayList subclassTables = new ArrayList(); ! public virtual bool DynamicUpdate { get { return dynamicUpdate; } set { dynamicUpdate = value ; } } ! public virtual string DiscriminatorValue { get { return discriminatorValue; } set { discriminatorValue = value; } } ! public virtual void AddSubclass(Subclass subclass) { subclasses.Add(subclass); } ! public virtual bool HasSubclasses { get { return subclasses.Count > 0; } } ! public virtual int SubclassSpan { ! get { int n = subclasses.Count; ! foreach(Subclass sc in subclasses) { n += sc.SubclassSpan; } --- 19,63 ---- private Table table; private System.Type proxyInterface; private readonly ArrayList subclasses = new ArrayList(); private readonly ArrayList subclassProperties = new ArrayList(); private readonly ArrayList subclassTables = new ArrayList(); + private bool dynamicInsert; + private bool dynamicUpdate; + + public virtual bool DynamicInsert + { + get { return dynamicInsert; } + set { dynamicInsert = value ; } + } ! public virtual bool DynamicUpdate ! { get { return dynamicUpdate; } set { dynamicUpdate = value ; } } ! public virtual string DiscriminatorValue ! { get { return discriminatorValue; } set { discriminatorValue = value; } } ! public virtual void AddSubclass(Subclass subclass) ! { subclasses.Add(subclass); } ! public virtual bool HasSubclasses ! { get { return subclasses.Count > 0; } } ! public virtual int SubclassSpan ! { ! get ! { int n = subclasses.Count; ! foreach(Subclass sc in subclasses) ! { n += sc.SubclassSpan; } *************** *** 51,55 **** /// it will pick those up also. /// </summary> ! public virtual ICollection SubclassCollection { get { ArrayList retVal = new ArrayList(); --- 71,76 ---- /// it will pick those up also. /// </summary> ! public virtual ICollection SubclassCollection ! { get { ArrayList retVal = new ArrayList(); *************** *** 69,123 **** } ! public virtual ICollection DirectSubclasses { get { return subclasses; } } ! public virtual void AddProperty(Property p) { properties.Add(p); } ! public virtual Table Table { get { return table; } set { table = value; } } ! public virtual ICollection PropertyCollection { get { return properties; } } ! public virtual System.Type PersistentClazz { get { return persistentClass; } set { persistentClass = value; } } ! public virtual string Name { get { return persistentClass.FullName; } } ! public abstract bool IsMutable { get; set;} public abstract bool HasIdentifierProperty { get; } ! public abstract Property IdentifierProperty { get; set; } ! public abstract Value Identifier { get; set; } ! public abstract Property Version { get; set; } ! public abstract Value Discriminator { get; set; } ! public abstract bool IsInherited { get; } // see the comment in RootClass about why the polymorphic setter is commented out public abstract bool IsPolymorphic { get; } //set; } public abstract bool IsVersioned { get;} ! public abstract ICacheConcurrencyStrategy Cache { get; set;} ! public abstract PersistentClass Superclass { get; set; } ! public abstract bool IsExplicitPolymorphism { get; set;} public abstract ICollection PropertyClosureCollection { get; } public abstract ICollection TableClosureCollection { get; } ! public virtual void AddSubclassProperty(Property p) { subclassProperties.Add(p); } ! public virtual void AddSubclassTable(Table table) { subclassTables.Add(table); } ! public virtual ICollection SubclassPropertyClosureCollection { ! get { ArrayList retVal = new ArrayList(); retVal.AddRange( PropertyClosureCollection ); --- 90,156 ---- } ! public virtual ICollection DirectSubclasses ! { get { return subclasses; } } ! public virtual void AddProperty(Property p) ! { properties.Add(p); } ! public virtual Table Table ! { get { return table; } set { table = value; } } ! public virtual ICollection PropertyCollection ! { get { return properties; } } ! public virtual System.Type PersistentClazz ! { get { return persistentClass; } set { persistentClass = value; } } ! public virtual string Name ! { get { return persistentClass.FullName; } } ! public abstract bool IsMutable { get; set;} // set?? public abstract bool HasIdentifierProperty { get; } ! public abstract Property IdentifierProperty { get; set; } //set?? ! public abstract Value Identifier { get; set; } //set?? ! public abstract Property Version { get; set; } //set?? ! public abstract Value Discriminator { get; set; } //set?? ! public abstract bool IsInherited { get; } // see the comment in RootClass about why the polymorphic setter is commented out public abstract bool IsPolymorphic { get; } //set; } public abstract bool IsVersioned { get;} ! public abstract ICacheConcurrencyStrategy Cache { get; set;} //set?? ! public abstract PersistentClass Superclass { get; set; } //set?? ! public abstract bool IsExplicitPolymorphism { get; set;}//set?? public abstract ICollection PropertyClosureCollection { get; } public abstract ICollection TableClosureCollection { get; } ! public virtual void AddSubclassProperty(Property p) ! { subclassProperties.Add(p); } ! ! public virtual void AddSubclassTable(Table table) ! { subclassTables.Add(table); } ! ! public virtual ICollection SubclassPropertyClosureCollection ! { ! get ! { ArrayList retVal = new ArrayList(); retVal.AddRange( PropertyClosureCollection ); *************** *** 132,137 **** /// </summary> /// <remarks>It adds the TableClosureCollection and the subclassTables into the ICollection.</remarks> ! public virtual ICollection SubclassTableClosureCollection { ! get { ArrayList retVal = new ArrayList(); retVal.AddRange( TableClosureCollection ); --- 165,172 ---- /// </summary> /// <remarks>It adds the TableClosureCollection and the subclassTables into the ICollection.</remarks> ! public virtual ICollection SubclassTableClosureCollection ! { ! get ! { ArrayList retVal = new ArrayList(); retVal.AddRange( TableClosureCollection ); *************** *** 140,144 **** } } ! public virtual System.Type ProxyInterface { get { return proxyInterface; } set { proxyInterface = value ; } --- 175,180 ---- } } ! public virtual System.Type ProxyInterface ! { get { return proxyInterface; } set { proxyInterface = value ; } *************** *** 146,174 **** public virtual bool IsForceDiscriminator { ! get { ! return false; ! } ! set { } } ! public abstract bool HasEmbeddedIdentifier { get; set;} ! public abstract System.Type Persister { get; set;} public abstract Table RootTable { get; } public abstract RootClass RootClazz { get; } ! public abstract Value Key { get; set; } ! public virtual void CreatePrimaryKey() { PrimaryKey pk = new PrimaryKey(); pk.Table = table; ! pk.Name = StringHelper.Suffix( table.Name, "PK" ); table.PrimaryKey = pk; ! foreach(Column col in Key.ColumnCollection) { pk.AddColumn(col); } } ! private static readonly Alias PKAlias = new Alias(15, "PK"); } } --- 182,216 ---- public virtual bool IsForceDiscriminator { ! get { return false; } ! set { //??? } } ! public abstract bool HasEmbeddedIdentifier { get; set;} //set?? ! public abstract System.Type Persister { get; set;} //set?? public abstract Table RootTable { get; } public abstract RootClass RootClazz { get; } ! public abstract Value Key { get; set; } //set?? ! public virtual void CreatePrimaryKey() ! { PrimaryKey pk = new PrimaryKey(); pk.Table = table; ! pk.Name = PKAlias.ToAliasString(table.Name); // StringHelper.Suffix( table.Name, "PK" ); table.PrimaryKey = pk; ! foreach(Column col in Key.ColumnCollection) ! { pk.AddColumn(col); } } ! //TODO: H2.0.3 - make abstract... ! public virtual string Where ! { ! get { return ""; } ! } ! ! } } Index: ManyToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ManyToOne.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ManyToOne.cs 4 Mar 2003 03:59:28 -0000 1.2 --- ManyToOne.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 3,23 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class ManyToOne : Association { public ManyToOne(Table table) : base(table) { } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) { ! try { if (Type==null) Type = TypeFactory.ManyToOne( ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType); ! } catch (HibernateException he) { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() { ! CreateForeignKeyOfClass( ( (EntityType)Type).PersistentClass); } } --- 3,29 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class ManyToOne : Association ! { public ManyToOne(Table table) : base(table) { } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) ! { ! try ! { if (Type==null) Type = TypeFactory.ManyToOne( ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType); ! } ! catch (HibernateException he) ! { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() ! { ! CreateForeignKeyOfClass( ( (EntityType)Type).PersistentClass ); } } Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Map.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Map.cs 10 Feb 2004 18:35:30 -0000 1.3 --- Map.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 1,22 **** using System; using NHibernate.Type; ! using SortedMap = NHibernate.Collection.SortedMap; ! using Map = NHibernate.Collection.Map; ! namespace NHibernate.Mapping { ! public class Map : IndexedCollection { public Map(PersistentClass owner) : base(owner) { } ! public override PersistentCollectionType Type { ! //TODO: fix up when SortedMap is implemented. //get { return IsSorted ? TypeFactory.SortedMap( Role, Comparator ) : TypeFactory.Map( Role ); get { return TypeFactory.Map( Role ); } //TODO: get sorted } ! public override System.Type WrapperClass { ! get { return IsSorted ? typeof(SortedMap) : typeof(Map); } } --- 1,26 ---- using System; + using NHibernate.Type; ! using NHCollection = NHibernate.Collection; ! namespace NHibernate.Mapping ! { public class Map : IndexedCollection { public Map(PersistentClass owner) : base(owner) { } ! public override PersistentCollectionType Type ! { ! //TODO: H2.0.3 - fix up when SortedMap is implemented. //get { return IsSorted ? TypeFactory.SortedMap( Role, Comparator ) : TypeFactory.Map( Role ); get { return TypeFactory.Map( Role ); } //TODO: get sorted } ! public override System.Type WrapperClass ! { ! //TODO: H2.0.3 - fix up when SortedMap is implemented. ! //get { return IsSorted ? typeof(NHCollection.SortedMap) : typeof(NHCollection.Map); } ! get { return typeof(NHCollection.Map); } } Index: Property.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Property.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Property.cs 22 Apr 2003 19:46:37 -0000 1.5 --- Property.cs 13 Apr 2004 02:06:54 -0000 1.6 *************** *** 4,71 **** using NHibernate.Engine; ! namespace NHibernate.Mapping { ! ! public class Property { private string name; ! private Value value; private string cascade; private bool updateable; private bool insertable; ! public Property(Value value) { ! this.value = value; } ! public IType Type { ! get { return value.Type; } } ! public int ColumnSpan { ! get { return value.ColumnSpan; } } ! public ICollection ColumnCollection { ! get { return value.ColumnCollection; } } ! public string Name { get { return name; } set { name = value; } } ! public bool IsUpdateable { get { return updateable; } set { updateable = value; } } ! public bool IsComposite { ! get { return value is Component; } } ! public Value Value { ! get { return value; } ! set { this.value = value; } } ! public Cascades.CascadeStyle CascadeStyle { get { ! IType type = value.Type; ! if (type.IsComponentType && !type.IsObjectType) { ! IAbstractComponentType actype = (IAbstractComponentType) value.Type; int length = actype.Subtypes.Length; ! for (int i=0; i<length; i++) { if ( actype.Cascade(i)!= Cascades.CascadeStyle.StyleNone ) return Cascades.CascadeStyle.StyleAll; } return Cascades.CascadeStyle.StyleNone; ! } else { ! if (cascade.Equals("all")) { return Cascades.CascadeStyle.StyleAll; ! } else if (cascade.Equals("none")) { return Cascades.CascadeStyle.StyleNone; ! } else if (cascade.Equals("save/update") || cascade.Equals("save-update")) { return Cascades.CascadeStyle.StyleSaveUpdate; ! } else if (cascade.Equals("delete")) { return Cascades.CascadeStyle.StyleOnlyDelete; ! } else { throw new MappingException("Unspported cascade style: " + cascade); } --- 4,99 ---- using NHibernate.Engine; ! namespace NHibernate.Mapping ! { ! public class Property ! { private string name; ! private Value propertyValue; private string cascade; private bool updateable; private bool insertable; ! public Property(Value propertyValue) ! { ! this.propertyValue = propertyValue; } ! public IType Type ! { ! get { return propertyValue.Type; } } ! public int ColumnSpan ! { ! get { return propertyValue.ColumnSpan; } } ! public ICollection ColumnCollection ! { ! get { return propertyValue.ColumnCollection; } } ! public string Name ! { get { return name; } set { name = value; } } ! public bool IsUpdateable ! { get { return updateable; } set { updateable = value; } } ! public bool IsComposite ! { ! get { return propertyValue is Component; } } ! public Value Value ! { ! get { return propertyValue; } ! set { this.propertyValue = value; } } ! public Cascades.CascadeStyle CascadeStyle ! { get { ! IType type = propertyValue.Type; ! if (type.IsComponentType && !type.IsObjectType) ! { ! IAbstractComponentType actype = (IAbstractComponentType) propertyValue.Type; int length = actype.Subtypes.Length; ! for (int i=0; i<length; i++) ! { if ( actype.Cascade(i)!= Cascades.CascadeStyle.StyleNone ) return Cascades.CascadeStyle.StyleAll; } + return Cascades.CascadeStyle.StyleNone; ! } ! else ! { ! if (cascade.Equals("all")) ! { return Cascades.CascadeStyle.StyleAll; ! } ! else if (cascade.Equals("all-delete-orphan") ) ! { ! return Cascades.CascadeStyle.StyleAllGC; ! } ! else if (cascade.Equals("none")) ! { return Cascades.CascadeStyle.StyleNone; ! } ! else if (cascade.Equals("save-update")) ! { return Cascades.CascadeStyle.StyleSaveUpdate; ! } ! else if (cascade.Equals("delete")) ! { return Cascades.CascadeStyle.StyleOnlyDelete; ! } ! else ! { throw new MappingException("Unspported cascade style: " + cascade); } *************** *** 74,78 **** } ! public string Cascade { get { return cascade; } set { cascade = value; } --- 102,107 ---- } ! public string Cascade ! { get { return cascade; } set { cascade = value; } *************** *** 80,86 **** public bool IsInsertable { ! get { return insertable; } set { insertable = value; } } } } \ No newline at end of file --- 109,125 ---- public bool IsInsertable { ! get { return insertable && !IsFormula; } set { insertable = value; } } + + public Formula Formula + { + get { return propertyValue.Formula; } + } + + public bool IsFormula + { + get { return Formula!=null; } + } } } \ No newline at end of file Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/List.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** List.cs 4 Mar 2003 16:38:12 -0000 1.5 --- List.cs 13 Apr 2004 02:06:54 -0000 1.6 *************** *** 1,21 **** using System; using NHibernate.Type; ! using HibernateList=NHibernate.Collection.List; ! namespace NHibernate.Mapping { ! /// <summary> /// A list has a primary key consisting of the key columns + index column /// </summary> ! public class List : IndexedCollection { ! ! public List(PersistentClass owner) : base(owner) { } ! public override PersistentCollectionType Type { get { return TypeFactory.List( Role ); } } ! public override System.Type WrapperClass { ! get { return typeof(HibernateList); } } --- 1,26 ---- using System; + using NHibernate.Type; ! using NHCollection = NHibernate.Collection; ! namespace NHibernate.Mapping ! { /// <summary> /// A list has a primary key consisting of the key columns + index column /// </summary> ! public class List : IndexedCollection ! { ! public List(PersistentClass owner) : base(owner) ! { ! } ! public override PersistentCollectionType Type ! { get { return TypeFactory.List( Role ); } } ! public override System.Type WrapperClass ! { ! get { return typeof(NHCollection.List); } } Index: Collection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Collection.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Collection.cs 10 Feb 2004 18:35:30 -0000 1.4 --- Collection.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 6,12 **** using NHibernate.Util; ! namespace NHibernate.Mapping { ! public abstract class Collection { public const string DefaultElementColumnName = "elt"; public const string DefaultKeyColumnName = "id"; --- 6,14 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public abstract class Collection ! { public const string DefaultElementColumnName = "elt"; public const string DefaultKeyColumnName = "id"; *************** *** 25,74 **** private PersistentClass owner; private bool sorted; - //private object comparator; //should be Comparator private IComparer comparer; ! protected Collection(PersistentClass owner) { this.owner = owner; } ! public virtual bool IsSet { get { return false; } } ! public Value Key { get { return key; } set { key = value; } } ! public Value Element { get { return element; } set { element = value; } } ! public virtual bool IsIndexed { get { return false; } } ! public Table Table { get { return table; } set { table = value; } } ! public bool IsSorted { get { return sorted; } set { sorted = value; } } ! public IComparer Comparer { get { return comparer; } set { comparer = value; } } ! public bool IsLazy { get { return lazy; } set { lazy = value; } } ! public string Role { get { return role; } set { role = value; } --- 27,86 ---- private PersistentClass owner; private bool sorted; private IComparer comparer; + private bool orphanDelete; ! protected Collection(PersistentClass owner) ! { this.owner = owner; } ! public virtual bool IsSet ! { get { return false; } } ! public Value Key ! { get { return key; } set { key = value; } } ! public Value Element ! { get { return element; } set { element = value; } } ! public virtual bool IsIndexed ! { get { return false; } } ! public Table Table ! { get { return table; } set { table = value; } } ! public bool IsSorted ! { get { return sorted; } set { sorted = value; } } ! public IComparer Comparer ! { get { return comparer; } set { comparer = value; } } ! public bool IsLazy ! { get { return lazy; } set { lazy = value; } } ! public string Role ! { get { return role; } set { role = value; } *************** *** 78,99 **** public abstract System.Type WrapperClass { get; } ! public virtual bool IsPrimitiveArray { get { return false; } } ! public virtual bool IsArray { get { return false; } } ! public bool IsOneToMany { get { return isOneToMany; } set { isOneToMany = value; } } ! public OneToMany OneToMany { get { return oneToMany; } set { oneToMany = value; } } public Index CreateIndex() { string name = "IX" + table.UniqueColumnString( Key.ColumnCollection ); --- 90,121 ---- public abstract System.Type WrapperClass { get; } ! public virtual bool IsPrimitiveArray ! { get { return false; } } ! public virtual bool IsArray ! { get { return false; } } ! public virtual bool IsIdentified ! { ! get { return false; } ! } ! ! public bool IsOneToMany ! { get { return isOneToMany; } set { isOneToMany = value; } } ! public OneToMany OneToMany ! { get { return oneToMany; } set { oneToMany = value; } } + //TODO: H2.0.3 - not in this class - where did it move to??? public Index CreateIndex() { string name = "IX" + table.UniqueColumnString( Key.ColumnCollection ); *************** *** 110,114 **** } ! public bool IsInverse { get { return inverse; } set { inverse = value; } --- 132,137 ---- } ! public bool IsInverse ! { get { return inverse; } set { inverse = value; } *************** *** 119,136 **** } ! public PersistentClass Owner { get { return owner; } set { owner = value; } } ! public string OrderBy { get { return orderBy; } set { orderBy = value; } } ! public string Where { get { return where; } set { where = value; } } } } --- 142,169 ---- } ! public PersistentClass Owner ! { get { return owner; } set { owner = value; } } ! public string OrderBy ! { get { return orderBy; } set { orderBy = value; } } ! public string Where ! { get { return where; } set { where = value; } } + + public bool OrphanDelete + { + get { return orphanDelete; } + set { orphanDelete = value; } + } + } } Index: OneToMany.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToMany.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OneToMany.cs 4 Mar 2003 03:59:28 -0000 1.2 --- OneToMany.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 2,21 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class OneToMany { private EntityType type; private Table referencingTable; ! public EntityType Type { get { return type; } set { type = value; } } ! public OneToMany(PersistentClass owner) { this.referencingTable = (owner==null) ? null : owner.Table; } ! public Table ReferencingTable { get { return referencingTable; } } --- 2,25 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class OneToMany ! { private EntityType type; private Table referencingTable; ! public EntityType Type ! { get { return type; } set { type = value; } } ! public OneToMany(PersistentClass owner) ! { this.referencingTable = (owner==null) ? null : owner.Table; } ! public Table ReferencingTable ! { get { return referencingTable; } } Index: Constraint.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Constraint.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Constraint.cs 10 Apr 2004 05:06:02 -0000 1.3 --- Constraint.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 6,43 **** using NHibernate.Util; ! namespace NHibernate.Mapping { ! ! public abstract class Constraint : IRelationalModel { private string name; private ArrayList columns = new ArrayList(); private Table table; ! public string Name { get { return name; } set { name = value; } } ! public ICollection ColumnCollection { get { return columns; } } ! public void AddColumn(Column column) { if ( !columns.Contains(column) ) columns.Add(column); } ! public int ColumnSpan { get { return columns.Count; } } ! public Table Table { get { return table; } set { table = value; } } ! public string SqlDropString(Dialect.Dialect dialect) { return "alter table " + Table.GetQualifiedName(dialect)+ " drop constraint " + Name; } ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("alter table ") .Append( Table.GetQualifiedName(dialect) ) --- 6,51 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public abstract class Constraint : IRelationalModel ! { private string name; private ArrayList columns = new ArrayList(); private Table table; ! public string Name ! { get { return name; } set { name = value; } } ! public ICollection ColumnCollection ! { get { return columns; } } ! public void AddColumn(Column column) ! { if ( !columns.Contains(column) ) columns.Add(column); } ! public int ColumnSpan ! { get { return columns.Count; } } ! public Table Table ! { get { return table; } set { table = value; } } ! public string SqlDropString(Dialect.Dialect dialect) ! { return "alter table " + Table.GetQualifiedName(dialect)+ " drop constraint " + Name; } ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) ! { StringBuilder buf = new StringBuilder("alter table ") .Append( Table.GetQualifiedName(dialect) ) Index: PrimaryKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PrimaryKey.cs 10 Apr 2004 05:06:02 -0000 1.4 --- PrimaryKey.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 5,16 **** using NHibernate.Util; ! namespace NHibernate.Mapping { ! ! public class PrimaryKey : Constraint { ! public string SqlConstraintString(Dialect.Dialect d) { StringBuilder buf = new StringBuilder(" primary key ("); int i=0; ! foreach(Column col in ColumnCollection) { buf.Append(col.GetQuotedName(d)); if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); --- 5,19 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public class PrimaryKey : Constraint ! { ! public string SqlConstraintString(Dialect.Dialect d) ! { StringBuilder buf = new StringBuilder(" primary key ("); int i=0; ! foreach(Column col in ColumnCollection) ! { buf.Append(col.GetQuotedName(d)); if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); *************** *** 20,29 **** } ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) { StringBuilder buf = new StringBuilder( d.GetAddPrimaryKeyConstraintString(constraintName)) .Append('('); int i=0; ! foreach(Column col in ColumnCollection) { buf.Append( col.GetQuotedName(d) ); if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); --- 23,34 ---- } ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) ! { StringBuilder buf = new StringBuilder( d.GetAddPrimaryKeyConstraintString(constraintName)) .Append('('); int i=0; ! foreach(Column col in ColumnCollection) ! { buf.Append( col.GetQuotedName(d) ); if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); Index: IRelationalModel.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IRelationalModel.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IRelationalModel.cs 26 Feb 2003 20:41:59 -0000 1.1 --- IRelationalModel.cs 13 Apr 2004 02:06:54 -0000 1.2 *************** *** 3,9 **** using NHibernate.Engine; ! namespace NHibernate.Mapping { ! ! public interface IRelationalModel { string SqlCreateString(Dialect.Dialect dialect, IMapping p); string SqlDropString(Dialect.Dialect dialect); --- 3,10 ---- using NHibernate.Engine; ! namespace NHibernate.Mapping ! { ! public interface IRelationalModel ! { string SqlCreateString(Dialect.Dialect dialect, IMapping p); string SqlDropString(Dialect.Dialect dialect); Index: Component.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Component.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Component.cs 17 Mar 2003 21:13:52 -0000 1.4 --- Component.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 3,31 **** using System.Collections; ! namespace NHibernate.Mapping { ! ! public class Component : Value { private ArrayList properties = new ArrayList(); private System.Type componentClass; private bool embedded; private string parentProperty; private PersistentClass owner; ! public int PropertySpan { get { return properties.Count; } } ! public ICollection PropertyCollection { get { return properties; } } ! public void AddProperty(Property p) { properties.Add(p); } ! public override void AddColumn(Column column) { throw new NotSupportedException("Cant add a column to a component"); } ! public override int ColumnSpan { ! get { int n=0; ! foreach(Property p in PropertyCollection) { n+= p.ColumnSpan; } --- 3,45 ---- using System.Collections; ! namespace NHibernate.Mapping ! { ! public class Component : Value ! { private ArrayList properties = new ArrayList(); private System.Type componentClass; + // TODO: H2.0.3 - make sure this is gone from the mapping file... + //private BasicDynaClass dynaClass private bool embedded; private string parentProperty; private PersistentClass owner; ! public int PropertySpan ! { get { return properties.Count; } } ! ! public ICollection PropertyCollection ! { get { return properties; } } ! ! public void AddProperty(Property p) ! { properties.Add(p); } ! ! public override void AddColumn(Column column) ! { throw new NotSupportedException("Cant add a column to a component"); } ! ! public override int ColumnSpan ! { ! get ! { int n=0; ! foreach(Property p in PropertyCollection) ! { n+= p.ColumnSpan; } *************** *** 35,39 **** public override ICollection ColumnCollection { ! get { ArrayList retVal = new ArrayList(); foreach(Property prop in PropertyCollection) { --- 49,54 ---- public override ICollection ColumnCollection { ! get ! { ArrayList retVal = new ArrayList(); foreach(Property prop in PropertyCollection) { *************** *** 44,83 **** } ! public Component(PersistentClass owner) : base(owner.Table) { this.owner = owner; } ! public Component(Table table) : base(table) { this.owner = null; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) { } ! public bool IsEmbedded { get { return embedded; } set { embedded = value; } } ! public override bool IsComposite { get { return true; } } ! public System.Type ComponentClass { get { return componentClass; } set { componentClass = value; } } ! public PersistentClass Owner { get { return owner; } set { owner = value; } } ! public string ParentProperty { get { return parentProperty; } set { parentProperty = value; } } ! public ArrayList Properties { get { return properties; } } --- 59,107 ---- } ! public Component(PersistentClass owner) : base(owner.Table) ! { this.owner = owner; } ! public Component(Table table) : base(table) ! { this.owner = null; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) ! { } ! public bool IsEmbedded ! { get { return embedded; } set { embedded = value; } } ! public override bool IsComposite ! { get { return true; } } ! public System.Type ComponentClass ! { get { return componentClass; } set { componentClass = value; } } ! public PersistentClass Owner ! { get { return owner; } set { owner = value; } } ! public string ParentProperty ! { get { return parentProperty; } set { parentProperty = value; } } ! public ArrayList Properties ! { get { return properties; } } Index: IntegerValue.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IntegerValue.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IntegerValue.cs 10 Feb 2004 18:35:30 -0000 1.3 --- IntegerValue.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 2,12 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class IntegerValue : Value{ ! public IntegerValue(Table table) : base(table) { } ! public override IType Type { get { return NHibernate.Int32; } } --- 2,13 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class IntegerValue : Value ! { public IntegerValue(Table table) : base(table) { } ! public override IType Type ! { get { return NHibernate.Int32; } } Index: UniqueKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/UniqueKey.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UniqueKey.cs 10 Apr 2004 05:06:02 -0000 1.3 --- UniqueKey.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 1,14 **** using System; - using System.Text; using System.Collections; ! using NHibernate.Util; using NHibernate.Dialect; namespace NHibernate.Mapping ! { ! public class UniqueKey : Constraint { - public string SqlConstraintString(Dialect.Dialect d) { --- 1,13 ---- 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) { Index: Value.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Value.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Value.cs 22 Apr 2003 19:46:38 -0000 1.8 --- Value.cs 13 Apr 2004 02:06:54 -0000 1.9 *************** *** 7,11 **** using NHibernate.Util; ! namespace NHibernate.Mapping { /// <summary> /// A value represents a simple thing that maps down to a table column or columns. --- 7,12 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { /// <summary> /// A value represents a simple thing that maps down to a table column or columns. *************** *** 13,17 **** /// of this class /// </summary> ! public class Value { private ArrayList columns = new ArrayList(); private IType type; --- 14,19 ---- /// of this class /// </summary> ! public class Value ! { private ArrayList columns = new ArrayList(); private IType type; *************** *** 20,47 **** private string nullValue; private Table table; ! 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; col.TypeIndex = count++; --- 22,60 ---- private string nullValue; private Table table; + 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; col.TypeIndex = count++; *************** *** 50,94 **** } ! public Table Table { get { return table; } set { table = value; } } ! public virtual void CreateForeignKey() { } ! public void CreateForeignKeyOfClass(System.Type persistentClass) { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); fk.ReferencedClass = persistentClass; } ! public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect) { ! ! return IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect); } ! 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; col.TypeIndex = count++; } } ! } 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(); ! } } --- 63,125 ---- } ! public Table Table ! { get { return table; } set { table = value; } } ! public virtual void CreateForeignKey() ! { } ! public void CreateForeignKeyOfClass(System.Type persistentClass) ! { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); fk.ReferencedClass = persistentClass; } ! private IIdentifierGenerator uniqueIdentifierGenerator; ! ! public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect) ! { ! if ( uniqueIdentifierGenerator==null ) ! { ! uniqueIdentifierGenerator = IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect); ! } + return uniqueIdentifierGenerator; } ! 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; col.TypeIndex = count++; } } ! } ! 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; } ! set { identifierGeneratorProperties = value; } } *************** *** 98,105 **** } ! public IDictionary IdentifierGeneratorProperties { ! get { return identifierGeneratorProperties; } ! set { identifierGeneratorProperties = value; } ! } public virtual bool IsComposite { --- 129,133 ---- } ! public virtual bool IsComposite { *************** *** 107,120 **** } ! public string NullValue { get { return nullValue; } set { nullValue = value; } } ! public virtual bool IsAny { ! get { ! return false; ! } ! } } } --- 135,155 ---- } ! public string NullValue ! { get { return nullValue; } set { nullValue = value; } } ! public virtual bool IsAny ! { ! get { return false; } ! } ! ! ! public Formula Formula ! { ! get { return formula; } ! set { formula = value; } ! } } } Index: Any.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Any.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Any.cs 10 Feb 2004 18:35:30 -0000 1.3 --- Any.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 10,20 **** private IType metaType = TypeFactory.GetTypeType(); ! public Any(Table table) : base(table){ } ! public override bool IsAny { ! get { ! return true; ! } } --- 10,20 ---- private IType metaType = TypeFactory.GetTypeType(); ! public Any(Table table) : base(table) ! { } ! public override bool IsAny ! { ! get { return true; } } *************** *** 22,41 **** /// Get or set the identifier type /// </summary> ! public virtual IType IdentifierType { ! get { ! return identifierType; ! } ! set { ! this.identifierType = value; ! } } ! public override IType Type { ! get { ! return new ObjectType(metaType, identifierType); ! } ! set { ! throw new NotSupportedException("cannot set type of an Any"); ! } } --- 22,35 ---- /// Get or set the identifier type /// </summary> ! public virtual IType IdentifierType ! { ! get { return identifierType; } ! set { this.identifierType = value; } } ! public override IType Type ! { ! get { return new ObjectType(metaType, identifierType); } ! set { throw new NotSupportedException("cannot set type of an Any"); } } *************** *** 45,55 **** /// Get or set the metatype /// </summary> ! public virtual IType MetaType { ! get { ! return metaType; ! } ! set { ! metaType = value; ! } } } --- 39,46 ---- /// Get or set the metatype /// </summary> ! public virtual IType MetaType ! { ! get { return metaType; } ! set { metaType = value; } } } Index: Association.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Association.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Association.cs 4 Mar 2003 03:59:27 -0000 1.2 --- Association.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 2,13 **** using NHibernate.Loader; ! namespace NHibernate.Mapping { ! public abstract class Association : Value { private OuterJoinLoaderType joinedFetch; protected Association(Table table) : base(table) {} ! public override OuterJoinLoaderType OuterJoinFetchSetting { get { return joinedFetch; } set { joinedFetch = value; } --- 2,16 ---- using NHibernate.Loader; ! namespace NHibernate.Mapping ! { ! public abstract class Association : Value ! { private OuterJoinLoaderType joinedFetch; protected Association(Table table) : base(table) {} ! public override OuterJoinLoaderType OuterJoinFetchSetting ! { get { return joinedFetch; } set { joinedFetch = value; } Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Set.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Set.cs 8 Apr 2004 21:11:32 -0000 1.3 --- Set.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 4,9 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! /// <summary> /// A Set with no nullable element columns will have a primary --- 4,9 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { /// <summary> /// A Set with no nullable element columns will have a primary *************** *** 11,15 **** /// element columns). /// </summary> ! public class Set : Collection { public Set(PersistentClass owner) : base(owner) { } --- 11,16 ---- /// element columns). /// </summary> ! public class Set : Collection ! { public Set(PersistentClass owner) : base(owner) { } *************** *** 18,23 **** /// <see cref="Collection.IsSet"/> /// </summary> ! public override bool IsSet { ! get {return true; } } --- 19,25 ---- /// <see cref="Collection.IsSet"/> /// </summary> ! public override bool IsSet ! { ! get { return true; } } *************** *** 25,30 **** /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType Type { ! get { //TODO: modify when added implementation of sorted set return IsSorted ? --- 27,34 ---- /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType Type ! { ! get ! { //TODO: modify when added implementation of sorted set return IsSorted ? *************** *** 37,42 **** /// <see cref="Collection.WrapperClass"/> /// </summary> ! public override System.Type WrapperClass { ! get { return IsSorted ? typeof(NCollection.SortedSet) : --- 41,48 ---- /// <see cref="Collection.WrapperClass"/> /// </summary> ! public override System.Type WrapperClass ! { ! get ! { return IsSorted ? typeof(NCollection.SortedSet) : *************** *** 46,57 **** ! public void CreatePrimaryKey() { PrimaryKey pk = new PrimaryKey(); ! foreach(Column col in Key.ColumnCollection) { pk.AddColumn(col); } bool nullable = false; ! foreach(Column col in Element.ColumnCollection) { if(col.IsNullable) nullable = true; pk.AddColumn(col); --- 52,66 ---- ! public void CreatePrimaryKey() ! { PrimaryKey pk = new PrimaryKey(); ! foreach(Column col in Key.ColumnCollection) ! { pk.AddColumn(col); } bool nullable = false; ! foreach(Column col in Element.ColumnCollection) ! { if(col.IsNullable) nullable = true; pk.AddColumn(col); *************** *** 61,68 **** // column in a primary key - others (DB2) won't if(!nullable) Table.PrimaryKey = pk; - } - - } } --- 70,74 ---- Index: OneToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToOne.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OneToOne.cs 4 Mar 2003 03:59:28 -0000 1.2 --- OneToOne.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 1,35 **** using System; using System.Collections; using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class OneToOne : Association { private bool constrained; private ForeignKeyType foreignKeyType; private Value identifier; ! public OneToOne(Table table, Value identifier) : base(table) { this.identifier = identifier; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) { ! try { if (Type==null) Type = TypeFactory.OneToOne(ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType, foreignKeyType); ! } catch (HibernateException he) { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() { if (constrained) CreateForeignKeyOfClass( ((EntityType)Type).PersistentClass ); } ! public override IList ConstraintColumns { ! get { ArrayList list = new ArrayList(); ! foreach(object obj in identifier.ColumnCollection) { list.Add(obj); } --- 1,46 ---- using System; using System.Collections; + using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class OneToOne : Association ! { private bool constrained; private ForeignKeyType foreignKeyType; private Value identifier; ! public OneToOne(Table table, Value identifier) : base(table) ! { this.identifier = identifier; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) ! { ! try ! { if (Type==null) Type = TypeFactory.OneToOne(ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType, foreignKeyType); ! } ! catch (HibernateException he) ! { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() ! { if (constrained) CreateForeignKeyOfClass( ((EntityType)Type).PersistentClass ); } ! public override IList ConstraintColumns ! { ! get ! { ArrayList list = new ArrayList(); ! foreach(object obj in identifier.ColumnCollection) ! { list.Add(obj); } *************** *** 38,52 **** } ! public bool IsConstrained { get { return constrained; } set { constrained = value; } } ! public ForeignKeyType ForeignKeyType { get { return foreignKeyType; } set { foreignKeyType = value; } } ! public Value Identifier { get { return identifier; } set { identifier = value; } --- 49,66 ---- } ! public bool IsConstrained ! { get { return constrained; } set { constrained = value; } } ! public ForeignKeyType ForeignKeyType ! { get { return foreignKeyType; } set { foreignKeyType = value; } } ! public Value Identifier ! { get { return identifier; } set { identifier = value; } Index: Index.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Index.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Index.cs 10 Apr 2004 05:06:02 -0000 1.3 --- Index.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 6,17 **** using NHibernate.Dialect; ! namespace NHibernate.Mapping { ! ! public class Index : IRelationalModel { private Table table; private ArrayList columns = new ArrayList(); private string name; ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("create index ") .Append( dialect.QualifyIndexName ? name : StringHelper.Unqualify(name) ) --- 6,19 ---- using NHibernate.Dialect; ! namespace NHibernate.Mapping ! { ! public class Index : IRelationalModel ! { private Table table; private ArrayList columns = new ArrayList(); private string name; ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) ! { StringBuilder buf = new StringBuilder("create index ") .Append( dialect.QualifyIndexName ? name : StringHelper.Unqualify(name) ) *************** *** 19,48 **** .Append( table.GetQualifiedName(dialect)) .Append(" ("); ! for(int i=0; i<columns.Count; i++) { buf.Append( ((Column)columns[i]).GetQuotedName(dialect) ); - if (i<columns.Count-1) buf.Append(StringHelper.CommaSpace); } buf.Append(StringHelper.ClosedParen); return buf.ToString(); } ! public string SqlDropString(Dialect.Dialect dialect) { return "drop index " + table.GetQualifiedName(dialect) + StringHelper.Dot + name; } ! public Table Table { get { return table; } set { table = value; } } ! public ICollection ColumnCollection { get { return columns; } } ! public void AddColumn(Column column) { if (!columns.Contains(column)) columns.Add(column); } ! public string Name { get { return name; } set { name = value; } --- 21,61 ---- .Append( table.GetQualifiedName(dialect)) .Append(" ("); ! ! bool commaNeeded = false; ! for(int i=0; i<columns.Count; i++) ! { ! if(commaNeeded) buf.Append(StringHelper.CommaSpace); ! commaNeeded = true; ! buf.Append( ((Column)columns[i]).GetQuotedName(dialect) ); } + buf.Append(StringHelper.ClosedParen); return buf.ToString(); } ! public string SqlDropString(Dialect.Dialect dialect) ! { return "drop index " + table.GetQualifiedName(dialect) + StringHelper.Dot + name; } ! public Table Table ! { get { return table; } set { table = value; } } ! public ICollection ColumnCollection ! { get { return columns; } } ! public void AddColumn(Column column) ! { if (!columns.Contains(column)) columns.Add(column); } ! public string Name ! { get { return name; } set { name = value; } Index: IndexedCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IndexedCollection.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndexedCollection.cs 28 Feb 2003 22:14:00 -0000 1.2 --- IndexedCollection.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 1,30 **** using System; ! namespace NHibernate.Mapping { ! ! public abstract class IndexedCollection : Collection { public const string DefaultIndexColumnName = "idx"; private Value index; ! public IndexedCollection(PersistentClass owner) : base(owner) { } ! public Value Index { get { return index; } set { index = value; } } ! public override bool IsIndexed { get { return true; } } ! public void CreatePrimaryKey() { PrimaryKey pk = new PrimaryKey(); ! foreach(Column col in Key.ColumnCollection ) { pk.AddColumn(col); } ! foreach(Column col in Index.ColumnCollection) { pk.AddColumn(col); } Table.PrimaryKey = pk; } --- 1,44 ---- using System; ! namespace NHibernate.Mapping ! { ! /// <summary> ! /// Indexed collections include IList, IDictionary, Arrays ! /// and primitive Arrays. ! /// </summary> ! public abstract class IndexedCollection : Collection ! { public const string DefaultIndexColumnName = "idx"; private Value index; ! public IndexedCollection(PersistentClass owner) : base(owner) ! { ! } ! public Value Index ! { get { return index; } set { index = value; } } ! public override bool IsIndexed ! { get { return true; } } ! public void CreatePrimaryKey() ! { PrimaryKey pk = new PrimaryKey(); ! ! foreach(Column col in Key.ColumnCollection ) ! { pk.AddColumn(col); } ! foreach(Column col in Index.ColumnCollection) ! { pk.AddColumn(col); } + Table.PrimaryKey = pk; } Index: ForeignKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ForeignKey.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ForeignKey.cs 10 Apr 2004 05:06:02 -0000 1.4 --- ForeignKey.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 3,31 **** using NHibernate.Dialect; ! namespace NHibernate.Mapping { ! ! public class ForeignKey : Constraint { private Table referencedTable; private System.Type referencedClass; ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) { string[] cols = new string[ ColumnSpan ]; string[] refcols = new string[ ColumnSpan ]; int i=0; ! foreach(Column ... [truncated message content] |
From: Michael D. <mik...@us...> - 2004-04-13 02:18:58
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11311/Cfg Modified Files: Configuration.cs Log Message: instead of Adding the generator use the Index to make it safe for subclasses. JIRA NH-49 Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Configuration.cs 10 Apr 2004 05:23:35 -0000 1.9 --- Configuration.cs 13 Apr 2004 02:05:03 -0000 1.10 *************** *** 307,311 **** IIdentifierGenerator ig = clazz.Identifier.CreateIdentifierGenerator(dialect); if ( ig is IPersistentIdentifierGenerator ) ! generators.Add( ( (IPersistentIdentifierGenerator) ig).GeneratorKey(), ig); } --- 307,311 ---- IIdentifierGenerator ig = clazz.Identifier.CreateIdentifierGenerator(dialect); if ( ig is IPersistentIdentifierGenerator ) ! generators[ ( (IPersistentIdentifierGenerator) ig).GeneratorKey()] = ig; } |
From: Michael D. <mik...@us...> - 2004-04-12 06:02:19
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11707/NHibernate.Test Modified Files: ABCProxyTest.cs ABCTest.cs TestCase.cs Log Message: Modified signature on TestCase.DropSchema to no longer take an array of files - just uses the cfg object and never used the files anyway. Index: TestCase.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TestCase.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestCase.cs 9 Apr 2004 13:39:48 -0000 1.8 --- TestCase.cs 12 Apr 2004 05:48:33 -0000 1.9 *************** *** 39,46 **** } ! public void DropSchema(string[] files) { new SchemaExport(cfg).Drop(true, true); } public void ExecuteStatement(string sql) { --- 39,50 ---- } ! /// <summary> ! /// Drops the schema that was built with the TestCase's Configuration. ! /// </summary> ! public void DropSchema() { new SchemaExport(cfg).Drop(true, true); } + public void ExecuteStatement(string sql) { Index: ABCProxyTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ABCProxyTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABCProxyTest.cs 7 Apr 2004 21:24:21 -0000 1.3 --- ABCProxyTest.cs 12 Apr 2004 05:48:33 -0000 1.4 *************** *** 19,23 **** public void TearDown() { ! DropSchema(new string[] { "ABCProxy.hbm.xml"}); } --- 19,23 ---- public void TearDown() { ! DropSchema(); } Index: ABCTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ABCTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ABCTest.cs 7 Apr 2004 21:24:21 -0000 1.3 --- ABCTest.cs 12 Apr 2004 05:48:33 -0000 1.4 *************** *** 22,26 **** public void TearDown() { ! DropSchema(new string[] { "ABC.hbm.xml"}); } --- 22,26 ---- public void TearDown() { ! DropSchema(); } |
From: Michael D. <mik...@us...> - 2004-04-12 05:59:07
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11183/NHibernate.Test Modified Files: NHibernate.Test-1.1.csproj Added Files: NH47.cs Log Message: Added test for Template and StringHelper. Added test for an issue (will probably remove later because I misunderstood the issue) --- NEW FILE: NH47.cs --- using System; using System.Data; using System.Collections; using NHibernate; using NExp = NHibernate.Expression; using NHibernate.DomainModel; using NUnit.Framework; namespace NHibernate.Test { [TestFixture] public class NH47Fxiture : TestCase { [SetUp] public void SetUp() { ExportSchema( new string[] { "UnsavedType.hbm.xml"}); } public TimeSpan BatchInsert(object[] objs) { System.TimeSpan tspan = TimeSpan.Zero; if (objs != null && objs.Length > 0) { ISession s = sessions.OpenSession(); ITransaction t = s.BeginTransaction(); int count = objs.Length; Console.WriteLine(); Console.WriteLine("Start batch insert " + count.ToString() + " objects"); DateTime startTime = DateTime.Now; for(int i = 0; i < count; ++i) { s.Save(objs[i]); } t.Commit(); s.Close(); tspan = DateTime.Now.Subtract(startTime); Console.WriteLine("Finish in " + tspan.TotalMilliseconds.ToString() + " milliseconds"); } return tspan; } [Test] [Ignore("Only run this by itself")] public void TestNH47() { int testCount = 100; object[] al = new object[testCount]; TimeSpan tspan = TimeSpan.Zero; int times = 1000; for (int i = 0; i < times; ++i) { for (int j = 0; j < testCount; ++j) { UnsavedType ut = new UnsavedType(); ut.Id = j + 1 + testCount * (i + 1); ut.TypeName = System.Guid.NewGuid().ToString(); al[j] = ut; } tspan = tspan.Add(BatchInsert(al)); } Console.WriteLine("Finish average in " + (tspan.TotalMilliseconds / times).ToString() + " milliseconds for " + times.ToString() + " times"); Console.Read(); } } } Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NHibernate.Test-1.1.csproj 9 Apr 2004 13:39:46 -0000 1.12 --- NHibernate.Test-1.1.csproj 12 Apr 2004 05:45:21 -0000 1.13 *************** *** 165,168 **** --- 165,173 ---- /> <File + RelPath = "NH47.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NHibernate.Test.build" BuildAction = "None" *************** *** 293,296 **** --- 298,306 ---- /> <File + RelPath = "SqlCommandTest\TemplateFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TypesTest\BaseTypeFixture.cs" SubType = "Code" *************** *** 317,320 **** --- 327,335 ---- BuildAction = "Compile" /> + <File + RelPath = "UtilityTest\StringHelperFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> </Include> </Files> |
From: Michael D. <mik...@us...> - 2004-04-12 05:57:28
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10901/NHibernate/Cfg Modified Files: Binder.cs Mappings.cs Log Message: Added code so the auto-import works now. Index: Mappings.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Mappings.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Mappings.cs 22 Apr 2003 22:05:52 -0000 1.4 --- Mappings.cs 12 Apr 2004 05:43:26 -0000 1.5 *************** *** 50,54 **** public void AddImport(string className, string rename) { ! if ( (string)imports[rename] != className) throw new MappingException("duplicate import: " + rename); imports.Add(rename, className); --- 50,54 ---- public void AddImport(string className, string rename) { ! if ( imports.Contains(rename) && (string)imports[rename] != className) throw new MappingException("duplicate import: " + rename); imports.Add(rename, className); Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Binder.cs 9 Apr 2004 12:37:55 -0000 1.12 --- Binder.cs 12 Apr 2004 05:43:26 -0000 1.13 *************** *** 54,58 **** //import if (mapping.IsAutoImport) { ! mapping.AddImport( className, StringHelper.Unqualify(className) ); } } --- 54,58 ---- //import if (mapping.IsAutoImport) { ! mapping.AddImport( StringHelper.GetFullClassname(className), StringHelper.GetClassname(className) ); } } *************** *** 86,90 **** XmlAttribute tableNameNode = node.Attributes["table"]; string tableName = (tableNameNode==null) ! ? StringHelper.Unqualify( model.PersistentClazz.Name ) : tableNameNode.Value; --- 86,90 ---- XmlAttribute tableNameNode = node.Attributes["table"]; string tableName = (tableNameNode==null) ! ? model.PersistentClazz.Name : tableNameNode.Value; *************** *** 117,121 **** XmlAttribute tableNameNode = node.Attributes["table"]; string tableName = (tableNameNode==null) ! ? StringHelper.Unqualify( model.PersistentClazz.Name ) : tableNameNode.Value; --- 117,121 ---- XmlAttribute tableNameNode = node.Attributes["table"]; string tableName = (tableNameNode==null) ! ? model.PersistentClazz.Name : tableNameNode.Value; *************** *** 855,858 **** --- 855,861 ---- model.DefaultCascade = (dcNode==null) ? "none" : dcNode.Value ; + XmlAttribute aiNode = hmNode.Attributes["auto-import"]; + model.IsAutoImport = (aiNode==null) ? true : "true".Equals( aiNode.Value ); + nsmgr = new XmlNamespaceManager(doc.NameTable); // note that the prefix has absolutely nothing to do with what the user *************** *** 874,877 **** --- 877,889 ---- model.AddQuery(qname, query); } + + foreach(XmlNode n in hmNode.SelectNodes(nsPrefix + ":import", nsmgr) ) + { + string className = n.Attributes["class"].Value; + XmlAttribute renameNode = n.Attributes["rename"]; + string rename = (renameNode==null) ? StringHelper.GetClassname(className) : renameNode.Value; + log.Debug("Import: " + rename + " -> " + className); + model.AddImport(className, rename); + } } |
From: Michael D. <mik...@us...> - 2004-04-12 05:56:22
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10781/NHibernate/Mapping Modified Files: PersistentClass.cs Log Message: Name property now returns the fully qualified classname instead of just the classname. Index: PersistentClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PersistentClass.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PersistentClass.cs 10 Feb 2004 18:35:30 -0000 1.7 --- PersistentClass.cs 12 Apr 2004 05:42:36 -0000 1.8 *************** *** 92,96 **** public virtual string Name { ! get { return persistentClass.Name; } } --- 92,96 ---- public virtual string Name { ! get { return persistentClass.FullName; } } |
From: Michael D. <mik...@us...> - 2004-04-12 05:55:30
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10667/NHibernate/Hql Modified Files: QueryTranslator.cs Log Message: removed unneeded code to unqualify a type name - framework already does that for us. Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** QueryTranslator.cs 2 Apr 2004 15:55:45 -0000 1.20 --- QueryTranslator.cs 12 Apr 2004 05:41:45 -0000 1.21 *************** *** 228,233 **** internal string CreateNameFor(System.Type type) { ! string typeName = type.Name; ! return Prefix( StringHelper.Unqualify(typeName) ) + NextCount() + StringHelper.Underscore; } --- 228,232 ---- internal string CreateNameFor(System.Type type) { ! return Prefix(type.Name) + NextCount() + StringHelper.Underscore; } |
From: Michael D. <mik...@us...> - 2004-04-12 05:52:56
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10386/NHibernate.Test/SqlCommandTest Added Files: TemplateFixture.cs Log Message: Test Fixture for Template class. --- NEW FILE: TemplateFixture.cs --- using System; using NHibernate.Dialect; using NHibernate.SqlCommand; using NUnit.Framework; namespace NHibernate.Test.SqlCommandTest { [TestFixture] public class TemplateFixture { public TemplateFixture() { } /// <summary> /// Tests that a column enclosed by <c>`</c> is enclosed by the Dialect.OpenQuote /// and Dialect.CloseQuote after the Template Renders the Where String. /// </summary> [Test] public void ReplaceWithDialectQuote() { Dialect.Dialect dialect = new Dialect.MsSql2000Dialect(); string whereFragment = "column_name = 'string value' and `backtick` = 1"; string expectedFragment = "$PlaceHolder.column_name = 'string value' and $PlaceHolder.[backtick] = 1"; Assert.AreEqual( expectedFragment, Template.RenderWhereStringTemplate(whereFragment, dialect) ); } } } |
From: Michael D. <mik...@us...> - 2004-04-12 05:52:05
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/UtilityTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10243/NHibernate.Test/UtilityTest Added Files: StringHelperFixture.cs Log Message: Added new methods to get the class name from a string that contains the type name. --- NEW FILE: StringHelperFixture.cs --- using System; using NHibernate.Util; using NUnit.Framework; namespace NHibernate.Test.UtilityTest { /// <summary> /// Summary description for StringHelperFixture. /// </summary> [TestFixture] public class StringHelperFixture { [Test] public void GetClassnameFromFQType() { string typeName = "ns1.ns2.classname, as1.as2., pk, lang"; string expected = "classname"; Assert.AreEqual(expected, StringHelper.GetClassname(typeName)); } [Test] public void GetClassnameFromFQClass() { string typeName = "ns1.ns2.classname"; string expected = "classname"; Assert.AreEqual(expected, StringHelper.GetClassname(typeName)); } } } |
From: Michael D. <mik...@us...> - 2004-04-12 05:52:04
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10243/NHibernate/Util Modified Files: StringHelper.cs Log Message: Added new methods to get the class name from a string that contains the type name. Index: StringHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/StringHelper.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StringHelper.cs 10 Feb 2004 18:42:01 -0000 1.8 --- StringHelper.cs 12 Apr 2004 05:38:19 -0000 1.9 *************** *** 83,86 **** --- 83,111 ---- } + /// <summary> + /// Takes a fully qualified type name and returns the full name of the + /// Class - includes namespaces. + /// </summary> + /// <param name="typeName"></param> + /// <returns></returns> + public static string GetFullClassname(string typeName) + { + return typeName.Trim().Split(' ', ',')[0]; + } + + /// <summary> + /// Takes a fully qualifed type name (can include the assembly) and just returns + /// the name of the Class. + /// </summary> + /// <param name="typeName"></param> + /// <returns></returns> + public static string GetClassname(string typeName) + { + string[] splitClassname = GetFullClassname(typeName).Split('.'); + + return splitClassname[splitClassname.Length-1]; + + } + public static string Qualifier(string qualifiedName) { int loc = qualifiedName.LastIndexOf("."); |
From: Michael D. <mik...@us...> - 2004-04-12 05:51:18
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10163/NHibernate/Dialect Modified Files: GenericDialect.cs Log Message: Added overrides for SqlTypeToString and removed Register code. Index: GenericDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/GenericDialect.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GenericDialect.cs 28 Apr 2003 14:25:09 -0000 1.6 --- GenericDialect.cs 12 Apr 2004 05:37:32 -0000 1.7 *************** *** 2,5 **** --- 2,7 ---- using System.Data; + using NHibernate.SqlTypes; + namespace NHibernate.Dialect { *************** *** 10,23 **** public GenericDialect() : base() { ! Register( DbType.Boolean, "BIT" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.String, "VARCHAR($1)" ); ! Register( DbType.Single, "FLOAT" ); ! Register( DbType.DateTime, "DATETIME" ); ! Register( DbType.Time, "TIMESTAMP" ); ! Register( DbType.Binary, "VARBINARY($1)" ); ! Register( DbType.Decimal, "DECIMAL" ); } --- 12,25 ---- public GenericDialect() : base() { ! // Register( DbType.Boolean, "BIT" ); ! // Register( DbType.Int16, "SMALLINT" ); ! // Register( DbType.Int32, "INTEGER" ); ! // Register( DbType.Int64, "BIGINT" ); ! // Register( DbType.String, "VARCHAR($1)" ); ! // Register( DbType.Single, "FLOAT" ); ! // Register( DbType.DateTime, "DATETIME" ); ! // Register( DbType.Time, "TIMESTAMP" ); ! // Register( DbType.Binary, "VARBINARY($1)" ); ! // Register( DbType.Decimal, "DECIMAL" ); } *************** *** 25,28 **** --- 27,131 ---- get { return "add column"; } } + + private string SqlTypeToString(string name, int length) + { + return name + "(" + length + ")"; + } + + private string SqlTypeToString(string name, int precision, int scale) + { + return name + "(" + precision + ", " + scale + ")"; + } + + protected override string SqlTypeToString(AnsiStringSqlType sqlType) + { + return SqlTypeToString("VARCHAR", sqlType.Length); + } + + protected override string SqlTypeToString(AnsiStringFixedLengthSqlType sqlType) + { + return SqlTypeToString("CHAR", sqlType.Length); + } + + protected override string SqlTypeToString(BinarySqlType sqlType) + { + return SqlTypeToString("VARBINARY", sqlType.Length); + } + + protected override string SqlTypeToString(BooleanSqlType sqlType) + { + return "BIT"; + } + + + protected override string SqlTypeToString(ByteSqlType sqlType) + { + return "TINYINT"; + } + + protected override string SqlTypeToString(CurrencySqlType sqlType) + { + return "MONEY"; + } + + protected override string SqlTypeToString(DateSqlType sqlType) + { + return "DATETIME"; + } + + protected override string SqlTypeToString(DateTimeSqlType sqlType) + { + return "DATETIME"; + } + + protected override string SqlTypeToString(TimeSqlType sqlType) + { + return "DATETIME"; + } + + protected override string SqlTypeToString(DecimalSqlType sqlType) + { + return SqlTypeToString("DECIMAL", sqlType.Precision, sqlType.Scale); + } + + protected override string SqlTypeToString(DoubleSqlType sqlType) + { + return SqlTypeToString("FLOAT", sqlType.Length); + } + + protected override string SqlTypeToString(GuidSqlType sqlType) + { + return "UNIQUEIDENTIFIER"; + } + + protected override string SqlTypeToString(Int16SqlType sqlType) + { + return "SMALLINT"; + } + + protected override string SqlTypeToString(Int32SqlType sqlType) + { + return "INTEGER"; + } + + protected override string SqlTypeToString(Int64SqlType sqlType) + { + return "BIGINT"; + } + + protected override string SqlTypeToString(SingleSqlType sqlType) + { + return SqlTypeToString("FLOAT", sqlType.Length); + } + + protected override string SqlTypeToString(StringFixedLengthSqlType sqlType) + { + return SqlTypeToString("NCHAR", sqlType.Length); + } + + protected override string SqlTypeToString(StringSqlType sqlType) + { + return SqlTypeToString("NVARCHAR", sqlType.Length); + } } } |
From: Michael D. <mik...@us...> - 2004-04-10 05:47:40
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32576 Modified Files: TableGenerator.cs Log Message: Was using Dialect.GetTypeName instead of Dalect.SqlTypeToString Index: TableGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableGenerator.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TableGenerator.cs 28 Mar 2004 06:06:40 -0000 1.6 --- TableGenerator.cs 10 Apr 2004 05:34:15 -0000 1.7 *************** *** 6,9 **** --- 6,10 ---- using NHibernate.Dialect; using NHibernate.Engine; + using NHibernate.SqlTypes; using NHibernate.Type; using NHibernate.Util; *************** *** 141,145 **** { return new string[] { ! "create table " + tableName + " ( " + columnName + " " + dialect.GetTypeName(DbType.Int32) + " )", "insert into " + tableName + " values ( 0 )" }; --- 142,146 ---- { return new string[] { ! "create table " + tableName + " ( " + columnName + " " + dialect.SqlTypeToString(SqlTypeFactory.GetInt32()) + " )", "insert into " + tableName + " values ( 0 )" }; |
From: Michael D. <mik...@us...> - 2004-04-10 05:37:01
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31300 Modified Files: Configuration.cs Log Message: Sequences were not getting created when the tables were created. Fixed problem reported in JIRA NH-47. Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Configuration.cs 10 Feb 2004 18:28:27 -0000 1.8 --- Configuration.cs 10 Apr 2004 05:23:35 -0000 1.9 *************** *** 300,309 **** } ! private ICollection CollectionGenerators(Dialect.Dialect dialect) { Hashtable generators = new Hashtable(); ! foreach(PersistentClass clazz in generators) { IIdentifierGenerator ig = clazz.Identifier.CreateIdentifierGenerator(dialect); ! if ( ig is IPersistentIdentifierGenerator ) generators.Add( ! ( (IPersistentIdentifierGenerator) ig).GeneratorKey(), ig); } --- 300,311 ---- } ! private ICollection CollectionGenerators(Dialect.Dialect dialect) ! { Hashtable generators = new Hashtable(); ! foreach(PersistentClass clazz in classes.Values) ! { IIdentifierGenerator ig = clazz.Identifier.CreateIdentifierGenerator(dialect); ! if ( ig is IPersistentIdentifierGenerator ) ! generators.Add( ( (IPersistentIdentifierGenerator) ig).GeneratorKey(), ig); } *************** *** 314,318 **** /// Generate DDL for droping tables /// </summary> ! public string[] GenerateDropSchemaScript(Dialect.Dialect dialect) { SecondPassCompile(); --- 316,321 ---- /// Generate DDL for droping tables /// </summary> ! public string[] GenerateDropSchemaScript(Dialect.Dialect dialect) ! { SecondPassCompile(); |
From: Michael D. <mik...@us...> - 2004-04-10 05:20:53
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28629/SqlCommand Added Files: Template.cs Log Message: Added SqlCommand.Template to the csproj. --- NEW FILE: Template.cs --- using System; using System.Collections; using System.Collections.Specialized; using System.Text; using NHibernate.Dialect; using NHibernate.Util; namespace NHibernate.SqlCommand { /// <summary> /// Summary description for Template. /// </summary> public sealed class Template { private static StringDictionary Keywords = new StringDictionary(); private static readonly string empty = ""; public static readonly string PlaceHolder = "$PlaceHolder"; private static ArrayList delimiterList = new ArrayList(13); private static string delimiters = null; static Template() { Keywords["and"] = empty; Keywords["or"] = empty; Keywords["not"] = empty; Keywords["like"] = empty; Keywords["is"] = empty; Keywords["in"] = empty; Keywords["between"] = empty; Keywords["null"] = empty; Keywords["select"] = empty; Keywords["from"] = empty; Keywords["where"] = empty; Keywords["having"] = empty; Keywords["group"] = empty; Keywords["order"] = empty; Keywords["by"] = empty; delimiterList.Add(" "); delimiterList.Add("="); delimiterList.Add(">"); delimiterList.Add("<"); delimiterList.Add("!"); delimiterList.Add("+"); delimiterList.Add("-"); delimiterList.Add("*"); delimiterList.Add("/"); delimiterList.Add("("); delimiterList.Add(")"); delimiterList.Add("'"); delimiterList.Add(","); foreach(string delim in delimiterList) { delimiters += delim; } } private Template() { } /// <summary> /// Add a Keyword to this Template. /// </summary> /// <param name="keyword">The Keyword to add.</param> public static void AddKeyword(string keyword) { Keywords[keyword] = empty; } /// <summary> /// Add a Delimeter to use when parsing the string. /// </summary> /// <param name="delimiter">The delimiter to add.</param> public static void AddDelimiter(string delimiter) { if ( !delimiterList.Contains(delimiter) ) { delimiterList.Add(delimiter); delimiters += delimiter; } } /// <summary> /// Takes the where condition provided in the mapping attribute and iterpolates the alias. /// </summary> /// <param name="sqlWhereString"></param> /// <param name="dialect"></param> /// <returns></returns> public static string RenderWhereStringTemplate(string sqlWhereString, Dialect.Dialect dialect) { //TODO: make this a bit nicer. StringTokenizer tokens = new StringTokenizer(sqlWhereString, delimiters, true); StringBuilder result = new StringBuilder(sqlWhereString.Length + 10); bool quoted = false; bool afterFrom = false; bool afterFromTable = false; IEnumerator tokensEnum = tokens.GetEnumerator(); bool hasMore = tokensEnum.MoveNext(); string nextToken = hasMore ? (string)tokensEnum.Current : null; while(hasMore) { string token = nextToken; hasMore = tokensEnum.MoveNext(); nextToken = hasMore ? (string)tokensEnum.Current : null; // the begin or end "'" has been found if ( "'".Equals(token) ) quoted = !quoted; if (quoted || char.IsWhiteSpace(token[0]) ) { result.Append(token); } else { bool isIdentifier = token[0]=='`' || ( // allow any identifier quoted with backtick Char.IsLetter(token[0]) && // only recognizes identifiers beginning with a letter !Keywords.ContainsKey( token.ToLower() ) && token.IndexOf('.') < 0 ); if (afterFrom) { result.Append(token); afterFrom = false; afterFromTable = true; } else if (afterFromTable) { afterFromTable = false; result.Append(token); } else if ( isIdentifier && ( nextToken==null || !nextToken.Equals("(") )) // not a function call { result.Append(PlaceHolder) .Append(StringHelper.Dot) .Append( Quote(token, dialect) ); } else { if ( "from".Equals( token.ToLower() ) ) afterFrom = true; result.Append(token); } } } return result.ToString(); } /// <summary> /// Takes order-by clause in the mapping attribute and iterpolates the alias /// </summary> /// <param name="sqlOrderByString"></param> /// <param name="dialect"></param> /// <returns></returns> public static string RenderOrderByStringTemplate(string sqlOrderByString, Dialect.Dialect dialect) { //TODO: make this a bit nicer StringTokenizer tokens = new StringTokenizer(sqlOrderByString, ","); StringBuilder result = new StringBuilder(sqlOrderByString.Length + 2); bool commaNeeded = false; IEnumerator tokenEnum = tokens.GetEnumerator(); while( tokenEnum.MoveNext() ) { string column = Quote(((string)tokenEnum.Current).Trim(), dialect); if (commaNeeded) result.Append(StringHelper.CommaSpace); commaNeeded = true; result.Append(PlaceHolder) .Append(StringHelper.Dot) .Append(column); } return result.ToString(); } private static string Quote(string column, Dialect.Dialect dialect) { if ( column[0] == '`' ) { return dialect.OpenQuote + column.Substring(1, column.Length - 2) + dialect.CloseQuote; } else { return column; } } } } |
From: Michael D. <mik...@us...> - 2004-04-10 05:20:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28629 Modified Files: NHibernate-1.1.csproj Log Message: Added SqlCommand.Template to the csproj. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** NHibernate-1.1.csproj 8 Apr 2004 15:55:45 -0000 1.16 --- NHibernate-1.1.csproj 10 Apr 2004 05:07:27 -0000 1.17 *************** *** 1404,1407 **** --- 1404,1412 ---- /> <File + RelPath = "SqlCommand\Template.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "SqlTypes\AnsiStringFixedLengthSqlType.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-04-10 05:19:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28379/NHibernate/Mapping Modified Files: Column.cs Constraint.cs ForeignKey.cs Index.cs PrimaryKey.cs Table.cs UniqueKey.cs Log Message: Fixed to support Quoted Tables and Columns - ie in MsSql the use of [ and ] to surround table names/columns. Index: Index.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Index.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Index.cs 27 Feb 2003 23:33:28 -0000 1.2 --- Index.cs 10 Apr 2004 05:06:02 -0000 1.3 *************** *** 17,24 **** .Append( dialect.QualifyIndexName ? name : StringHelper.Unqualify(name) ) .Append(" on ") ! .Append( table.QualifiedName ) .Append(" ("); for(int i=0; i<columns.Count; i++) { ! buf.Append( ((Column)columns[i]).Name); if (i<columns.Count-1) buf.Append(StringHelper.CommaSpace); } --- 17,24 ---- .Append( dialect.QualifyIndexName ? name : StringHelper.Unqualify(name) ) .Append(" on ") ! .Append( table.GetQualifiedName(dialect)) .Append(" ("); for(int i=0; i<columns.Count; i++) { ! buf.Append( ((Column)columns[i]).GetQuotedName(dialect) ); if (i<columns.Count-1) buf.Append(StringHelper.CommaSpace); } *************** *** 28,32 **** public string SqlDropString(Dialect.Dialect dialect) { ! return "drop index " + table.QualifiedName + StringHelper.Dot + name; } --- 28,32 ---- public string SqlDropString(Dialect.Dialect dialect) { ! return "drop index " + table.GetQualifiedName(dialect) + StringHelper.Dot + name; } Index: ForeignKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ForeignKey.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ForeignKey.cs 21 Mar 2003 22:30:19 -0000 1.3 --- ForeignKey.cs 10 Apr 2004 05:06:02 -0000 1.4 *************** *** 14,26 **** int i=0; foreach(Column col in referencedTable.PrimaryKey.ColumnCollection) { ! refcols[i] = col.Name; i++; } i=0; foreach(Column col in ColumnCollection) { ! cols[i] = col.Name; i++; } ! return d.GetAddForeignKeyConstraintString(constraintName, cols, referencedTable.QualifiedName, refcols); } --- 14,26 ---- int i=0; foreach(Column col in referencedTable.PrimaryKey.ColumnCollection) { ! refcols[i] = col.GetQuotedName(d); i++; } i=0; foreach(Column col in ColumnCollection) { ! cols[i] = col.GetQuotedName(d); i++; } ! return d.GetAddForeignKeyConstraintString(constraintName, cols, referencedTable.GetQualifiedName(d), refcols); } Index: Constraint.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Constraint.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Constraint.cs 27 Feb 2003 23:33:28 -0000 1.2 --- Constraint.cs 10 Apr 2004 05:06:02 -0000 1.3 *************** *** 36,45 **** public string SqlDropString(Dialect.Dialect dialect) { ! return "alter table " + Table.QualifiedName + " drop constraint " + Name; } public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("alter table ") ! .Append( Table.QualifiedName ) .Append( SqlConstraintString( dialect, Name ) ); return buf.ToString(); --- 36,45 ---- public string SqlDropString(Dialect.Dialect dialect) { ! return "alter table " + Table.GetQualifiedName(dialect)+ " drop constraint " + Name; } public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("alter table ") ! .Append( Table.GetQualifiedName(dialect) ) .Append( SqlConstraintString( dialect, Name ) ); return buf.ToString(); Index: Column.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Column.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Column.cs 10 Feb 2004 18:35:30 -0000 1.4 --- Column.cs 10 Apr 2004 05:06:02 -0000 1.5 *************** *** 21,24 **** --- 21,25 ---- private bool unique = false; private string sqlType; + private bool quoted = false; internal int uniqueInteger; *************** *** 35,41 **** public string Name { get { return name; } ! set { name = value; } } public string Alias { get { --- 36,59 ---- 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 d) + { + return quoted ? + d.OpenQuote + name + d.CloseQuote : + name; + } public string Alias { get { Index: PrimaryKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PrimaryKey.cs 10 Feb 2004 18:35:30 -0000 1.3 --- PrimaryKey.cs 10 Apr 2004 05:06:02 -0000 1.4 *************** *** 13,17 **** int i=0; foreach(Column col in ColumnCollection) { ! buf.Append(col.Name); if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); i++; --- 13,17 ---- int i=0; foreach(Column col in ColumnCollection) { ! buf.Append(col.GetQuotedName(d)); if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); i++; *************** *** 26,30 **** int i=0; foreach(Column col in ColumnCollection) { ! buf.Append( col.Name); if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); i++; --- 26,30 ---- int i=0; foreach(Column col in ColumnCollection) { ! buf.Append( col.GetQuotedName(d) ); if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); i++; Index: Table.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Table.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Table.cs 10 Feb 2004 18:35:30 -0000 1.6 --- Table.cs 10 Apr 2004 05:06:02 -0000 1.7 *************** *** 16,19 **** --- 16,20 ---- private string name; + private bool quoted; private string schema; private SequencedHashMap columns = new SequencedHashMap(); *************** *** 30,40 **** } ! /// <summary> ! /// Returns the QualifiedName for the table by combining the Schema and Name property. ! /// </summary> ! public string QualifiedName { ! get { return (schema == null) ? name : schema + StringHelper.Dot + name; } } /// <summary> /// Returns the QualifiedName for the table using the specified Qualifier --- 31,48 ---- } ! 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 by combining the Schema and Name property. + // /// </summary> + // public string QualifiedName { + // get { return (schema == null) ? name : schema + StringHelper.Dot + name; } + // } + + /// <summary> /// Returns the QualifiedName for the table using the specified Qualifier *************** *** 43,55 **** /// <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(string defaultQualifier) { ! return (schema==null) ? ( (defaultQualifier==null) ? name : defaultQualifier + StringHelper.Dot + name ) : QualifiedName; } public string Name { get { return name; } ! set { name = value; } } public Column GetColumn(int n) { IEnumerator iter = columns.Values.GetEnumerator(); --- 51,81 ---- /// <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 + name ) : 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 quoted ? + dialect.OpenQuote + name + dialect.CloseQuote : + name; + } public Column GetColumn(int n) { IEnumerator iter = columns.Values.GetEnumerator(); *************** *** 92,96 **** if (buf.Length != 0) buf.Append(StringHelper.CommaSpace); ! buf.Append(col.Name).Append(' ').Append(col.GetSqlType(dialect, p)); if (col.IsUnique && dialect.SupportsUnique) { buf.Append(" unique"); --- 118,124 ---- if (buf.Length != 0) buf.Append(StringHelper.CommaSpace); ! buf.Append(col.GetQuotedName(dialect)) ! .Append(' ') ! .Append(col.GetSqlType(dialect, p)); if (col.IsUnique && dialect.SupportsUnique) { buf.Append(" unique"); *************** *** 102,106 **** return null; ! return new StringBuilder("alter table ").Append(QualifiedName).Append(" add ").Append(buf).ToString(); } --- 130,134 ---- return null; ! return new StringBuilder("alter table ").Append(GetQualifiedName(dialect)).Append(" add ").Append(buf).ToString(); } *************** *** 108,112 **** public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("create table ") ! .Append( QualifiedName ) .Append( " ("); --- 136,140 ---- public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("create table ") ! .Append( GetQualifiedName(dialect) ) .Append( " ("); *************** *** 117,121 **** if (primaryKey != null && identityColumn ) { foreach(Column col in primaryKey.ColumnCollection) { ! pkname = col.Name; //should only go through this loop once } } --- 145,149 ---- if (primaryKey != null && identityColumn ) { foreach(Column col in primaryKey.ColumnCollection) { ! pkname = col.GetQuotedName(dialect); //should only go through this loop once } } *************** *** 123,131 **** foreach(Column col in ColumnCollection) { i++; ! buf.Append( col.Name) .Append(' ') .Append( col.GetSqlType(dialect, p) ); ! if ( identityColumn && col.Name.Equals(pkname) ) { buf.Append(' ') .Append( dialect.IdentityColumnString); --- 151,159 ---- 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); *************** *** 161,165 **** public string SqlDropString(Dialect.Dialect dialect) { ! return "drop table " + QualifiedName + dialect.CascadeConstraintsString; } --- 189,193 ---- public string SqlDropString(Dialect.Dialect dialect) { ! return "drop table " + GetQualifiedName(dialect) + dialect.CascadeConstraintsString; } *************** *** 211,234 **** public string UniqueColumnString(ICollection col) { ! string uniqueName; int result = 0; foreach(object obj in col) { ! result += obj.GetHashCode(); ! } ! /* ! * I was running into the problem of FKs being genrated with negative numbers. ! * So the sql being sent to generate the FK was "FK-1234" - SqlServer2000 does ! * not like that. So I'll change the "-" to an "_" to try and workaround that ! * problem ! */ ! //return ( Integer.toHexString( name.hashCode() ) + Integer.toHexString(result) ).toUpperCase(); ! if(result < 0) { ! result = result * -1; ! uniqueName = name + "_" + result.ToString(); ! } ! else { ! uniqueName = name + result.ToString(); } ! return uniqueName; //name + result.ToString(); } --- 239,254 ---- public string UniqueColumnString(ICollection col) { ! int result = 0; + foreach(object obj in col) { ! ! // this is marked as unchecked because the GetHashCode could potentially ! // cause an integer overflow. This way if there is an overflow it will ! // just roll back over. ! unchecked{ result += obj.GetHashCode(); } } ! ! return ( name.GetHashCode().ToString("X") + result.GetHashCode().ToString("X") ); } Index: UniqueKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/UniqueKey.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UniqueKey.cs 27 Feb 2003 23:33:28 -0000 1.2 --- UniqueKey.cs 10 Apr 2004 05:06:02 -0000 1.3 *************** *** 5,32 **** using NHibernate.Dialect; ! ! namespace NHibernate.Mapping { ! public class UniqueKey : Constraint { ! public string SqlConstraintString(Dialect.Dialect d) { StringBuilder buf = new StringBuilder(" unique ("); ! int i=0; ! foreach(Column col in ColumnCollection) { ! buf.Append( col.Name); ! if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); } return buf.Append(StringHelper.ClosedParen).ToString(); } ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) { StringBuilder buf = new StringBuilder( d.GetAddPrimaryKeyConstraintString(constraintName)) .Append('('); ! int i=0; ! foreach(Column col in ColumnCollection) { ! buf.Append( col.Name); ! if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); } return StringHelper.Replace( buf.Append(StringHelper.ClosedParen).ToString(), "primary key", "unique" ); } --- 5,48 ---- using NHibernate.Dialect; ! 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" ); } |
From: Michael D. <mik...@us...> - 2004-04-10 05:19:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28379/NHibernate/Persister Modified Files: AbstractEntityPersister.cs EntityPersister.cs NormalizedEntityPersister.cs Log Message: Fixed to support Quoted Tables and Columns - ie in MsSql the use of [ and ] to surround table names/columns. Index: NormalizedEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/NormalizedEntityPersister.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** NormalizedEntityPersister.cs 18 Mar 2004 18:36:09 -0000 1.11 --- NormalizedEntityPersister.cs 10 Apr 2004 05:06:02 -0000 1.12 *************** *** 158,162 **** this.factory = factory; Table table = model.RootTable; ! this.qualifiedTableName = table.GetQualifiedName( factory.DefaultSchema ); // DISCRIMINATOR --- 158,162 ---- this.factory = factory; Table table = model.RootTable; ! this.qualifiedTableName = table.GetQualifiedName( dialect, factory.DefaultSchema ); // DISCRIMINATOR *************** *** 203,212 **** // move through each table that contains the data for this entity. foreach(Table tab in model.TableClosureCollection) { ! string tabname = tab.GetQualifiedName( factory.DefaultSchema ); if ( !tabname.Equals(qualifiedTableName) ) { tables.Add( tabname ); string[] key = new string[idColumnSpan]; int k=0; ! foreach(Column col in tab.PrimaryKey.ColumnCollection ) key[k++] = col.Name; keyColumns.Add(key); } --- 203,212 ---- // move through each table that contains the data for this entity. foreach(Table tab in model.TableClosureCollection) { ! string tabname = tab.GetQualifiedName( dialect, factory.DefaultSchema ); if ( !tabname.Equals(qualifiedTableName) ) { tables.Add( tabname ); string[] key = new string[idColumnSpan]; int k=0; ! foreach(Column col in tab.PrimaryKey.ColumnCollection ) key[k++] = col.GetQuotedName(dialect); keyColumns.Add(key); } *************** *** 224,233 **** keyColumns.Add( IdentifierColumnNames ); foreach(Table tab in model.SubclassTableClosureCollection ) { ! string tabname = tab.GetQualifiedName(factory.DefaultSchema); if ( !tabname.Equals(qualifiedTableName) ) { subtables.Add(tabname); string[] key = new string[idColumnSpan]; int k=0; ! foreach(Column col in tab.PrimaryKey.ColumnCollection ) key[k++] = col.Name; keyColumns.Add(key); } --- 224,233 ---- keyColumns.Add( IdentifierColumnNames ); foreach(Table tab in model.SubclassTableClosureCollection ) { ! string tabname = tab.GetQualifiedName(dialect, factory.DefaultSchema); if ( !tabname.Equals(qualifiedTableName) ) { subtables.Add(tabname); string[] key = new string[idColumnSpan]; int k=0; ! foreach(Column col in tab.PrimaryKey.ColumnCollection ) key[k++] = col.GetQuotedName(dialect); keyColumns.Add(key); } *************** *** 262,266 **** thisClassProperties.Add(prop); Table tab = prop.Value.Table; ! string tabname = tab.GetQualifiedName( factory.DefaultSchema ); this.propertyTables[propertyIndex] = GetTableId(tabname, this.tableNames); --- 262,266 ---- thisClassProperties.Add(prop); Table tab = prop.Value.Table; ! string tabname = tab.GetQualifiedName(dialect, factory.DefaultSchema ); this.propertyTables[propertyIndex] = GetTableId(tabname, this.tableNames); *************** *** 272,276 **** int columnIndex = 0; foreach(Column col in prop.ColumnCollection ) { ! propCols[columnIndex] = col.Name; propAliases[columnIndex] = col.Alias + tab.UniqueInteger + StringHelper.Underscore; columnIndex++; --- 272,276 ---- int columnIndex = 0; foreach(Column col in prop.ColumnCollection ) { ! propCols[columnIndex] = col.GetQuotedName(dialect); propAliases[columnIndex] = col.Alias + tab.UniqueInteger + StringHelper.Underscore; columnIndex++; *************** *** 302,306 **** definedBySubclass.Add( !thisClassProperties.Contains(prop) ); Table tab = prop.Value.Table; ! string tabname = tab.GetQualifiedName( factory.DefaultSchema ); string[] cols = new string[ prop.ColumnSpan ]; types.Add( prop.Type ); --- 302,306 ---- definedBySubclass.Add( !thisClassProperties.Contains(prop) ); Table tab = prop.Value.Table; ! string tabname = tab.GetQualifiedName( dialect, factory.DefaultSchema ); string[] cols = new string[ prop.ColumnSpan ]; types.Add( prop.Type ); *************** *** 309,315 **** int l=0; foreach(Column col in prop.ColumnCollection) { ! columns.Add( col.Name ); coltables.Add(tabnum); ! cols[l++] = col.Name; aliases.Add( col.Alias + tab.UniqueInteger + StringHelper.Underscore ); } --- 309,315 ---- int l=0; foreach(Column col in prop.ColumnCollection) { ! columns.Add( col.GetQuotedName(dialect) ); coltables.Add(tabnum); ! cols[l++] = col.GetQuotedName(dialect); aliases.Add( col.Alias + tab.UniqueInteger + StringHelper.Underscore ); } *************** *** 346,355 **** this.tableNumbers = new int[subclassSpan]; this.tableNumbers[subclassSpan-1] = GetTableId( ! model.Table.GetQualifiedName( factory.DefaultSchema ), this.subclassTableNameClosure); this.notNullColumns = new string[subclassSpan]; foreach(Column col in model.Table.PrimaryKey.ColumnCollection) { ! notNullColumns[subclassSpan-1] = col.Name; //only once } --- 346,355 ---- this.tableNumbers = new int[subclassSpan]; this.tableNumbers[subclassSpan-1] = GetTableId( ! model.Table.GetQualifiedName( dialect, factory.DefaultSchema ), this.subclassTableNameClosure); this.notNullColumns = new string[subclassSpan]; foreach(Column col in model.Table.PrimaryKey.ColumnCollection) { ! notNullColumns[subclassSpan-1] = col.GetQuotedName(dialect); //only once } *************** *** 371,378 **** discriminators[p] = disc.ToString(); tableNumbers[p] = GetTableId( ! sc.Table.GetQualifiedName( factory.DefaultSchema ), subclassTableNameClosure); foreach(Column col in sc.Table.PrimaryKey.ColumnCollection) { ! notNullColumns[p] = col.Name; //only once; } } --- 371,378 ---- discriminators[p] = disc.ToString(); tableNumbers[p] = GetTableId( ! sc.Table.GetQualifiedName( dialect, factory.DefaultSchema ), subclassTableNameClosure); foreach(Column col in sc.Table.PrimaryKey.ColumnCollection) { ! notNullColumns[p] = col.GetQuotedName(dialect); //only once; } } Index: AbstractEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/AbstractEntityPersister.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractEntityPersister.cs 9 Apr 2004 16:18:00 -0000 1.15 --- AbstractEntityPersister.cs 10 Apr 2004 05:06:02 -0000 1.16 *************** *** 391,395 **** int i=0; foreach(Column col in idValue.ColumnCollection) { ! identifierColumnNames[i] = col.Name; i++; } --- 391,395 ---- int i=0; foreach(Column col in idValue.ColumnCollection) { ! identifierColumnNames[i] = col.GetQuotedName(dialect); i++; } *************** *** 426,430 **** if (model.IsVersioned) { foreach(Column col in model.Version.ColumnCollection) { ! versionColumnName = col.Name; //only hapens once } } else { --- 426,430 ---- if (model.IsVersioned) { foreach(Column col in model.Version.ColumnCollection) { ! versionColumnName = col.GetQuotedName(dialect); //only hapens once } } else { Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** EntityPersister.cs 6 Apr 2004 10:51:41 -0000 1.13 --- EntityPersister.cs 10 Apr 2004 05:06:02 -0000 1.14 *************** *** 75,79 **** this.factory = factory; Table table = model.RootTable; ! qualifiedTableName = table.GetQualifiedName( factory.DefaultSchema ); tableNames = new string[] { qualifiedTableName }; --- 75,79 ---- this.factory = factory; Table table = model.RootTable; ! qualifiedTableName = table.GetQualifiedName( dialect, factory.DefaultSchema ); tableNames = new string[] { qualifiedTableName }; *************** *** 88,92 **** // the discriminator will have only one column foreach(Column discColumn in d.ColumnCollection) { ! discriminatorColumnName = discColumn.Name; } try { --- 88,92 ---- // the discriminator will have only one column foreach(Column discColumn in d.ColumnCollection) { ! discriminatorColumnName = discColumn.GetQuotedName(dialect); } try { *************** *** 132,136 **** foreach(Column col in prop.ColumnCollection) { colAliases[j] = col.Alias; ! colNames[j] = col.Name; j++; if( prop.IsUpdateable ) foundColumn=true; --- 132,136 ---- foreach(Column col in prop.ColumnCollection) { colAliases[j] = col.Alias; ! colNames[j] = col.GetQuotedName(dialect); j++; if( prop.IsUpdateable ) foundColumn=true; *************** *** 159,165 **** int l=0; foreach( Column col in prop.ColumnCollection ) { ! columns.Add( col.Name ); aliases.Add( col.Alias ); ! cols[l++] = col.Name; } propColumns.Add(cols); --- 159,165 ---- int l=0; foreach( Column col in prop.ColumnCollection ) { ! columns.Add( col.GetQuotedName(dialect) ); aliases.Add( col.Alias ); ! cols[l++] = col.GetQuotedName(dialect); } propColumns.Add(cols); |