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-09-20 03:00:56
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10443/src/NHibernate Modified Files: NHibernate-1.1.csproj Log Message: Refactored ValueTypes to inherit from ValueTypeType instead of PrimitiveType. Removed PrimitiveClass property so that changed Binder & QueryTranslator - it is not applicable in .net since the type system has no 'Primitives' Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** NHibernate-1.1.csproj 19 Sep 2004 16:13:02 -0000 1.46 --- NHibernate-1.1.csproj 20 Sep 2004 03:00:17 -0000 1.47 *************** *** 1908,1916 **** /> <File - RelPath = "Type\PrimitiveType.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Type\SerializableType.cs" SubType = "Code" --- 1908,1911 ---- *************** *** 1988,1991 **** --- 1983,1991 ---- /> <File + RelPath = "Type\ValueTypeType.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Type\YesNoType.cs" SubType = "Code" |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10443/src/NHibernate/Type Modified Files: BooleanType.cs ByteType.cs CharType.cs DateTimeType.cs DateType.cs DecimalType.cs DoubleType.cs GuidType.cs ImmutableType.cs Int16Type.cs Int32Type.cs Int64Type.cs NullableType.cs ObjectType.cs PersistentEnumType.cs SingleType.cs TicksType.cs TimeSpanType.cs TimestampType.cs TimeType.cs Added Files: ValueTypeType.cs Removed Files: PrimitiveType.cs Log Message: Refactored ValueTypes to inherit from ValueTypeType instead of PrimitiveType. Removed PrimitiveClass property so that changed Binder & QueryTranslator - it is not applicable in .net since the type system has no 'Primitives' Index: TimeType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TimeType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TimeType.cs 21 Aug 2004 16:37:33 -0000 1.5 --- TimeType.cs 20 Sep 2004 03:00:29 -0000 1.6 *************** *** 14,18 **** /// using this Type indicates that you don't care about the Date portion of the DateTime. /// </remarks> ! public class TimeType : MutableType, IIdentifierType, ILiteralType, IVersionType { internal TimeType() : base( new TimeSqlType() ) --- 14,18 ---- /// using this Type indicates that you don't care about the Date portion of the DateTime. /// </remarks> ! public class TimeType : ValueTypeType, IIdentifierType, ILiteralType, IVersionType { internal TimeType() : base( new TimeSqlType() ) *************** *** 72,81 **** } - public override object DeepCopyNotNull(object value) - { - DateTime old = (DateTime) value; - return new DateTime(1, 1, 1, old.Hour, old.Month, old.Day); - } - public override bool HasNiceEquals { --- 72,75 ---- *************** *** 88,94 **** } ! public string ObjectToSQLString(object value) { ! return "'" + value.ToString() + "'"; } --- 82,88 ---- } ! public override string ObjectToSQLString(object value) { ! return "'" + ((DateTime)value).ToShortTimeString() + "'"; } Index: ByteType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ByteType.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ByteType.cs 21 Aug 2004 16:37:32 -0000 1.6 --- ByteType.cs 20 Sep 2004 03:00:29 -0000 1.7 *************** *** 10,14 **** /// ByteType. /// </summary> ! public class ByteType : PrimitiveType, IDiscriminatorType { internal ByteType() : base( new ByteSqlType() ) --- 10,14 ---- /// ByteType. /// </summary> ! public class ByteType : ValueTypeType, IDiscriminatorType { internal ByteType() : base( new ByteSqlType() ) *************** *** 24,31 **** } - public override System.Type PrimitiveClass { - get { return typeof(byte); } - } - public override System.Type ReturnedClass { get { return typeof(byte); } --- 24,27 ---- Index: DateType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DateType.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DateType.cs 21 Aug 2004 16:37:32 -0000 1.9 --- DateType.cs 20 Sep 2004 03:00:29 -0000 1.10 *************** *** 5,9 **** namespace NHibernate.Type { ! public class DateType : MutableType, IIdentifierType, ILiteralType, IVersionType { internal DateType() : base( new DateSqlType() ) --- 5,9 ---- namespace NHibernate.Type { ! public class DateType : ValueTypeType, IIdentifierType, ILiteralType, IVersionType { internal DateType() : base( new DateSqlType() ) *************** *** 22,26 **** } ! public override System.Type ReturnedClass { get { return typeof(DateTime); } } --- 22,27 ---- } ! public override System.Type ReturnedClass ! { get { return typeof(DateTime); } } *************** *** 60,68 **** } - public override object DeepCopyNotNull(object value) { - DateTime old = (DateTime) value; - return new DateTime(old.Year, old.Month, old.Day); - } - public override bool HasNiceEquals { get { return true; } --- 61,64 ---- *************** *** 73,78 **** } ! public string ObjectToSQLString(object value) { ! return "'" + value.ToString() + "'"; } --- 69,74 ---- } ! public override string ObjectToSQLString(object value) { ! return "'" + ((DateTime)value).ToShortDateString() + "'"; } Index: Int16Type.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/Int16Type.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Int16Type.cs 21 Aug 2004 16:37:33 -0000 1.3 --- Int16Type.cs 20 Sep 2004 03:00:29 -0000 1.4 *************** *** 6,10 **** namespace NHibernate.Type { ! public class Int16Type : PrimitiveType, IDiscriminatorType, IVersionType { internal Int16Type() : base( new Int16SqlType() ) --- 6,10 ---- namespace NHibernate.Type { ! public class Int16Type : ValueTypeType, IDiscriminatorType, IVersionType { internal Int16Type() : base( new Int16SqlType() ) *************** *** 19,25 **** return Convert.ToInt16(rs[name]); } ! public override System.Type PrimitiveClass { ! get { return typeof(System.Int16); } ! } public override System.Type ReturnedClass { get { return typeof(System.Int16); } --- 19,23 ---- return Convert.ToInt16(rs[name]); } ! public override System.Type ReturnedClass { get { return typeof(System.Int16); } Index: DecimalType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DecimalType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DecimalType.cs 21 Aug 2004 16:37:32 -0000 1.5 --- DecimalType.cs 20 Sep 2004 03:00:29 -0000 1.6 *************** *** 10,14 **** /// DecimalType /// </summary> ! public class DecimalType : PrimitiveType, IIdentifierType { internal DecimalType() : this( new DecimalSqlType() ) --- 10,14 ---- /// DecimalType /// </summary> ! public class DecimalType : ValueTypeType, IIdentifierType { internal DecimalType() : this( new DecimalSqlType() ) *************** *** 30,38 **** } - public override System.Type PrimitiveClass - { - get { return typeof(Decimal); } - } - public override System.Type ReturnedClass { --- 30,33 ---- Index: GuidType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/GuidType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuidType.cs 21 Aug 2004 16:37:32 -0000 1.3 --- GuidType.cs 20 Sep 2004 03:00:29 -0000 1.4 *************** *** 7,11 **** { ! public class GuidType : PrimitiveType, IDiscriminatorType { --- 7,11 ---- { ! public class GuidType : ValueTypeType, IDiscriminatorType { *************** *** 24,32 **** } - public override System.Type PrimitiveClass - { - get { return typeof(System.Guid); } - } - public override System.Type ReturnedClass { --- 24,27 ---- Index: SingleType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/SingleType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SingleType.cs 21 Aug 2004 16:37:33 -0000 1.4 --- SingleType.cs 20 Sep 2004 03:00:29 -0000 1.5 *************** *** 14,18 **** /// matches up with the capabilities of System.Single /// </remarks> ! public class SingleType : PrimitiveType { internal SingleType() : base( new SingleSqlType() ) --- 14,18 ---- /// matches up with the capabilities of System.Single /// </remarks> ! public class SingleType : ValueTypeType { internal SingleType() : base( new SingleSqlType() ) *************** *** 30,38 **** } - public override System.Type PrimitiveClass - { - get { return typeof(System.Single); } - } - public override System.Type ReturnedClass { --- 30,33 ---- Index: BooleanType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BooleanType.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BooleanType.cs 21 Aug 2004 16:37:32 -0000 1.8 --- BooleanType.cs 20 Sep 2004 03:00:29 -0000 1.9 *************** *** 15,19 **** /// from Hibernate so I am not sure how/if they apply to NHibernate /// </remarks> ! public class BooleanType : PrimitiveType, IDiscriminatorType { private static readonly string TRUE = "1"; --- 15,19 ---- /// from Hibernate so I am not sure how/if they apply to NHibernate /// </remarks> ! public class BooleanType : ValueTypeType, IDiscriminatorType { private static readonly string TRUE = "1"; *************** *** 47,54 **** return Convert.ToBoolean(rs[name]); } - - public override System.Type PrimitiveClass { - get { return typeof(bool); } - } public override System.Type ReturnedClass { --- 47,50 ---- Index: Int64Type.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/Int64Type.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Int64Type.cs 21 Aug 2004 16:37:33 -0000 1.3 --- Int64Type.cs 20 Sep 2004 03:00:29 -0000 1.4 *************** *** 6,10 **** namespace NHibernate.Type { ! public class Int64Type : PrimitiveType, IIdentifierType, IVersionType { internal Int64Type() : base( new Int64SqlType() ) --- 6,10 ---- namespace NHibernate.Type { ! public class Int64Type : ValueTypeType, IIdentifierType, IVersionType { internal Int64Type() : base( new Int64SqlType() ) *************** *** 20,27 **** } - public override System.Type PrimitiveClass { - get { return typeof(System.Int64); } - } - public override System.Type ReturnedClass { get { return typeof(System.Int64); } --- 20,23 ---- Index: NullableType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/NullableType.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NullableType.cs 31 Aug 2004 13:14:26 -0000 1.10 --- NullableType.cs 20 Sep 2004 03:00:29 -0000 1.11 *************** *** 6,10 **** using NHibernate.Util; - namespace NHibernate.Type { --- 6,9 ---- *************** *** 12,18 **** /// Superclass of single-column nullable types. /// </summary> ! /// <remarks>Maps the Property to a single column that is capable of storing nulls.</remarks> ! public abstract class NullableType : AbstractType { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(NullableType)); /// <summary> --- 11,22 ---- /// Superclass of single-column nullable types. /// </summary> ! /// <remarks> ! /// Maps the Property to a single column that is capable of storing nulls in it. If a .net Struct is ! /// used it will be created with its unitialized value and then on Update the uninitialized value of ! /// the Struct will be written to the column - not <c>null</c>. ! /// </remarks> ! public abstract class NullableType : AbstractType ! { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(NullableType) ); /// <summary> *************** *** 131,138 **** /// </para> /// </remarks> ! public void NullSafeSet(IDbCommand cmd, object value, int index) { ! if (value==null) { ! if ( log.IsDebugEnabled ) log.Debug("binding null to parameter: " + index.ToString()); //Do we check IsNullable? --- 135,146 ---- /// </para> /// </remarks> ! public void NullSafeSet(IDbCommand cmd, object value, int index) ! { ! if (value==null) ! { ! if ( log.IsDebugEnabled ) ! { log.Debug("binding null to parameter: " + index.ToString()); + } //Do we check IsNullable? *************** *** 142,148 **** ( (IDataParameter)cmd.Parameters[index]).Value = DBNull.Value; } ! else { ! if ( log.IsDebugEnabled ) log.Debug("binding '" + ToXML(value) + "' to parameter: " + index); Set(cmd, value, index); --- 150,159 ---- ( (IDataParameter)cmd.Parameters[index]).Value = DBNull.Value; } ! else ! { ! if ( log.IsDebugEnabled ) ! { log.Debug("binding '" + ToXML(value) + "' to parameter: " + index); + } Set(cmd, value, index); *************** *** 179,183 **** /// TODO: determine if this is needed /// </remarks> ! public virtual object NullSafeGet(IDataReader rs, string[] names) { return NullSafeGet(rs, names[0]); } --- 190,195 ---- /// TODO: determine if this is needed /// </remarks> ! public virtual object NullSafeGet(IDataReader rs, string[] names) ! { return NullSafeGet(rs, names[0]); } *************** *** 201,216 **** public virtual object NullSafeGet(IDataReader rs, string name) { - int index = rs.GetOrdinal(name); ! if(rs.IsDBNull(index)) { ! if ( log.IsDebugEnabled ) log.Debug("returning null as column: " + name); // TODO: add a method to NullableType.GetNullValue - if we want to // use "MAGIC" numbers to indicate null values... return null; } ! else { ! object val = null; try --- 213,230 ---- public virtual object NullSafeGet(IDataReader rs, string name) { int index = rs.GetOrdinal(name); ! if( rs.IsDBNull(index) ) ! { ! if ( log.IsDebugEnabled ) ! { log.Debug("returning null as column: " + name); + } // TODO: add a method to NullableType.GetNullValue - if we want to // use "MAGIC" numbers to indicate null values... return null; } ! else ! { object val = null; try *************** *** 225,230 **** } ! if ( log.IsDebugEnabled ) log.Debug("returning '" + ToXML(val) + "' as column: " + name); return val; --- 239,246 ---- } ! if ( log.IsDebugEnabled ) ! { log.Debug("returning '" + ToXML(val) + "' as column: " + name); + } return val; *************** *** 292,296 **** /// a NullableType can only map to one column in a table. /// </remarks> ! public override sealed int GetColumnSpan(IMapping session) { return 1; } --- 308,313 ---- /// a NullableType can only map to one column in a table. /// </remarks> ! public override sealed int GetColumnSpan(IMapping session) ! { return 1; } Index: CharType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/CharType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CharType.cs 21 Aug 2004 16:37:32 -0000 1.4 --- CharType.cs 20 Sep 2004 03:00:29 -0000 1.5 *************** *** 9,13 **** /// Summary description for CharacterType. /// </summary> ! public class CharType : PrimitiveType , IDiscriminatorType { internal CharType() : base( new StringFixedLengthSqlType(1) ) --- 9,13 ---- /// Summary description for CharacterType. /// </summary> ! public class CharType : ValueTypeType , IDiscriminatorType { internal CharType() : base( new StringFixedLengthSqlType(1) ) *************** *** 28,36 **** return Get(rs, rs.GetOrdinal(name)); } ! ! public override System.Type PrimitiveClass { ! get { return typeof(char); } ! } ! public override System.Type ReturnedClass { get { return typeof(char); } --- 28,32 ---- return Get(rs, rs.GetOrdinal(name)); } ! public override System.Type ReturnedClass { get { return typeof(char); } --- PrimitiveType.cs DELETED --- Index: ImmutableType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ImmutableType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ImmutableType.cs 10 Feb 2004 18:41:42 -0000 1.5 --- ImmutableType.cs 20 Sep 2004 03:00:29 -0000 1.6 *************** *** 3,13 **** using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Superclass of nullable immutable types. /// </summary> ! public abstract class ImmutableType : NullableType { ! /// <summary> /// Initialize a new instance of the ImmutableType class using a --- 3,13 ---- using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Superclass of nullable immutable types. /// </summary> ! public abstract class ImmutableType : NullableType ! { /// <summary> /// Initialize a new instance of the ImmutableType class using a *************** *** 25,33 **** /// <returns>A deep copy of the object.</returns> /// <remarks> ! /// This just returns the value passed in because if the object being mapped is ! /// immutable. ! /// ! /// TODO: I really need to understand where this method is used so that the ! /// .NET types inherit from the correct MutableType/ImmutableType IType. /// </remarks> public override sealed object DeepCopyNotNull(object val) --- 25,32 ---- /// <returns>A deep copy of the object.</returns> /// <remarks> ! /// A <see cref="ValueType"/> is considered immutable because a boxed version ! /// of the <see cref="ValueType"/> is being stored by NHibernate. So any changes ! /// made to it would require the <see cref="ValueType"/> to be unboxed and ! /// then reboxed. /// </remarks> public override sealed object DeepCopyNotNull(object val) Index: Int32Type.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/Int32Type.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Int32Type.cs 21 Aug 2004 16:37:33 -0000 1.4 --- Int32Type.cs 20 Sep 2004 03:00:29 -0000 1.5 *************** *** 6,10 **** namespace NHibernate.Type { ! public class Int32Type : PrimitiveType, IDiscriminatorType, IVersionType { internal Int32Type() : base( new Int32SqlType() ) --- 6,10 ---- namespace NHibernate.Type { ! public class Int32Type : ValueTypeType, IDiscriminatorType, IVersionType { internal Int32Type() : base( new Int32SqlType() ) *************** *** 20,27 **** } - public override System.Type PrimitiveClass { - get { return typeof(System.Int32); } - } - public override System.Type ReturnedClass { get { return typeof(System.Int32); } --- 20,23 ---- --- NEW FILE: ValueTypeType.cs --- using System; using NHibernate.SqlTypes; using NHibernate.Util; namespace NHibernate.Type { /// <summary> /// Superclass of <see cref="ValueType"/> types. /// </summary> public abstract class ValueTypeType : ImmutableType, ILiteralType { /// <summary> /// Initialize a new instance of the ValueTypeType class using a /// <see cref="SqlType"/>. /// </summary> /// <param name="sqlType">The underlying <see cref="SqlType"/>.</param> protected ValueTypeType(SqlType sqlType) : base(sqlType) { } /// <summary> /// Compare two instances of the class mapped by this /// IType for persistence "equality" - ie. Equality of persistent state. /// </summary> /// <param name="x">The left hand side object.</param> /// <param name="y">The right hand side object.</param> /// <returns>True if the two objects contain the same values.</returns> public override bool Equals(object x, object y) { return ObjectUtils.Equals(x, y); } /// <summary> /// A representation of the value to be embedded in an XML element /// </summary> /// <param name="val">The object that contains the values. /// </param> /// <returns>An Xml formatted string.</returns> /// <remarks> /// This just calls <see cref="Object.ToString"/> so if there is /// a possibility of this <see cref="PrimitiveType"/> having any characters /// that need to be encoded then this method should be overridden. /// /// TODO: figure out if this is used to build Xml strings or will have encoding /// done automattically. /// </remarks> public override string ToXML(object val) { return val.ToString(); } /// <summary> /// When implemented by a class, return a <see cref="String"/> representation /// of the value, suitable for embedding in an SQL statement /// </summary> /// <param name="val">The object to convert to a string for the SQL statement.</param> /// <returns>A string that containts a well formed SQL Statement.</returns> public abstract string ObjectToSQLString(object val); } } Index: TicksType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TicksType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TicksType.cs 21 Aug 2004 16:37:33 -0000 1.4 --- TicksType.cs 20 Sep 2004 03:00:29 -0000 1.5 *************** *** 15,19 **** /// is accurate to 100-nanosecond intervals. /// </remarks> ! public class TicksType : MutableType, IVersionType, ILiteralType { internal TicksType() : base( new Int64SqlType() ) --- 15,19 ---- /// is accurate to 100-nanosecond intervals. /// </remarks> ! public class TicksType : ValueTypeType, IVersionType, ILiteralType { internal TicksType() : base( new Int64SqlType() ) *************** *** 52,60 **** } - public override object DeepCopyNotNull(object value) - { - return value; - } - public override bool Equals(object x, object y) { --- 52,55 ---- *************** *** 82,86 **** } ! public string ObjectToSQLString(object value) { return "'" + ((DateTime)value).Ticks.ToString() + "'"; --- 77,81 ---- } ! public override string ObjectToSQLString(object value) { return "'" + ((DateTime)value).Ticks.ToString() + "'"; Index: ObjectType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ObjectType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ObjectType.cs 21 Aug 2004 16:37:33 -0000 1.7 --- ObjectType.cs 20 Sep 2004 03:00:29 -0000 1.8 *************** *** 142,151 **** } ! public object Assembly(object cached, ISessionImplementor session, object owner) { ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached; return (cached==null) ? null : session.Load(e.clazz, e.id); } ! public override object Disassemble(object value, ISessionImplementor session) { return (value==null) ? null : new ObjectTypeCacheEntry( value.GetType(), session.GetEntityIdentifier(value) ); } --- 142,153 ---- } ! public override object Assemble(object cached, ISessionImplementor session, object owner) ! { ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached; return (cached==null) ? null : session.Load(e.clazz, e.id); } ! public override object Disassemble(object value, ISessionImplementor session) ! { return (value==null) ? null : new ObjectTypeCacheEntry( value.GetType(), session.GetEntityIdentifier(value) ); } Index: TimestampType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TimestampType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TimestampType.cs 21 Aug 2004 16:37:33 -0000 1.7 --- TimestampType.cs 20 Sep 2004 03:00:29 -0000 1.8 *************** *** 6,10 **** namespace NHibernate.Type { - /// <summary> /// This is almost the exact same type as the DateTime except it can be used --- 6,9 ---- *************** *** 21,33 **** /// <p> /// For example - MsSql Server 2000 is only accurate to 3.33 milliseconds. So if ! /// NHibernate writes a value of '01/01/98 23:59:59.995' to the Prepared Command, MsSql ! /// will store it as '1998-01-01 23:59:59.997'. /// </p> /// <p> /// Please review the documentation of your Database server. /// </p> - /// /// </remarks> ! public class TimestampType : MutableType, IVersionType, ILiteralType { internal TimestampType() : base( new DateTimeSqlType() ) --- 20,31 ---- /// <p> /// For example - MsSql Server 2000 is only accurate to 3.33 milliseconds. So if ! /// NHibernate writes a value of <c>01/01/98 23:59:59.995</c> to the Prepared Command, MsSql ! /// will store it as <c>1998-01-01 23:59:59.997</c>. /// </p> /// <p> /// Please review the documentation of your Database server. /// </p> /// </remarks> ! public class TimestampType : ValueTypeType, IVersionType, ILiteralType { internal TimestampType() : base( new DateTimeSqlType() ) *************** *** 83,91 **** } - public override object DeepCopyNotNull(object value) - { - return value; - } - public override bool Equals(object x, object y) { --- 81,84 ---- *************** *** 113,117 **** } ! public string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; --- 106,110 ---- } ! public override string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; Index: DateTimeType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DateTimeType.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DateTimeType.cs 10 Sep 2004 21:27:00 -0000 1.9 --- DateTimeType.cs 20 Sep 2004 03:00:29 -0000 1.10 *************** *** 6,10 **** namespace NHibernate.Type { - /// <summary> /// Maps a System.DateTime Property to a column that stores date & time down to --- 6,9 ---- *************** *** 16,20 **** /// or the <see cref="TicksType"/> /// </remarks> ! public class DateTimeType : MutableType, IIdentifierType, ILiteralType, IVersionType { --- 15,19 ---- /// or the <see cref="TicksType"/> /// </remarks> ! public class DateTimeType : ValueTypeType, IIdentifierType, ILiteralType, IVersionType { *************** *** 84,96 **** } - public override object DeepCopyNotNull(object value) - { - // take advantage of the fact that unboxing with the cast - // and then reboxing with the return as an object will - // return a different box. - return (DateTime)value; - } - - public override bool HasNiceEquals { --- 83,86 ---- *************** *** 103,107 **** } ! public string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; --- 93,97 ---- } ! public override string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; Index: PersistentEnumType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/PersistentEnumType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PersistentEnumType.cs 1 Sep 2004 00:16:00 -0000 1.7 --- PersistentEnumType.cs 20 Sep 2004 03:00:29 -0000 1.8 *************** *** 11,15 **** /// PersistentEnumType /// </summary> ! public class PersistentEnumType : ImmutableType, ILiteralType { private readonly System.Type enumClass; --- 11,15 ---- /// PersistentEnumType /// </summary> ! public class PersistentEnumType : ValueTypeType, ILiteralType { private readonly System.Type enumClass; *************** *** 186,190 **** } ! public string ObjectToSQLString(object value) { return GetValue(value).ToString(); --- 186,190 ---- } ! public override string ObjectToSQLString(object value) { return GetValue(value).ToString(); Index: DoubleType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DoubleType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DoubleType.cs 21 Aug 2004 16:37:32 -0000 1.5 --- DoubleType.cs 20 Sep 2004 03:00:29 -0000 1.6 *************** *** 6,10 **** namespace NHibernate.Type { ! public class DoubleType : PrimitiveType { internal DoubleType() : base( new DoubleSqlType() ) --- 6,10 ---- namespace NHibernate.Type { ! public class DoubleType : ValueTypeType { internal DoubleType() : base( new DoubleSqlType() ) *************** *** 20,27 **** } - public override System.Type PrimitiveClass { - get { return typeof(double); } - } - public override System.Type ReturnedClass { get { return typeof(double); } --- 20,23 ---- Index: TimeSpanType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TimeSpanType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TimeSpanType.cs 21 Aug 2004 16:37:33 -0000 1.4 --- TimeSpanType.cs 20 Sep 2004 03:00:29 -0000 1.5 *************** *** 10,14 **** /// Maps a System.Timespan Property to an Int64 column /// </summary> ! public class TimeSpanType : MutableType, IVersionType, ILiteralType { internal TimeSpanType() : base( new Int64SqlType() ) --- 10,14 ---- /// Maps a System.Timespan Property to an Int64 column /// </summary> ! public class TimeSpanType : ValueTypeType, IVersionType, ILiteralType { internal TimeSpanType() : base( new Int64SqlType() ) *************** *** 47,55 **** } - public override object DeepCopyNotNull(object value) - { - return value; - } - public override bool Equals(object x, object y) { --- 47,50 ---- *************** *** 77,81 **** } ! public string ObjectToSQLString(object value) { return "'" + ((TimeSpan)value).Ticks.ToString() + "'"; --- 72,76 ---- } ! public override string ObjectToSQLString(object value) { return "'" + ((TimeSpan)value).Ticks.ToString() + "'"; |
From: Michael D. <mik...@us...> - 2004-09-20 03:00:37
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10443/src/NHibernate/Hql Modified Files: QueryTranslator.cs Log Message: Refactored ValueTypes to inherit from ValueTypeType instead of PrimitiveType. Removed PrimitiveClass property so that changed Binder & QueryTranslator - it is not applicable in .net since the type system has no 'Primitives' Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** QueryTranslator.cs 13 Sep 2004 04:51:05 -0000 1.45 --- QueryTranslator.cs 20 Sep 2004 03:00:18 -0000 1.46 *************** *** 615,621 **** for (int i=0; i<types.Length; i++) { ! if (types[i]!=null) classes[i] = (types[i] is PrimitiveType) ? ! ((PrimitiveType) types[i]).PrimitiveClass : ! types[i].ReturnedClass; } --- 615,622 ---- for (int i=0; i<types.Length; i++) { ! if (types[i]!=null) ! { ! classes[i] = types[i].ReturnedClass; ! } } |
From: Michael D. <mik...@us...> - 2004-09-20 02:27:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5002/NHibernate/Type Modified Files: EntityType.cs Log Message: Fixed problem with EntityType and putting object into cache. Index: EntityType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/EntityType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EntityType.cs 7 Mar 2003 19:26:47 -0000 1.4 --- EntityType.cs 20 Sep 2004 02:27:01 -0000 1.5 *************** *** 68,85 **** public abstract bool IsOneToOne { get; } ! public override object Disassemble(object value, ISessionImplementor session) { ! if (value==null) { return null; } ! else { object id = session.GetIdentifier(value); ! if (id==null) throw new AssertionFailure("cannot cache a reference to an object with a null id"); ! return id; } } ! public override object Assemble(object oid, ISessionImplementor session, object owner) { ! return ResolveIdentifier(oid, session, owner); } --- 68,98 ---- public abstract bool IsOneToOne { get; } ! public override object Disassemble(object value, ISessionImplementor session) ! { ! if (value==null) ! { return null; } ! else ! { object id = session.GetIdentifier(value); ! if (id==null) ! { throw new AssertionFailure("cannot cache a reference to an object with a null id"); ! } ! return GetIdentifierType( session ).Disassemble( id, session ); } } ! protected IType GetIdentifierType(ISessionImplementor session) ! { ! return session.Factory.GetIdentifierType( persistentClass ); ! } ! ! public override object Assemble(object oid, ISessionImplementor session, object owner) ! { ! object assembledId = GetIdentifierType( session ).Assemble( oid, session, owner ); ! ! return ResolveIdentifier( assembledId, session, owner ); } *************** *** 98,107 **** public override abstract object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner); ! public override bool IsDirty(object old, object current, ISessionImplementor session) { if ( Equals(old, current) ) return false; object oldid = GetIdentifier(old, session); object newid = GetIdentifier(current, session); ! return !session.Factory.GetIdentifierType(persistentClass).Equals(oldid, newid); } } --- 111,121 ---- public override abstract object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner); ! public override bool IsDirty(object old, object current, ISessionImplementor session) ! { if ( Equals(old, current) ) return false; object oldid = GetIdentifier(old, session); object newid = GetIdentifier(current, session); ! return !GetIdentifierType(session).Equals(oldid, newid); } } |
From: Michael D. <mik...@us...> - 2004-09-20 02:27:10
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5002/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Fixed problem with EntityType and putting object into cache. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** FooBarTest.cs 15 Sep 2004 14:00:16 -0000 1.66 --- FooBarTest.cs 20 Sep 2004 02:27:01 -0000 1.67 *************** *** 227,239 **** Assert.AreEqual( LockMode.None, s.GetCurrentLockMode(b) ); s.Find("from Foo foo"); ! // When Proxies are implemented this will need to be changed to LockMode.None ! Assert.AreEqual( LockMode.Write, s.GetCurrentLockMode(b) ); q = s.CreateQuery("from Foo foo"); q.SetLockMode("foo", LockMode.Read); q.List(); ! // When Proxies are implemented this will need to be changed to LockMode.Read ! // because the current LockMode.Write won't downgrade to LockMode.Read ! Assert.AreEqual( LockMode.Write, s.GetCurrentLockMode(b) ); s.Evict(baz); --- 227,236 ---- Assert.AreEqual( LockMode.None, s.GetCurrentLockMode(b) ); s.Find("from Foo foo"); ! Assert.AreEqual( LockMode.None, s.GetCurrentLockMode(b) ); q = s.CreateQuery("from Foo foo"); q.SetLockMode("foo", LockMode.Read); q.List(); ! Assert.AreEqual( LockMode.Read, s.GetCurrentLockMode(b) ); s.Evict(baz); |
From: Michael D. <mik...@us...> - 2004-09-19 16:56:01
|
Update of /cvsroot/nhibernate/nhibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16687 Modified Files: releasenotes.txt Log Message: Some updates to get ready for next build. Index: releasenotes.txt =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/releasenotes.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** releasenotes.txt 2 Sep 2004 15:30:10 -0000 1.12 --- releasenotes.txt 19 Sep 2004 16:55:51 -0000 1.13 *************** *** 1,2 **** --- 1,25 ---- + Alpha Build 0.3.0.0 + ======================== + - Removed property AdoTransaction from Transaction. + - Added MsSql7Dialect. + - Added PostgreSQL Driver and Dialect (Oliver Weichhold & Martijn Boland). + - Fixed bug with Expression.Ge() not returning correct Expression. + - PersistentCollection now implements ICollection (Donald Mull). + - BatcherImpl and PreparerImpl were combined and code cleaned up thanks to problems found when using Ngpsql + - ITransaction is now responsible for joining IDbCommand to IDbTransaction instead of IBatcher - if applicable. + - Modified code to help improve performance of Drivers that don't support multiple Open DataReaders on a single IDbConnection. + - Fixed bug with hbm2net and VelocityRenderer throwing Exception (Carlos Guzmán Álvarez & Peter Smulovics). + - Clean up of hbm2net (Peter Smulovics). + - Modified internals of AbstractEntityPersister to help with buiding on Mono (Oliver Weichhold). + - Renamed nhibernate.build to NHibernate.build to help with building on Mono (Oliver Weichhold). + - Removed Dialect.GetLimitString(string) should use Dialect.GetLimitString(SqlString) instead. + - SqlStringBuilders were modified to set an initial capacity for the ArrayList. + - Added properties to SqlString to help with SqlStringBuilders and Hql. + - Marked Exceptions as [Serializable]. + - Fixed bug with Hql not being able to use a constant in an imported or mapped Class. + - DateTimeType.DeepCopyNotNull() cleaned up (Mark Traudt). + - Added VersionProperty to IClassMetadata. + + Alpha Build 0.2.0.0 ======================== |
From: Michael D. <mik...@us...> - 2004-09-19 16:54:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16491/Dialect Modified Files: Dialect.cs Oracle9Dialect.cs PostgreSQLDialect.cs Log Message: Removed GetLimitString(string) in favor of GetLimitString(SqlString) Index: PostgreSQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PostgreSQLDialect.cs 19 Sep 2004 15:32:34 -0000 1.7 --- PostgreSQLDialect.cs 19 Sep 2004 16:54:43 -0000 1.8 *************** *** 83,91 **** } - public override string GetLimitString(String querySelect) - { - return querySelect + " limit ? offset ? "; - } - public override SqlString GetLimitString(SqlString querySqlString) { --- 83,86 ---- Index: Oracle9Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Oracle9Dialect.cs 1 Sep 2004 00:17:08 -0000 1.13 --- Oracle9Dialect.cs 19 Sep 2004 16:54:43 -0000 1.14 *************** *** 125,137 **** } - public override string GetLimitString(String querySelect) - { - StringBuilder pagingSelect = new StringBuilder(100); - pagingSelect.Append("select * from ( select row_.*, rownum rownum_ from ( "); - pagingSelect.Append(querySelect); - pagingSelect.Append(" ) row_ where rownum <= ?) where rownum_ > ?"); - return pagingSelect.ToString(); - } - public override SqlString GetLimitString(SqlString querySqlString) { --- 125,128 ---- Index: Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Dialect.cs,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Dialect.cs 13 Sep 2004 07:31:34 -0000 1.39 --- Dialect.cs 19 Sep 2004 16:54:42 -0000 1.40 *************** *** 412,428 **** /// <summary> - /// Add a <c>LIMIT</c> clause to the given SQL <c>SELECT</c> - /// </summary> - /// <param name="querySelect"></param> - /// <returns>The modified SQL</returns> - [Obsolete("Use the GetLimitString(SqlString) overload instead.")] - public virtual string GetLimitString(String querySelect) - { - //TODO: H2.0.3 - this might need to the a SqlString or an IDbCommand depending - // on when it comes in. Need to look at Loader to know for sure... - throw new NotSupportedException("Paged Queries not supported"); - } - - /// <summary> /// Add a <c>LIMIT</c> clause to the given SQL <c>SELECT</c> /// </summary> --- 412,415 ---- |
From: Michael D. <mik...@us...> - 2004-09-19 16:15:10
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8348/Transaction Modified Files: Transaction.cs Log Message: Removed a method from the public api that should not be there. Index: Transaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/Transaction.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Transaction.cs 15 Sep 2004 03:17:47 -0000 1.4 --- Transaction.cs 19 Sep 2004 16:15:00 -0000 1.5 *************** *** 27,35 **** } - public IDbTransaction AdoTransaction - { - get { return trans; } - } - public void Enlist(IDbCommand command) { --- 27,30 ---- |
From: Michael D. <mik...@us...> - 2004-09-19 16:13:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7928/Dialect Modified Files: MsSql2000Dialect.cs Added Files: MsSql7Dialect.cs Log Message: Added a Dialect for Ms Sql 7 --- NEW FILE: MsSql7Dialect.cs --- using System; namespace NHibernate.Dialect { /// <summary> /// An SQL dialect compatible with Microsoft SQL Server 7. /// </summary> /// <remarks> /// There have been no test run with this because the NHibernate team does not /// have a machine with Sql 7 installed on it. But there have been users using /// Ms Sql 7 with NHibernate. As issues with Ms Sql 7 and NHibernate become known /// this Dialect will be updated. /// </remarks> public class MsSql7Dialect : MsSql2000Dialect { /// <summary> /// Uses @@identity to get the Id value. /// </summary> /// <remarks> /// There is a well known problem with @@identity and triggers that insert into /// rows into other tables that also use an identity column. The only way I know /// of to get around this problem is to upgrade your databse server to Ms Sql 2000. /// </remarks> public override string IdentitySelectString { get { return "select @@identity"; } } } } Index: MsSql2000Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** MsSql2000Dialect.cs 28 Aug 2004 15:32:33 -0000 1.18 --- MsSql2000Dialect.cs 19 Sep 2004 16:13:01 -0000 1.19 *************** *** 89,93 **** public override SqlString AddIdentitySelectToInsert(SqlString insertSql) { ! return insertSql.Append( "; SELECT SCOPE_IDENTITY()" ); } --- 89,93 ---- public override SqlString AddIdentitySelectToInsert(SqlString insertSql) { ! return insertSql.Append( "; " + IdentitySelectString ); } *************** *** 96,102 **** get { return true; } } public override string IdentitySelectString { ! get { return "select @@identity"; } } public override string IdentityColumnString --- 96,103 ---- get { return true; } } + public override string IdentitySelectString { ! get { return "select SCOPE_IDENTITY()"; } } public override string IdentityColumnString |
From: Michael D. <mik...@us...> - 2004-09-19 16:13:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7928 Modified Files: NHibernate-1.1.csproj Log Message: Added a Dialect for Ms Sql 7 Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** NHibernate-1.1.csproj 19 Sep 2004 15:32:34 -0000 1.45 --- NHibernate-1.1.csproj 19 Sep 2004 16:13:02 -0000 1.46 *************** *** 481,484 **** --- 481,489 ---- /> <File + RelPath = "Dialect\MsSql7Dialect.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Dialect\MySQLDialect.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-09-19 15:32:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32110/Driver Added Files: NpgsqlDriver.cs Log Message: Added PostgreSQL driver from NH-114 --- NEW FILE: NpgsqlDriver.cs --- using System; using System.Data; using System.Reflection; namespace NHibernate.Driver { /// <summary> /// The PostgreSQL data provider provides a database driver for PostgreSQL. /// <p> /// Author: <a href="mailto:ol...@we...">Oliver Weichhold</a> /// </p> /// </summary> /// <remarks> /// <p> /// In order to use this Driver you must have the Npgsql.dll Assembly available for /// NHibernate to load it. /// </p> /// <p> /// Please check the products website <a href="http://www.postgresql.org/">http://www.postgresql.org/</a> /// for any updates and or documentation. /// </p> /// <p> /// The homepage for the .NET DataProvider is: /// <a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">http://gborg.postgresql.org/project/npgsql/projdisplay.php</a>. /// </p> /// </remarks> public class NpgsqlDriver : DriverBase { private System.Type connectionType; private System.Type commandType; public NpgsqlDriver() { connectionType = System.Type.GetType("Npgsql.NpgsqlConnection, Npgsql"); commandType = System.Type.GetType("Npgsql.NpgsqlCommand, Npgsql"); } public override System.Type CommandType { get { return commandType; } } public override System.Type ConnectionType { get { return connectionType; } } public override bool UseNamedPrefixInSql { get { return true; } } public override bool UseNamedPrefixInParameter { get { return true; } } public override string NamedPrefix { get { return ":"; } } public override bool SupportsMultipleOpenReaders { get { return true; } } public override bool SupportsPreparingCommands { // NOTE: Npgsql actually supports this feature but there a bug that results in // NotSupportedException("Backend sent unrecognized response type") being thrown on insert statements // this should be fixed with Npgsql post 0.7beta1 (GBorg Bug ID 952) so we need to re-evaluate this override then get { return false; } } } } |
From: Michael D. <mik...@us...> - 2004-09-19 15:32:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32110/Dialect Modified Files: PostgreSQLDialect.cs Log Message: Added PostgreSQL driver from NH-114 Index: PostgreSQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PostgreSQLDialect.cs 11 Jul 2004 21:04:13 -0000 1.6 --- PostgreSQLDialect.cs 19 Sep 2004 15:32:34 -0000 1.7 *************** *** 2,60 **** using System.Data; ! namespace NHibernate.Dialect { /// <summary> /// An SQL dialect for PostgreSQL. /// </summary> ! public class PostgreSQLDialect : Dialect { ! ! public PostgreSQLDialect() { - /* Java mapping was: - Types.BIT, "BOOL" ); - Types.BIGINT, "INT8" ); - Types.SMALLINT, "INT2" ); - Types.TINYINT, "INT2" ); - Types.INTEGER, "INT4" ); - Types.CHAR, "CHAR(1)" ); - Types.VARCHAR, "VARCHAR($l)" - Types.FLOAT, "FLOAT4" ); - Types.DOUBLE, "FLOAT8" ); - Types.DATE, "DATE" ); - Types.TIME, "TIME" ); - Types.TIMESTAMP, "TIMESTAMP" - Types.VARBINARY, "BYTEA" ); - Types.CLOB, "TEXT" ); - Types.BLOB, "BYTEA" ); - Types.NUMERIC, "NUMERIC" ); - */ DefaultProperties[Cfg.Environment.OuterJoin] = "true"; ! DefaultProperties[Cfg.Environment.StatementBatchSize] = DefaultBatchSize; ! } ! public override string AddColumnString { get { return "add column"; } } ! public override bool DropConstraints { get { return false; } } ! public override string GetSequenceNextValString(string sequenceName) { return string.Concat( "select nextval ('", sequenceName, "')" ); } ! public override string GetCreateSequenceString(string sequenceName) { return "create sequence " + sequenceName; } ! public override string GetDropSequenceString(string sequenceName) { return "drop sequence " + sequenceName; } ! ! public override string CascadeConstraintsString { ! get { return " cascade"; } } ! ! public override bool SupportsSequences { get { return true; } } } ! } \ No newline at end of file --- 2,116 ---- using System.Data; ! using NHibernate.SqlCommand; ! using NHibernate.SqlTypes; + namespace NHibernate.Dialect + { /// <summary> /// An SQL dialect for PostgreSQL. /// </summary> ! public class PostgreSQLDialect : Dialect ! { ! public PostgreSQLDialect() ! { ! Register( DbType.AnsiStringFixedLength, "char(255)"); ! Register( DbType.AnsiStringFixedLength, 8000, "char($1)" ); ! Register( DbType.AnsiString, "varchar(255)" ); ! Register( DbType.AnsiString, 8000, "varchar($1)" ); ! Register( DbType.AnsiString, 2147483647, "text"); ! Register( DbType.Binary, 2147483647, "bytea" ); ! Register( DbType.Boolean, "boolean" ); ! Register( DbType.Byte, "int2" ); ! Register( DbType.Currency, "decimal(16,4)"); ! Register( DbType.Date, "date"); ! Register( DbType.DateTime, "timestamp" ); ! Register( DbType.Decimal, "decimal(18,0)" ); // NUMERIC(18,0) is equivalent to DECIMAL(18,0) ! Register( DbType.Decimal, 18, "decimal(18, $1)"); ! Register( DbType.Double, "float8" ); ! Register( DbType.Int16, "int2" ); ! Register( DbType.Int32, "int4" ); ! Register( DbType.Int64, "int8" ); ! Register( DbType.Single, "float4" ); ! Register( DbType.StringFixedLength, "char(255)"); ! Register( DbType.StringFixedLength, 4000, "char($1)"); ! Register( DbType.String, "varchar(255)" ); ! Register( DbType.String, 4000, "varchar($1)" ); ! Register( DbType.String, 1073741823, "text" );// ! Register( DbType.Time, "time" ); DefaultProperties[Cfg.Environment.OuterJoin] = "true"; ! DefaultProperties[Cfg.Environment.StatementBatchSize] = NoBatch; } ! public override string AddColumnString ! { get { return "add column"; } } ! ! public override bool DropConstraints ! { get { return false; } } ! ! public override string CascadeConstraintsString ! { ! get { return " cascade"; } ! } ! ! public override string GetSequenceNextValString(string sequenceName) ! { return string.Concat( "select nextval ('", sequenceName, "')" ); } ! ! public override string GetCreateSequenceString(string sequenceName) ! { return "create sequence " + sequenceName; } ! ! public override string GetDropSequenceString(string sequenceName) ! { return "drop sequence " + sequenceName; } ! ! public override bool SupportsSequences ! { ! get { return true; } } ! ! public override bool SupportsLimit ! { ! get { return true; } ! } ! ! public override string GetLimitString(String querySelect) ! { ! return querySelect + " limit ? offset ? "; ! } ! ! public override SqlString GetLimitString(SqlString querySqlString) ! { ! Parameter p1 = new Parameter(); ! Parameter p2 = new Parameter(); ! ! p1.Name = "p1"; ! p1.SqlType = new Int16SqlType(); ! ! p2.Name = "p2"; ! p2.SqlType = new Int16SqlType(); ! ! SqlStringBuilder pagingBuilder = new SqlStringBuilder(); ! pagingBuilder.Add(querySqlString); ! pagingBuilder.Add(" limit "); ! pagingBuilder.Add(p1); ! pagingBuilder.Add(" offset "); ! pagingBuilder.Add(p2); ! ! return pagingBuilder.ToSqlString(); ! } ! ! public override bool SupportsForUpdateOf ! { get { return true; } } } ! } |
From: Michael D. <mik...@us...> - 2004-09-19 15:32:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32110 Modified Files: NHibernate-1.1.csproj Log Message: Added PostgreSQL driver from NH-114 Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** NHibernate-1.1.csproj 14 Sep 2004 17:49:53 -0000 1.44 --- NHibernate-1.1.csproj 19 Sep 2004 15:32:34 -0000 1.45 *************** *** 546,549 **** --- 546,554 ---- /> <File + RelPath = "Driver\NpgsqlDriver.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Driver\OdbcDriver.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-09-17 12:26:03
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13530/NHibernate/Expression Modified Files: Expression.cs Log Message: Fixed typo with Expression.Ge not returning correct Expression. Index: Expression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Expression.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Expression.cs 26 Aug 2004 14:28:18 -0000 1.10 --- Expression.cs 17 Sep 2004 12:25:53 -0000 1.11 *************** *** 100,104 **** public static Expression Ge(string propertyName, object value) { ! return new GtExpression(propertyName, value); } --- 100,104 ---- public static Expression Ge(string propertyName, object value) { ! return new GeExpression(propertyName, value); } |
From: Michael D. <mik...@us...> - 2004-09-16 14:03:40
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6162/NHibernate/Collection Modified Files: ArrayHolder.cs Map.cs ODMGCollection.cs PersistentCollection.cs Set.cs Log Message: patch for NH-117 applied Index: ODMGCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/ODMGCollection.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ODMGCollection.cs 9 Aug 2004 03:11:45 -0000 1.8 --- ODMGCollection.cs 16 Sep 2004 14:03:29 -0000 1.9 *************** *** 43,53 **** return iter.MoveNext() ? iter.Current : null; } - - public abstract void CopyTo(Array a, int index); - public abstract int Count { get; } - public abstract bool IsSynchronized { get; } - public abstract object SyncRoot { get; } - public abstract IEnumerator GetEnumerator(); - } } --- 43,46 ---- Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Map.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Map.cs 2 Sep 2004 15:07:19 -0000 1.13 --- Map.cs 16 Sep 2004 14:03:29 -0000 1.14 *************** *** 97,101 **** } ! public int Count { get { Read(); --- 97,101 ---- } ! public override int Count { get { Read(); *************** *** 104,108 **** } ! public bool IsSynchronized { get { return false; } } --- 104,108 ---- } ! public override bool IsSynchronized { get { return false; } } *************** *** 113,117 **** get { return false; } } ! public object SyncRoot { get { return this; } } --- 113,117 ---- get { return false; } } ! public override object SyncRoot { get { return this; } } *************** *** 133,137 **** } ! public IEnumerator GetEnumerator() { Read(); return map.GetEnumerator(); --- 133,137 ---- } ! public override IEnumerator GetEnumerator() { Read(); return map.GetEnumerator(); *************** *** 150,154 **** } ! public void CopyTo(System.Array array, int index) { Read(); map.CopyTo(array, index); --- 150,154 ---- } ! public override void CopyTo(System.Array array, int index) { Read(); map.CopyTo(array, index); Index: PersistentCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/PersistentCollection.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PersistentCollection.cs 10 Sep 2004 21:23:14 -0000 1.14 --- PersistentCollection.cs 16 Sep 2004 14:03:29 -0000 1.15 *************** *** 34,38 **** /// </summary> [Serializable] ! public abstract class PersistentCollection { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(PersistentCollection)); --- 34,38 ---- /// </summary> [Serializable] ! public abstract class PersistentCollection : ICollection { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(PersistentCollection)); *************** *** 368,371 **** --- 368,397 ---- #endregion + #region ICollection Members + + public abstract bool IsSynchronized + { + get; + } + + public abstract int Count + { + get; + } + + public abstract void CopyTo(Array array, int index); + + public abstract object SyncRoot + { + get; + } + + #endregion + + #region IEnumerable Members + + public abstract IEnumerator GetEnumerator(); + + #endregion } Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Set.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Set.cs 10 Sep 2004 21:23:14 -0000 1.13 --- Set.cs 16 Sep 2004 14:03:29 -0000 1.14 *************** *** 116,120 **** /// <see cref="ICollection.Count"/> /// </summary> ! public int Count { get { Read(); --- 116,120 ---- /// <see cref="ICollection.Count"/> /// </summary> ! public override int Count { get { Read(); *************** *** 126,130 **** /// <see cref="ICollection.IsSynchronized"/> /// </summary> ! public bool IsSynchronized { get { return false; } } --- 126,130 ---- /// <see cref="ICollection.IsSynchronized"/> /// </summary> ! public override bool IsSynchronized { get { return false; } } *************** *** 147,151 **** /// <see cref="ICollection.SyncRoot"/> /// </summary> ! public object SyncRoot { get { return this; } } --- 147,151 ---- /// <see cref="ICollection.SyncRoot"/> /// </summary> ! public override object SyncRoot { get { return this; } } *************** *** 178,182 **** /// <see cref="IEnumerable.GetEnumerator"/> /// </summary> ! public virtual IEnumerator GetEnumerator() { Read(); return map.Keys.GetEnumerator(); --- 178,182 ---- /// <see cref="IEnumerable.GetEnumerator"/> /// </summary> ! public override IEnumerator GetEnumerator() { Read(); return map.Keys.GetEnumerator(); *************** *** 202,206 **** /// <see cref="ICollection.CopyTo"/> /// </summary> ! public void CopyTo(System.Array array, int index) { Read(); map.CopyTo(array, index); --- 202,206 ---- /// <see cref="ICollection.CopyTo"/> /// </summary> ! public override void CopyTo(System.Array array, int index) { Read(); map.CopyTo(array, index); Index: ArrayHolder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/ArrayHolder.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ArrayHolder.cs 9 Aug 2004 03:11:45 -0000 1.11 --- ArrayHolder.cs 16 Sep 2004 14:03:29 -0000 1.12 *************** *** 265,269 **** return entry!=null; } ! } --- 265,305 ---- return entry!=null; } ! ! public override void CopyTo(Array array, int index) ! { ! ((System.Array)this.array).CopyTo(array, index); ! } ! ! public override int Count ! { ! get ! { ! return ((Array)array).Length; ! } ! } ! ! public override IEnumerator GetEnumerator() ! { ! return ((Array)array).GetEnumerator(); ! } ! ! public override bool IsSynchronized ! { ! get ! { ! return false; ! } ! } ! ! public override object SyncRoot ! { ! get ! { ! return this; ! } ! } ! ! ! } |
From: Michael D. <mik...@us...> - 2004-09-15 14:00:24
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8270/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Added tests to verify an old version can't update the db Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** FooBarTest.cs 11 Sep 2004 00:10:39 -0000 1.65 --- FooBarTest.cs 15 Sep 2004 14:00:16 -0000 1.66 *************** *** 1881,1884 **** --- 1881,1890 ---- s.Close(); + // grab a version of g that is old and hold onto it until later + // for a StaleObjectException check. + ISession sOld = sessions.OpenSession(); + GlarchProxy gOld = (GlarchProxy)sOld.Load( typeof(Glarch), gid ); + sOld.Close(); + s = sessions.OpenSession(); g = (GlarchProxy)s.Load( typeof(Glarch), gid ); *************** *** 1894,1897 **** --- 1900,1930 ---- s.Close(); + // now that g has been changed verify that we can't go back and update + // it with an old version of g + bool isStale = false; + sOld = sessions.OpenSession(); + gOld.Name = "should not update"; + try + { + sOld.Update( gOld, gid ); + sOld.Flush(); + sOld.Close(); + } + catch(Exception e) + { + Exception exc = e; + while( e!=null ) + { + if( exc is StaleObjectStateException ) + { + isStale = true; + break; + } + exc = exc.InnerException; + } + } + + Assert.IsTrue( isStale, "Did not catch a stale object exception when updating an old GlarchProxy." ); + s = sessions.OpenSession(); g = (GlarchProxy)s.Load( typeof(Glarch), gid ); |
From: Michael D. <mik...@us...> - 2004-09-15 13:20:01
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv963/NHibernate/Persister Modified Files: EntityPersister.cs Log Message: Removed commented out code. Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** EntityPersister.cs 14 Sep 2004 17:49:56 -0000 1.28 --- EntityPersister.cs 15 Sep 2004 13:19:44 -0000 1.29 *************** *** 727,743 **** } - // IDataReader rs = st.ExecuteReader(); reader = session.Batcher.ExecuteReader( st ); ! // try ! // { ! if ( reader.Read()==false ) ! { ! throw new StaleObjectStateException( MappedClass, id); ! } ! // } ! // finally ! // { ! // rs.Close(); ! // } } //TODO: add something to catch a sql exception and log it here --- 727,736 ---- } reader = session.Batcher.ExecuteReader( st ); ! ! if ( reader.Read()==false ) ! { ! throw new StaleObjectStateException( MappedClass, id); ! } } //TODO: add something to catch a sql exception and log it here |
From: Michael D. <mik...@us...> - 2004-09-15 13:18:42
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv768/NHibernate/Impl Modified Files: BatcherImpl.cs Log Message: Cleaned up code around assigning connection to a command. Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BatcherImpl.cs 15 Sep 2004 03:17:46 -0000 1.6 --- BatcherImpl.cs 15 Sep 2004 13:18:32 -0000 1.7 *************** *** 101,105 **** } ! command.Connection = session.Connection; if( session.Transaction!=null ) { --- 101,117 ---- } ! if( command.Connection!=null ) ! { ! if( command.Connection!=session.Connection ) ! { ! throw new AssertionFailure("The IDbCommand for " + command.CommandText + " has a different connection " + ! "than the Connection the Session is providing."); ! } ! } ! else ! { ! command.Connection = session.Connection; ! } ! if( session.Transaction!=null ) { |
From: Michael D. <mik...@us...> - 2004-09-15 03:17:57
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31747 Modified Files: ITransaction.cs Log Message: Moved code for an IDbCommand to enlist in a Transaction to the Transaction class. Index: ITransaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/ITransaction.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ITransaction.cs 17 Feb 2003 18:16:13 -0000 1.1 --- ITransaction.cs 15 Sep 2004 03:17:46 -0000 1.2 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Data; namespace NHibernate { *************** *** 43,46 **** --- 44,55 ---- bool WasCommitted { get; } + /// <summary> + /// Enlist the <see cref="IDbCommand"/> in the current Transaction. + /// </summary> + /// <param name="command">The <see cref="IDbCommand"/> to enlist.</param> + /// <remarks> + /// It is okay for this to be a no op implementation. + /// </remarks> + void Enlist(IDbCommand command); } } |
From: Michael D. <mik...@us...> - 2004-09-15 03:17:57
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31747/Impl Modified Files: BatcherImpl.cs Log Message: Moved code for an IDbCommand to enlist in a Transaction to the Transaction class. Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BatcherImpl.cs 14 Sep 2004 17:49:55 -0000 1.5 --- BatcherImpl.cs 15 Sep 2004 03:17:46 -0000 1.6 *************** *** 102,106 **** command.Connection = session.Connection; ! JoinTransaction( command ); if( factory.ConnectionProvider.Driver.SupportsPreparingCommands ) --- 102,110 ---- command.Connection = session.Connection; ! if( session.Transaction!=null ) ! { ! session.Transaction.Enlist( command ); ! } ! if( factory.ConnectionProvider.Driver.SupportsPreparingCommands ) *************** *** 117,170 **** } - /// <summary> - /// Joins the Command to the Transaction and ensures that the Session and IDbCommand are in - /// the same Transaction. - /// </summary> - /// <param name="command">The command to setup the Transaction on.</param> - /// <returns>A IDbCommand with a valid Transaction property.</returns> - /// TODO: move this into ITransaction and let the Transaction figure out how to - /// get the Command to be a part of it. When .net 2.0 and the new transaction interface - /// comes out it will probably have its own strategy... - private void JoinTransaction(IDbCommand command) - { - IDbTransaction sessionAdoTrx = null; - - // at this point in the code if the Transaction is not null then we know we - // have a Transaction object that has the .AdoTransaction property. In the future - // we will have a seperate object to represent an AdoTransaction and won't have a - // generic Transaction class - the existing Transaction class will become Abstract. - if(this.session.Transaction!=null) sessionAdoTrx = ((Transaction.Transaction)session.Transaction).AdoTransaction; - - - // if the sessionAdoTrx is null then we don't want the command to be a part of - // any Transaction - so lets set the command trx to null - if(sessionAdoTrx==null) - { - if(command.Transaction!=null) - { - log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); - } - command.Transaction = null; - } - - // make sure these are the same transaction - I don't know why we would have a command - // in a different Transaction than the Session, but I don't understand all of the code - // well enough yet to verify that. - else if (sessionAdoTrx!=command.Transaction) - { - - // got into here because the command was being initialized and had a null Transaction - probably - // don't need to be confused by that - just a normal part of initialization... - if(command.Transaction!=null) - { - log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + - "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); - } - - command.Transaction = sessionAdoTrx; - } - - } - public IDbCommand PrepareBatchCommand(SqlString sql) { --- 121,124 ---- |
From: Michael D. <mik...@us...> - 2004-09-15 03:17:57
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31747/Transaction Modified Files: Transaction.cs Log Message: Moved code for an IDbCommand to enlist in a Transaction to the Transaction class. Index: Transaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/Transaction.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Transaction.cs 28 Aug 2004 04:07:05 -0000 1.3 --- Transaction.cs 15 Sep 2004 03:17:47 -0000 1.4 *************** *** 32,35 **** --- 32,61 ---- } + public void Enlist(IDbCommand command) + { + if( trans==null ) + { + if(command.Transaction!=null) + { + log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); + } + command.Transaction = null; + return; + } + else + { + + // got into here because the command was being initialized and had a null Transaction - probably + // don't need to be confused by that - just a normal part of initialization... + if(command.Transaction!=null) + { + log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + + "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); + } + + command.Transaction = trans; + } + } + public void Begin() { |
From: Michael D. <mik...@us...> - 2004-09-14 17:50:34
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11256/Driver Modified Files: NDataReader.cs Added Files: NHybridDataReader.cs Log Message: Major refactoring with NDataReader and Batcher. NHibernate now uses an IDataReader returned from the Driver for as long as possible before converting to a NDataReader. This has nice perf gains on the simple performance test in the Test Fixtures. --- NEW FILE: NHybridDataReader.cs --- using System; using System.Data; namespace NHibernate.Driver { /// <summary> /// An implementation of <see cref="IDataReader"/> that will work with either an /// <see cref="IDataReader"/> returned by Execute or with an <see cref="IDataReader"/> /// whose contents have been read into a <see cref="NDataReader"/>. /// </summary> /// <remarks> /// <para> /// This allows NHibernate to use the underlying <see cref="IDataReader"/> for as long as /// possible without the need to read everything into the <see cref="NDataReader"/>. /// </para> /// <para> /// The consumer of the <see cref="IDataReader"/> returned from <see cref="Engine.IBatcher"/> does /// not need to know the underlying reader and can use it the same even if it switches from an /// <see cref="IDataReader"/> to <see cref="NDataReader"/> in the middle of its use. /// </para> /// </remarks> public class NHybridDataReader : IDataReader { log4net.ILog log = log4net.LogManager.GetLogger( typeof(NHybridDataReader) ); IDataReader _reader; bool _isMidstream = false; /// <summary> /// Initializes a new instance of the NHybridDataReader class. /// </summary> /// <param name="reader">The underlying IDataReader to use.</param> public NHybridDataReader(IDataReader reader) : this(reader, false) { } /// <summary> /// Initializes a new instance of the NHybridDataReader class. /// </summary> /// <param name="reader">The underlying IDataReader to use.</param> /// <param name="inMemory"><c>true</c> if the contents of the IDataReader should be read into memory right away.</param> public NHybridDataReader(IDataReader reader, bool inMemory) { if( inMemory ) { _reader = new NDataReader( reader, false ); } else { _reader = reader; } } /// <summary> /// Reads all of the contents into memory because another <see cref="IDataReader"/> /// needs to be opened. /// </summary> /// <remarks> /// This will result in a no op if the reader is closed or is already in memory. /// </remarks> public void ReadIntoMemory() { if( _reader.IsClosed==false && _reader.GetType()!=typeof(NDataReader) ) { if( log.IsDebugEnabled ) { log.Debug("Moving IDataReader into an NDataReader. It was converted in midstream " + _isMidstream.ToString() ); } _reader = new NDataReader( _reader, _isMidstream ); } } /// <summary> /// Gets if the object is in the middle of reading a Result. /// </summary> /// <value><c>true</c> if NextResult and Read have been called on the <see cref="IDataReader"/>.</value> public bool IsMidstream { get { return _isMidstream; } } #region IDataReader Members public int RecordsAffected { get { return _reader.RecordsAffected; } } public bool IsClosed { get { return _reader.IsClosed; } } public bool NextResult() { // we are not in middle of a result _isMidstream = false; return _reader.NextResult(); } public void Close() { _reader.Close(); } public bool Read() { _isMidstream = true; return _reader.Read(); } public int Depth { get { return _reader.Depth; } } public DataTable GetSchemaTable() { return _reader.GetSchemaTable(); } #endregion #region IDisposable Members public void Dispose() { _reader.Dispose(); } #endregion #region IDataRecord Members public int GetInt32(int i) { return _reader.GetInt32(i); } public object this[string name] { get { return _reader[name]; } } object System.Data.IDataRecord.this[int i] { get { return _reader[i]; } } public object GetValue(int i) { return _reader.GetValue(i); } public bool IsDBNull(int i) { return _reader.IsDBNull(i); } public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { return _reader.GetBytes( i, fieldOffset, buffer, bufferoffset, length ); } public byte GetByte(int i) { return _reader.GetByte(i); } public System.Type GetFieldType(int i) { return _reader.GetFieldType(i); } public decimal GetDecimal(int i) { return _reader.GetDecimal(i); } public int GetValues(object[] values) { return _reader.GetValues( values ); } public string GetName(int i) { return _reader.GetName(i); } public int FieldCount { get { return _reader.FieldCount; } } public long GetInt64(int i) { return _reader.GetInt64(i); } public double GetDouble(int i) { return _reader.GetDouble(i); } public bool GetBoolean(int i) { return _reader.GetBoolean(i); } public Guid GetGuid(int i) { return _reader.GetGuid(i); } public DateTime GetDateTime(int i) { return _reader.GetDateTime(i); } public int GetOrdinal(string name) { return _reader.GetOrdinal(name); } public string GetDataTypeName(int i) { return _reader.GetDataTypeName(i); } public float GetFloat(int i) { return _reader.GetFloat(i); } public IDataReader GetData(int i) { return _reader.GetData(i); } public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { return _reader.GetChars( i, fieldoffset, buffer, bufferoffset, length ); } public string GetString(int i) { return _reader.GetString(i); } public char GetChar(int i) { return _reader.GetChar(i); } public short GetInt16(int i) { return _reader.GetInt16(i); } #endregion } } Index: NDataReader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/NDataReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NDataReader.cs 24 Jun 2004 15:23:52 -0000 1.2 --- NDataReader.cs 14 Sep 2004 17:49:54 -0000 1.3 *************** *** 32,39 **** /// <summary> ! /// Creates a NDataReader from a IDataReader /// </summary> ! /// <param name="reader">The IDataReader to get the records from the Database.</param> ! public NDataReader(IDataReader reader) { ArrayList resultList = new ArrayList(2); --- 32,46 ---- /// <summary> ! /// Creates a NDataReader from a <see cref="IDataReader" /> /// </summary> ! /// <param name="reader">The <see cref="IDataReader" /> to get the records from the Database.</param> ! /// <param name="isMidstream"><c>true</c> if we are loading the <see cref="IDataReader" /> in the middle of reading it.</param> ! /// <remarks> ! /// NHibernate attempts to not have to read the contents of an <see cref="IDataReader"/> into memory until it absolutely ! /// has to. What that means is that it might have processed some records from the <see cref="IDataReader"/> and will ! /// pick up the <see cref="IDataReader"/> midstream so that the underlying <see cref="IDataReader"/> can be closed ! /// so a new one can be opened. ! /// </remarks> ! public NDataReader(IDataReader reader, bool isMidstream) { ArrayList resultList = new ArrayList(2); *************** *** 41,50 **** try { // there will be atleast one result ! resultList.Add( new NResult(reader) ); while( reader.NextResult() ) { ! resultList.Add( new NResult(reader) ); } --- 48,62 ---- try { + // if we are in midstream of processing a DataReader then we are already + // positioned on the first row (index=0) + if( isMidstream ) currentRowIndex = 0; + // there will be atleast one result ! resultList.Add( new NResult(reader, isMidstream) ); while( reader.NextResult() ) { ! // the second, third, nth result is not processed midstream ! resultList.Add( new NResult(reader, false) ); } *************** *** 121,125 **** public void Close() { - // TODO: Add NDataReader.Close implementation isClosed = true; } --- 133,136 ---- *************** *** 160,164 **** public void Dispose() { ! // TODO: Add NDataReader.Dispose implementation } --- 171,177 ---- public void Dispose() { ! isClosed = true; ! ClearCache(); ! results = null; } *************** *** 343,347 **** private readonly ArrayList fieldDataTypeNames = new ArrayList(); ! internal NResult(IDataReader reader) { schemaTable = reader.GetSchemaTable(); --- 356,368 ---- private readonly ArrayList fieldDataTypeNames = new ArrayList(); ! /// <summary> ! /// Initializes a new instance of the NResult class. ! /// </summary> ! /// <param name="reader">The IDataReader to populate the Result with.</param> ! /// <param name="isMidstream"> ! /// <c>true</c> if the <see cref="IDataReader"/> is already positioned on the record ! /// to start reading from. ! /// </param> ! internal NResult(IDataReader reader, bool isMidstream) { schemaTable = reader.GetSchemaTable(); *************** *** 350,354 **** int rowIndex = 0; ! while( reader.Read() ) { if(rowIndex==0) --- 371,377 ---- int rowIndex = 0; ! // if we are in the middle of processing the reader then don't bother ! // to move to the next record - just use the current one. ! while( isMidstream || reader.Read() ) { if(rowIndex==0) *************** *** 372,376 **** --- 395,403 ---- recordsList.Add(colValues); + // we can go back to reading a reader like normal and don't need + // to consider where we started from. + isMidstream = false; } + records = (object[][])recordsList.ToArray( typeof(object[]) ); |
From: Michael D. <mik...@us...> - 2004-09-14 17:50:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11256 Modified Files: NHibernate-1.1.csproj Log Message: Major refactoring with NDataReader and Batcher. NHibernate now uses an IDataReader returned from the Driver for as long as possible before converting to a NDataReader. This has nice perf gains on the simple performance test in the Test Fixtures. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** NHibernate-1.1.csproj 31 Aug 2004 13:14:24 -0000 1.43 --- NHibernate-1.1.csproj 14 Sep 2004 17:49:53 -0000 1.44 *************** *** 541,544 **** --- 541,549 ---- /> <File + RelPath = "Driver\NHybridDataReader.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Driver\OdbcDriver.cs" SubType = "Code" *************** *** 609,617 **** /> <File - RelPath = "Engine\IPreparer.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Engine\ISessionFactoryImplementor.cs" SubType = "Code" --- 614,617 ---- *************** *** 969,977 **** /> <File - RelPath = "Impl\PreparerImpl.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Impl\QueryImpl.cs" SubType = "Code" --- 969,972 ---- |
From: Michael D. <mik...@us...> - 2004-09-14 17:50:07
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11256/Persister Modified Files: EntityPersister.cs NormalizedEntityPersister.cs Log Message: Major refactoring with NDataReader and Batcher. NHibernate now uses an IDataReader returned from the Driver for as long as possible before converting to a NDataReader. This has nice perf gains on the simple performance test in the Test Fixtures. Index: NormalizedEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/NormalizedEntityPersister.cs,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** NormalizedEntityPersister.cs 30 Aug 2004 02:49:06 -0000 1.30 --- NormalizedEntityPersister.cs 14 Sep 2004 17:49:56 -0000 1.31 *************** *** 944,947 **** --- 944,949 ---- IDbCommand st = session.Batcher.PrepareCommand( (SqlString)lockers[lockMode] ); + IDataReader rs = null; + try { *************** *** 952,967 **** } ! IDataReader rs = st.ExecuteReader(); ! try ! { if ( !rs.Read() ) { throw new StaleObjectStateException(MappedClass, id); } ! } ! finally ! { ! rs.Close(); ! } } //TODO: change this to catch a Sql Exception and log it --- 954,970 ---- } ! // IDataReader rs = st.ExecuteReader(); ! rs = session.Batcher.ExecuteReader( st ); ! // try ! // { if ( !rs.Read() ) { throw new StaleObjectStateException(MappedClass, id); } ! // } ! // finally ! // { ! // rs.Close(); ! // } } //TODO: change this to catch a Sql Exception and log it *************** *** 972,976 **** finally { ! session.Batcher.CloseCommand(st); } } --- 975,979 ---- finally { ! session.Batcher.CloseCommand(st, rs); } } *************** *** 1049,1053 **** for (int i = 0; i < tableNames.Length; i++) { ! insertCmds[i].ExecuteNonQuery(); } --- 1052,1056 ---- for (int i = 0; i < tableNames.Length; i++) { ! session.Batcher.ExecuteNonQuery( insertCmds[i] ); } *************** *** 1064,1068 **** if( insertCmds[i]!=null ) { ! session.Batcher.CloseCommand( insertCmds[i] ); } } --- 1067,1071 ---- if( insertCmds[i]!=null ) { ! session.Batcher.CloseCommand( insertCmds[i], null ); } } *************** *** 1087,1106 **** IDbCommand statement = null; IDbCommand idSelect = null; object id; - // still using the Preparer instead of Batcher because the Batcher won't work - // with 2 commands being Prepared back to back - when the second SqlString gets - // prepared that would cause it to execute the first SqlString - which is not - // what we want because no values have been put into the parameter. if(dialect.SupportsIdentitySelectInInsert) { ! statement = session.Preparer.PrepareCommand( dialect.AddIdentitySelectToInsert(sql[0]) ); idSelect = statement; } else { ! statement = session.Preparer.PrepareCommand(sql[0]); ! idSelect = session.Preparer.PrepareCommand(SqlIdentitySelect); } --- 1090,1109 ---- IDbCommand statement = null; IDbCommand idSelect = null; + IDataReader rs = null; object id; if(dialect.SupportsIdentitySelectInInsert) { ! statement = session.Batcher.PrepareCommand( dialect.AddIdentitySelectToInsert(sql[0]) ); idSelect = statement; } else { ! // do not Prepare the Command to be part of a batch. When the second command ! // is Prepared for the Batch that would cause the first one to be executed and ! // we don't want that yet. ! statement = session.Batcher.Generate( sql[0] ); ! idSelect = session.Batcher.PrepareCommand( new SqlString( SqlIdentitySelect ) ); } *************** *** 1120,1139 **** if(dialect.SupportsIdentitySelectInInsert==false) { ! statement.ExecuteNonQuery(); } ! IDataReader rs = idSelect.ExecuteReader(); ! try ! { ! if ( !rs.Read() ) ! { ! throw new HibernateException("The database returned no natively generated identity value"); ! } ! id = IdentifierGeneratorFactory.Get( rs, IdentifierType.ReturnedClass ); ! } ! finally { ! rs.Close(); } log.Debug("Natively generated identity: " + id); --- 1123,1135 ---- if(dialect.SupportsIdentitySelectInInsert==false) { ! session.Batcher.ExecuteNonQuery( statement ); } ! rs = session.Batcher.ExecuteReader( idSelect ); ! if ( !rs.Read() ) { ! throw new HibernateException("The database returned no natively generated identity value"); } + id = IdentifierGeneratorFactory.Get( rs, IdentifierType.ReturnedClass ); log.Debug("Natively generated identity: " + id); *************** *** 1147,1162 **** finally { ! // session.Batcher.CloseStatement(statement); ! // session.Batcher.CloseStatement(idselect); } for (int i=1; i<naturalOrderTableNames.Length; i++ ) { ! statement = session.Preparer.PrepareCommand(sql[i]); ! try { Dehydrate(id, fields, notNull, i, statement, session); ! statement.ExecuteNonQuery(); } //TODO: change this to SQLException and log it --- 1143,1160 ---- finally { ! if( dialect.SupportsIdentitySelectInInsert==false ) ! { ! session.Batcher.CloseCommand( statement, null ); ! } ! session.Batcher.CloseCommand( idSelect, rs ); } for (int i=1; i<naturalOrderTableNames.Length; i++ ) { ! statement = session.Batcher.PrepareCommand( sql[i] ); try { Dehydrate(id, fields, notNull, i, statement, session); ! session.Batcher.ExecuteNonQuery( statement ); } //TODO: change this to SQLException and log it *************** *** 1167,1171 **** finally { ! //session.Batcher.CloseStatement(statement); } } --- 1165,1169 ---- finally { ! session.Batcher.CloseCommand( statement, null ); } } *************** *** 1206,1210 **** IdentifierType.NullSafeSet( statements[i], id, 0, session ); ! Check( statements[i].ExecuteNonQuery(), id ); } } --- 1204,1208 ---- IdentifierType.NullSafeSet( statements[i], id, 0, session ); ! Check( session.Batcher.ExecuteNonQuery( statements[i] ), id ); } } *************** *** 1217,1221 **** for (int i=0; i<naturalOrderTableNames.Length; i++) { ! if (statements[i]!=null ) session.Batcher.CloseCommand( statements[i] ); } } --- 1215,1222 ---- for (int i=0; i<naturalOrderTableNames.Length; i++) { ! if (statements[i]!=null ) ! { ! session.Batcher.CloseCommand( statements[i], null ); ! } } } *************** *** 1303,1307 **** for (int i=0; i<tables; i++ ) { ! if ( includeTable[i] ) Check(statements[i].ExecuteNonQuery(), id ); } } --- 1304,1311 ---- for (int i=0; i<tables; i++ ) { ! if ( includeTable[i] ) ! { ! Check( session.Batcher.ExecuteNonQuery( statements[i] ), id ); ! } } } *************** *** 1316,1320 **** if ( statements[i]!=null ) { ! session.Batcher.CloseCommand( statements[i] ); } } --- 1320,1324 ---- if ( statements[i]!=null ) { ! session.Batcher.CloseCommand( statements[i], null ); } } Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** EntityPersister.cs 30 Aug 2004 02:49:06 -0000 1.27 --- EntityPersister.cs 14 Sep 2004 17:49:56 -0000 1.28 *************** *** 716,719 **** --- 716,720 ---- IDbCommand st = session.Batcher.PrepareCommand( (SqlString)lockers[lockMode] ); + IDataReader reader = null; try *************** *** 726,743 **** } ! IDataReader rs = st.ExecuteReader(); ! try ! { ! if ( rs.Read()==false ) throw new StaleObjectStateException( MappedClass, id); ! } ! finally ! { ! rs.Close(); ! } } //TODO: add something to catch a sql exception and log it here finally { ! session.Batcher.CloseCommand(st); } } --- 727,748 ---- } ! // IDataReader rs = st.ExecuteReader(); ! reader = session.Batcher.ExecuteReader( st ); ! // try ! // { ! if ( reader.Read()==false ) ! { ! throw new StaleObjectStateException( MappedClass, id); ! } ! // } ! // finally ! // { ! // rs.Close(); ! // } } //TODO: add something to catch a sql exception and log it here finally { ! session.Batcher.CloseCommand( st, reader ); } } *************** *** 832,849 **** IDbCommand statement = null; IDbCommand idSelect = null; - // still using the Preparer instead of Batcher because the Batcher won't work - // with 2 commands being Prepared back to back - when the second SqlString gets - // prepared that would cause it to execute the first SqlString - which is not - // what we want because no values have been put into the parameter. if(dialect.SupportsIdentitySelectInInsert) { ! statement = session.Preparer.PrepareCommand( dialect.AddIdentitySelectToInsert(sql) ); idSelect = statement; } else { ! statement = session.Preparer.PrepareCommand( sql ); ! idSelect = session.Preparer.PrepareCommand( SqlIdentitySelect ); } --- 837,854 ---- IDbCommand statement = null; IDbCommand idSelect = null; + IDataReader rs = null; if(dialect.SupportsIdentitySelectInInsert) { ! statement = session.Batcher.PrepareCommand( dialect.AddIdentitySelectToInsert(sql) ); idSelect = statement; } else { ! // do not Prepare the Command to be part of a batch. When the second command ! // is Prepared for the Batch that would cause the first one to be executed and ! // we don't want that yet. ! statement = session.Batcher.Generate( sql ); ! idSelect = session.Batcher.PrepareCommand( new SqlString( SqlIdentitySelect ) ); } *************** *** 863,880 **** if(dialect.SupportsIdentitySelectInInsert==false) { ! statement.ExecuteNonQuery(); } ! IDataReader rs = idSelect.ExecuteReader(); object id; ! try ! { ! if ( !rs.Read() ) throw new HibernateException("The database returned no natively generated identity value"); ! id = IdentifierGeneratorFactory.Get( rs, IdentifierType.ReturnedClass ); ! } ! finally { ! rs.Close(); } log.Debug("Natively generated identity: " + id); --- 868,882 ---- if(dialect.SupportsIdentitySelectInInsert==false) { ! session.Batcher.ExecuteNonQuery( statement ); } ! rs = session.Batcher.ExecuteReader( idSelect ); object id; ! ! if ( !rs.Read() ) { ! throw new HibernateException("The database returned no natively generated identity value"); } + id = IdentifierGeneratorFactory.Get( rs, IdentifierType.ReturnedClass ); log.Debug("Natively generated identity: " + id); *************** *** 889,894 **** finally { ! // session.Batcher.CloseStatement(statement); ! // session.Batcher.CloseStatement(idselect); } } --- 891,899 ---- finally { ! if( dialect.SupportsIdentitySelectInInsert==false ) ! { ! session.Batcher.CloseCommand( statement, null ); ! } ! session.Batcher.CloseCommand( idSelect, rs ); } } *************** *** 931,935 **** { VersionType.NullSafeSet(deleteCmd, version, IdentifierColumnNames.Length, session); ! Check(deleteCmd.ExecuteNonQuery(), id); } else --- 936,940 ---- { VersionType.NullSafeSet(deleteCmd, version, IdentifierColumnNames.Length, session); ! Check( session.Batcher.ExecuteNonQuery( deleteCmd ) , id); } else *************** *** 947,951 **** if( IsVersioned ) { ! session.Batcher.CloseCommand( deleteCmd ); } } --- 952,956 ---- if( IsVersioned ) { ! session.Batcher.CloseCommand( deleteCmd, null ); } } *************** *** 1026,1030 **** { VersionType.NullSafeSet( statement, oldVersion, versionParamIndex, session); ! Check( statement.ExecuteNonQuery(), id ); } else --- 1031,1035 ---- { VersionType.NullSafeSet( statement, oldVersion, versionParamIndex, session); ! Check( session.Batcher.ExecuteNonQuery( statement ), id ); } else *************** *** 1053,1057 **** if( IsVersioned ) { ! session.Batcher.CloseCommand( statement ); } } --- 1058,1062 ---- if( IsVersioned ) { ! session.Batcher.CloseCommand( statement, null ); } } |
From: Michael D. <mik...@us...> - 2004-09-14 17:50:05
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11256/Impl Modified Files: BatcherImpl.cs EnumerableImpl.cs NonBatchingBatcher.cs SessionImpl.cs Removed Files: PreparerImpl.cs Log Message: Major refactoring with NDataReader and Batcher. NHibernate now uses an IDataReader returned from the Driver for as long as possible before converting to a NDataReader. This has nice perf gains on the simple performance test in the Test Fixtures. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** SessionImpl.cs 28 Aug 2004 04:19:22 -0000 1.40 --- SessionImpl.cs 14 Sep 2004 17:49:55 -0000 1.41 *************** *** 92,98 **** [NonSerialized] private IBatcher batcher; - - [NonSerialized] private IPreparer preparer; - /// <summary> --- 92,95 ---- *************** *** 525,537 **** } - public IPreparer Preparer - { - get - { - if (preparer == null) preparer = new PreparerImpl(factory, this); - return preparer; - } - } - public ISessionFactoryImplementor Factory { --- 522,525 ---- Index: EnumerableImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/EnumerableImpl.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EnumerableImpl.cs 2 Sep 2004 13:04:58 -0000 1.5 --- EnumerableImpl.cs 14 Sep 2004 17:49:55 -0000 1.6 *************** *** 37,41 **** /// </summary> /// <param name="reader">The <see cref="IDataReader"/> to enumerate over.</param> ! /// <param name="cmd">TODO: is this needed?</param> /// <param name="sess">The <see cref="ISession"/> to use to load objects.</param> /// <param name="types">The <see cref="IType"/>s contained in the <see cref="IDataReader"/>.</param> --- 37,41 ---- /// </summary> /// <param name="reader">The <see cref="IDataReader"/> to enumerate over.</param> ! /// <param name="cmd">The <see cref="IDbCommand"/> used to create the <see cref="IDataReader"/>.</param> /// <param name="sess">The <see cref="ISession"/> to use to load objects.</param> /// <param name="types">The <see cref="IType"/>s contained in the <see cref="IDataReader"/>.</param> *************** *** 70,76 **** log.Debug("exhausted results"); _currentResults = null; ! _reader.Close(); ! //TODO: H2.0.3 code to synch here to close the QueryStatement ! //sess.Batcher.CloseQueryStatement( cmd, rs ); } else --- 70,74 ---- log.Debug("exhausted results"); _currentResults = null; ! _sess.Batcher.CloseQueryCommand( _cmd, _reader ); } else --- PreparerImpl.cs DELETED --- Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BatcherImpl.cs 31 Aug 2004 13:14:25 -0000 1.4 --- BatcherImpl.cs 14 Sep 2004 17:49:55 -0000 1.5 *************** *** 3,6 **** --- 3,7 ---- using System.Data; + using NHibernate.Driver; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 70,81 **** return batchCommand; } ! public IDbCommand PrepareCommand(SqlString sql) { ExecuteBatch(); LogOpenPreparedCommands(); ! return session.Preparer.PrepareCommand(sql); } --- 71,190 ---- return batchCommand; } + + public IDbCommand Generate(SqlString sqlString) + { + IDbCommand cmd = factory.ConnectionProvider.Driver.GenerateCommand(factory.Dialect, sqlString); + if(log.IsDebugEnabled) + { + log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() ); + } + return cmd; + + } ! /// <summary> ! /// Prepares the <see cref="IDbCommand"/> for execution in the database. ! /// </summary> ! /// <param name="command"></param> ! /// <remarks> ! /// This takes care of hooking the <see cref="IDbCommand"/> up to an <see cref="IDbConnection"/> ! /// and <see cref="IDbTransaction"/> if one exists. It will call <c>Prepare</c> if the Driver ! /// supports preparing commands. ! /// </remarks> ! private void Prepare(IDbCommand command) { + try + { + if(log.IsInfoEnabled) + { + log.Info("Preparing " + command.CommandText); + } + + command.Connection = session.Connection; + JoinTransaction( command ); + if( factory.ConnectionProvider.Driver.SupportsPreparingCommands ) + { + command.Prepare(); + } + } + catch(Exception e) + { + throw new ApplicationException( + "While preparing " + command.CommandText + " an error occurred" + , e); + } + } + + /// <summary> + /// Joins the Command to the Transaction and ensures that the Session and IDbCommand are in + /// the same Transaction. + /// </summary> + /// <param name="command">The command to setup the Transaction on.</param> + /// <returns>A IDbCommand with a valid Transaction property.</returns> + /// TODO: move this into ITransaction and let the Transaction figure out how to + /// get the Command to be a part of it. When .net 2.0 and the new transaction interface + /// comes out it will probably have its own strategy... + private void JoinTransaction(IDbCommand command) + { + IDbTransaction sessionAdoTrx = null; + + // at this point in the code if the Transaction is not null then we know we + // have a Transaction object that has the .AdoTransaction property. In the future + // we will have a seperate object to represent an AdoTransaction and won't have a + // generic Transaction class - the existing Transaction class will become Abstract. + if(this.session.Transaction!=null) sessionAdoTrx = ((Transaction.Transaction)session.Transaction).AdoTransaction; + + + // if the sessionAdoTrx is null then we don't want the command to be a part of + // any Transaction - so lets set the command trx to null + if(sessionAdoTrx==null) + { + if(command.Transaction!=null) + { + log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); + } + command.Transaction = null; + } + + // make sure these are the same transaction - I don't know why we would have a command + // in a different Transaction than the Session, but I don't understand all of the code + // well enough yet to verify that. + else if (sessionAdoTrx!=command.Transaction) + { + + // got into here because the command was being initialized and had a null Transaction - probably + // don't need to be confused by that - just a normal part of initialization... + if(command.Transaction!=null) + { + log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + + "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); + } + + command.Transaction = sessionAdoTrx; + } + + } + + public IDbCommand PrepareBatchCommand(SqlString sql) + { + if ( !sql.Equals(batchCommandSql) ) + { + batchCommand = PrepareCommand(sql); // calls ExecuteBatch() + batchCommandSql=sql; + } + return batchCommand; + } + + public IDbCommand PrepareCommand(SqlString sql) + { ExecuteBatch(); LogOpenPreparedCommands(); ! // do not actually prepare the Command here - instead just generate it because ! // if the command is associated with an ADO.NET Transaction/Connection while ! // another open one Command is doing something then an exception will be ! // thrown. ! return Generate( sql ); } *************** *** 85,89 **** // to ado.net since DataReader is forward only LogOpenPreparedCommands(); ! IDbCommand command = session.Preparer.PrepareCommand(sql); // not sure if this is needed because fetch size doesn't apply --- 194,203 ---- // to ado.net since DataReader is forward only LogOpenPreparedCommands(); ! ! // do not actually prepare the Command here - instead just generate it because ! // if the command is associated with an ADO.NET Transaction/Connection while ! // another open one Command is doing something then an exception will be ! // thrown. ! IDbCommand command = Generate( sql ); // session.Preparer.BuildCommand(sql); // not sure if this is needed because fetch size doesn't apply *************** *** 103,109 **** } ! public IDataReader GetDataReader(IDbCommand cmd) { ! IDataReader reader = cmd.ExecuteReader(); readersToClose.Add(reader); LogOpenReaders(); --- 217,248 ---- } ! public int ExecuteNonQuery(IDbCommand cmd) { ! int rowsAffected = 0; ! ! CheckReaders(); ! ! Prepare( cmd ); ! rowsAffected = cmd.ExecuteNonQuery(); ! ! return rowsAffected; ! } ! ! public IDataReader ExecuteReader(IDbCommand cmd) ! { ! CheckReaders(); ! ! Prepare( cmd );; ! ! IDataReader reader; ! if( factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders==false ) ! { ! reader = new NHybridDataReader( cmd.ExecuteReader() ); ! } ! else ! { ! reader = cmd.ExecuteReader(); ! } ! readersToClose.Add(reader); LogOpenReaders(); *************** *** 111,167 **** } ! public void CloseQueryCommand(IDbCommand st, IDataReader reader) { ! commandsToClose.Remove(st); ! if( reader!=null ) { ! readersToClose.Remove(reader); } ! try ! { ! if( reader!=null) ! { ! LogCloseReaders(); ! reader.Close(); ! } ! } ! finally { ! CloseQueryCommand(st); } } ! public IDbCommand PrepareBatchCommand(SqlString sql) { ! if ( !sql.Equals(batchCommandSql) ) ! { ! batchCommand = PrepareCommand(sql); // calls ExecuteBatch() ! batchCommandSql=sql; ! } ! return batchCommand; } ! public void ExecuteBatch() { ! if ( batchCommand!=null ) { - IDbCommand ps = batchCommand; - batchCommand = null; - batchCommandSql = null; try { ! DoExecuteBatch(ps); } ! finally { ! CloseCommand(ps); } } ! } ! public void CloseCommand(IDbCommand cmd) ! { ! LogClosePreparedCommands(); } --- 250,309 ---- } ! /// <summary> ! /// Ensures that the Driver's rules for Multiple Open DataReaders are being followed. ! /// </summary> ! private void CheckReaders() { ! // early exit because we don't need to move an open IDataReader into memory ! // since the Driver supports mult open readers. ! if( factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders ) { ! return; } ! for( int i=0; i<readersToClose.Count; i++ ) { ! ((NHybridDataReader)readersToClose[i]).ReadIntoMemory(); } + } ! public void CloseCommand(IDbCommand cmd, IDataReader reader) { ! //TODO: fix this up a little bit - don't like it having the same name and just ! // turning around and calling a diff method. ! CloseQueryCommand( cmd, reader ); ! //LogClosePreparedCommands(); } ! public void CloseCommands() { ! foreach( IDataReader reader in readersToClose ) { try { ! LogCloseReaders(); ! reader.Close(); } ! catch( Exception e ) { ! log.Warn( "Could not close IDataReader", e ); } } ! readersToClose.Clear(); ! foreach( IDbCommand cmd in commandsToClose ) ! { ! try ! { ! CloseQueryCommand(cmd); ! } ! catch(Exception e) ! { ! // no big deal ! log.Warn("Could not close a JDBC statement", e); ! } ! } ! commandsToClose.Clear(); } *************** *** 179,214 **** } ! CloseCommand( cmd ); } ! public void CloseCommands() { ! foreach( IDataReader reader in readersToClose ) { ! try { LogCloseReaders(); reader.Close(); } - catch( Exception e ) - { - log.Warn( "Could not close IDataReader", e ); - } } ! readersToClose.Clear(); ! foreach( IDbCommand cmd in commandsToClose ) { try { ! CloseQueryCommand(cmd); ! } ! catch(Exception e) { ! // no big deal ! log.Warn("Could not close a JDBC statement", e); } } - commandsToClose.Clear(); } --- 321,365 ---- } ! // CloseCommand( cmd, null ); } ! public void CloseQueryCommand(IDbCommand st, IDataReader reader) { ! commandsToClose.Remove(st); ! if( reader!=null ) { ! readersToClose.Remove(reader); ! } ! ! try ! { ! if( reader!=null) { LogCloseReaders(); reader.Close(); } } ! finally ! { ! CloseQueryCommand(st); ! } ! } ! public void ExecuteBatch() ! { ! if ( batchCommand!=null ) { + IDbCommand ps = batchCommand; + batchCommand = null; + batchCommandSql = null; try { ! DoExecuteBatch(ps); ! } ! finally { ! CloseCommand(ps, null); } } } *************** *** 231,243 **** { log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); - openCommandCount++; } } private static void LogClosePreparedCommands() { if ( log.IsDebugEnabled ) { - openCommandCount--; log.Debug( "done closing: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); } --- 382,395 ---- { log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); } + openCommandCount++; } private static void LogClosePreparedCommands() { + openCommandCount--; + if ( log.IsDebugEnabled ) { log.Debug( "done closing: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); } *************** *** 246,262 **** private static void LogOpenReaders() { ! if( log.IsDebugEnabled ) ! { ! openReaderCount++; ! } } private static void LogCloseReaders() { ! if( log.IsDebugEnabled ) ! { ! openReaderCount--; ! } } } } --- 398,410 ---- private static void LogOpenReaders() { ! openReaderCount++; } private static void LogCloseReaders() { ! openReaderCount--; } + + } } Index: NonBatchingBatcher.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/NonBatchingBatcher.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NonBatchingBatcher.cs 28 Aug 2004 04:18:40 -0000 1.5 --- NonBatchingBatcher.cs 14 Sep 2004 17:49:55 -0000 1.6 *************** *** 16,20 **** public override void AddToBatch(int expectedRowCount) { ! int rowCount = GetCommand().ExecuteNonQuery(); //negative expected row count means we don't know how many rows to expect --- 16,20 ---- public override void AddToBatch(int expectedRowCount) { ! int rowCount = this.ExecuteNonQuery( this.GetCommand() ); //negative expected row count means we don't know how many rows to expect |