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...> - 2005-04-18 02:55:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18776/NHibernate/Expression Modified Files: Example.cs InExpression.cs InsensitiveLikeExpression.cs LeExpression.cs LePropertyExpression.cs LtExpression.cs LtPropertyExpression.cs MatchMode.cs Log Message: Finished up the QBE Tests. Index: InsensitiveLikeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/InsensitiveLikeExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** InsensitiveLikeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 --- InsensitiveLikeExpression.cs 18 Apr 2005 02:55:29 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using NHibernate.Dialect; Index: Example.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Example.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Example.cs 17 Apr 2005 17:16:05 -0000 1.2 --- Example.cs 18 Apr 2005 02:55:28 -0000 1.3 *************** *** 1,7 **** using System; using System.Collections; - using Iesi.Collections; - using NHibernate.Engine; using NHibernate.Metadata; --- 1,5 ---- *************** *** 13,17 **** { /// <summary> ! /// Summary description for Example. /// </summary> public class Example : AbstractCriterion --- 11,15 ---- { /// <summary> ! /// Support for <c>Query By Example</c>. /// </summary> public class Example : AbstractCriterion *************** *** 22,45 **** private bool _isLikeEnabled; private MatchMode _matchMode; ! /// <summary> /// A strategy for choosing property values for inclusion in the query criteria /// </summary> ! public interface IPropertySelector { /// <summary> ! /// /// </summary> ! /// <param name="propertyValue"></param> ! /// <param name="propertyName"></param> ! /// <param name="type"></param> ! /// <returns></returns> bool Include(object propertyValue, String propertyName, IType type); } ! private static readonly IPropertySelector NotNullOrEmptyString = new NotNullOrEmptyStringPropertySelector(); private static readonly IPropertySelector All = new AllPropertySelector(); private static readonly IPropertySelector NotNullOrZero = new NotNullOrZeroPropertySelector(); ! private class AllPropertySelector : IPropertySelector { --- 20,50 ---- private bool _isLikeEnabled; private MatchMode _matchMode; ! /// <summary> /// A strategy for choosing property values for inclusion in the query criteria /// </summary> ! public interface IPropertySelector { /// <summary> ! /// Determine if the Property should be included. /// </summary> ! /// <param name="propertyValue">The value of the property that is being checked for inclusion.</param> ! /// <param name="propertyName">The name of the property that is being checked for inclusion.</param> ! /// <param name="type">The <see cref="IType"/> of the property.</param> ! /// <returns> ! /// <c>true</c> if the Property should be included in the Query, ! /// <c>false</c> otherwise. ! /// </returns> bool Include(object propertyValue, String propertyName, IType type); } ! private static readonly IPropertySelector NotNullOrEmptyString = new NotNullOrEmptyStringPropertySelector(); private static readonly IPropertySelector All = new AllPropertySelector(); private static readonly IPropertySelector NotNullOrZero = new NotNullOrZeroPropertySelector(); ! ! /// <summary> ! /// Implementation of <see cref="IPropertySelector"/> that includes all ! /// properties regardless of value. ! /// </summary> private class AllPropertySelector : IPropertySelector { *************** *** 49,67 **** } } ! internal class NotNullOrEmptyStringPropertySelector : IPropertySelector { - public bool Include(object propertyValue, String propertyName, IType type) { ! if(propertyValue != null) { ! if(propertyValue.ToString() != "") ! return true; ! else ! return false; } else return false; } --- 54,79 ---- } } ! ! /// <summary> ! /// Implementation of <see cref="IPropertySelector"/> that includes the ! /// properties that are not <c>null</c> and do not have an <see cref="String.Empty"/> ! /// returned by <c>propertyValue.ToString()</c>. ! /// </summary> internal class NotNullOrEmptyStringPropertySelector : IPropertySelector { public bool Include(object propertyValue, String propertyName, IType type) { ! if( propertyValue != null ) { ! // TODO: find out why we are checking ToString() - why is null ! // and not null not good enough??? ! // used to be propertyValue.ToString()!="" but that creates an ! // extra string in memory ! return ( propertyValue.ToString().Length > 0 ); } else + { return false; + } } *************** *** 69,129 **** } - /// <summary> /// This Can't work right now. Have to figure out some way to use Magic values /// to avoid the non-nullable types in .NET. /// </summary> ! internal class NotNullOrZeroPropertySelector : IPropertySelector { ! public bool Include(object propertyValue, String propertyName, IType type) ! { ! return propertyValue!=null ;/*&& (!char.IsNumber(propertyValue as char) || ( (int) propertyValue !=0));*/ } } ! /// <summary> ! /// Set the property selector /// </summary> ! public Example SetPropertySelector(IPropertySelector selector) { ! this._selector = selector; return this; } ! ! /// <summary> ! /// Exclude zero-valued properties /// </summary> ! public Example ExcludeNulls() { ! SetPropertySelector(NotNullOrEmptyString); return this; } ! /// <summary> ! /// Don't exclude null or zero-valued properties /// </summary> ! public Example ExcludeNone() { ! SetPropertySelector(All); return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties /// </summary> ! public Example EnableLike(MatchMode matchMode) { _isLikeEnabled = true; ! this._matchMode = matchMode; return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties /// </summary> ! public Example EnableLike() { ! return EnableLike(MatchMode.Exact); } --- 81,157 ---- } /// <summary> /// This Can't work right now. Have to figure out some way to use Magic values /// to avoid the non-nullable types in .NET. /// </summary> ! internal class NotNullOrZeroPropertySelector : IPropertySelector { ! public bool Include(object propertyValue, String propertyName, IType type) ! { ! return propertyValue != null; /*&& (!char.IsNumber(propertyValue as char) || ( (int) propertyValue !=0));*/ } } ! /// <summary> ! /// Set the <see cref="IPropertySelector"/> for this <see cref="Example"/>. /// </summary> ! /// <param name="selector">The <see cref="IPropertySelector"/> to determine which properties to include.</param> ! /// <returns>This <see cref="Example"/> instance.</returns> ! /// <remarks> ! /// This should be used when a custom <see cref="IPropertySelector"/> has ! /// been implemented. Otherwise use the methods <see cref="Example.ExcludeNulls"/> ! /// or <see cref="Example.ExcludeNone"/> to set the <see cref="IPropertySelector"/> ! /// to the <see cref="IPropertySelector"/>s built into NHibernate. ! /// </remarks> ! public Example SetPropertySelector(IPropertySelector selector) { ! _selector = selector; return this; } ! /// <summary> ! /// Set the <see cref="IPropertySelector"/> for this <see cref="Example"/> ! /// to exclude zero-valued properties. /// </summary> ! public Example ExcludeNulls() { ! SetPropertySelector( NotNullOrEmptyString ); return this; } ! /// <summary> ! /// Set the <see cref="IPropertySelector"/> for this <see cref="Example"/> ! /// to exclude no properties. /// </summary> ! public Example ExcludeNone() { ! SetPropertySelector( All ); return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties with ! /// the specified <see cref="MatchMode"/>. /// </summary> ! /// <param name="matchMode"> ! /// The <see cref="MatchMode"/> to convert the string to the pattern ! /// for the <c>like</c> comparison. ! /// </param> ! public Example EnableLike(MatchMode matchMode) { _isLikeEnabled = true; ! _matchMode = matchMode; return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties. /// </summary> ! /// <remarks> ! /// The default <see cref="MatchMode"/> is <see cref="MatchMode.Exact">MatchMode.Exact</see>. ! /// </remarks> ! public Example EnableLike() { ! return EnableLike( MatchMode.Exact ); } *************** *** 131,137 **** /// Exclude a particular named property /// </summary> ! public Example ExcludeProperty(String name) { ! _excludedProperties.Add(name); return this; } --- 159,166 ---- /// Exclude a particular named property /// </summary> ! /// <param name="name">The name of the property to exclude.</param> ! public Example ExcludeProperty(String name) { ! _excludedProperties.Add( name ); return this; } *************** *** 142,158 **** /// </summary> /// <param name="entity"></param> ! /// <returns>a new instance of <code>Example</code></returns> ! public static Example Create(object entity) { ! if (entity==null) throw new ArgumentException("null example"); ! return new Example(entity, NotNullOrEmptyString); } /// <summary> ! /// /// </summary> ! /// <param name="entity"></param> ! /// <param name="selector"></param> ! protected Example(object entity, IPropertySelector selector) { _entity = entity; --- 171,191 ---- /// </summary> /// <param name="entity"></param> ! /// <returns>A new instance of <see cref="Example" />.</returns> ! public static Example Create(object entity) { ! if( entity == null ) ! { ! throw new ArgumentException( "null example" ); ! } ! return new Example( entity, NotNullOrEmptyString ); } /// <summary> ! /// Initialize a new instance of the <see cref="Example" /> class for a particular ! /// entity. /// </summary> ! /// <param name="entity">The <see cref="Object"/> that the Example is being built from.</param> ! /// <param name="selector">The <see cref="IPropertySelector"/> the Example should use.</param> ! protected Example(object entity, IPropertySelector selector) { _entity = entity; *************** *** 160,177 **** } ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public override String ToString() { return _entity.ToString(); } ! ! private bool IsPropertyIncluded(object value, String name, IType type) { ! return !_excludedProperties.Contains(name) && !type.IsAssociationType && ! _selector.Include(value, name, type); } --- 193,221 ---- } ! #region System.Object Members ! ! public override String ToString() { return _entity.ToString(); } ! ! #endregion ! ! ! /// <summary> ! /// Determines if the property should be included in the Query. ! /// </summary> ! /// <param name="value">The value of the property.</param> ! /// <param name="name">The name of the property.</param> ! /// <param name="type">The <see cref="IType"/> of the property.</param> ! /// <returns> ! /// <c>true</c> if the Property should be included, <c>false</c> if ! /// the Property should not be a part of the Query. ! /// </returns> ! private bool IsPropertyIncluded(object value, String name, IType type) { ! return !_excludedProperties.Contains( name ) && !type.IsAssociationType && ! _selector.Include( value, name, type ); } *************** *** 190,194 **** ArrayList list = new ArrayList(); ! for( int i=0; i<propertyNames.Length; i++) { object value = values[ i ]; --- 234,238 ---- ArrayList list = new ArrayList(); ! for( int i = 0; i < propertyNames.Length; i++ ) { object value = values[ i ]; *************** *** 196,200 **** string name = propertyNames[ i ]; ! bool isPropertyIncluded = ( i!=meta.VersionProperty && IsPropertyIncluded( value, name, type ) ); if( isPropertyIncluded ) --- 240,244 ---- string name = propertyNames[ i ]; ! bool isPropertyIncluded = ( i != meta.VersionProperty && IsPropertyIncluded( value, name, type ) ); if( isPropertyIncluded ) *************** *** 202,206 **** if( propertyTypes[ i ].IsComponentType ) { ! AddComponentTypedValues( name, value, (IAbstractComponentType)type, list ); } else --- 246,250 ---- if( propertyTypes[ i ].IsComponentType ) { ! AddComponentTypedValues( name, value, (IAbstractComponentType)type, list ); } else *************** *** 211,215 **** } ! return ( TypedValue[ ] ) list.ToArray( typeof( TypedValue ) ); } --- 255,259 ---- } ! return (TypedValue[])list.ToArray( typeof( TypedValue ) ); } *************** *** 226,249 **** builder.Add( StringHelper.OpenParen ); ! IClassMetadata meta = factory.GetClassMetadata(persistentClass); String[] propertyNames = meta.PropertyNames; IType[] propertyTypes = meta.PropertyTypes; ! object[] propertyValues = meta.GetPropertyValues(_entity); ! for (int i=0; i<propertyNames.Length; i++) { ! object propertyValue = propertyValues[i]; ! String propertyName = propertyNames[i]; ! // Have to figure out how to get the name or index of the version property ! bool isPropertyIncluded = i!=meta.VersionProperty && ! IsPropertyIncluded( propertyValue, propertyName, propertyTypes[i] ); ! if (isPropertyIncluded) { ! if ( propertyTypes[i].IsComponentType) { AppendComponentCondition( ! propertyName, ! propertyValue, ! (IAbstractComponentType) propertyTypes[i], persistentClass, alias, --- 270,293 ---- builder.Add( StringHelper.OpenParen ); ! IClassMetadata meta = factory.GetClassMetadata( persistentClass ); String[] propertyNames = meta.PropertyNames; IType[] propertyTypes = meta.PropertyTypes; ! object[] propertyValues = meta.GetPropertyValues( _entity ); ! for( int i = 0; i < propertyNames.Length; i++ ) { ! object propertyValue = propertyValues[ i ]; ! String propertyName = propertyNames[ i ]; ! // Have to figure out how to get the name or index of the version property ! bool isPropertyIncluded = i != meta.VersionProperty && ! IsPropertyIncluded( propertyValue, propertyName, propertyTypes[ i ] ); ! if( isPropertyIncluded ) { ! if( propertyTypes[ i ].IsComponentType ) { AppendComponentCondition( ! propertyName, ! propertyValue, ! (IAbstractComponentType)propertyTypes[ i ], persistentClass, alias, *************** *** 253,261 **** ); } ! else { AppendPropertyCondition( ! propertyName, ! propertyValue, persistentClass, alias, --- 297,305 ---- ); } ! else { AppendPropertyCondition( ! propertyName, ! propertyValue, persistentClass, alias, *************** *** 267,271 **** } } ! if( builder.Count==1 ) { builder.Add( "1=1" ); // yuck! --- 311,315 ---- } } ! if( builder.Count == 1 ) { builder.Add( "1=1" ); // yuck! *************** *** 275,279 **** return builder.ToSqlString(); } ! /// <summary> /// Adds a <see cref="TypedValue"/> based on the <c>value</c> --- 319,323 ---- return builder.ToSqlString(); } ! /// <summary> /// Adds a <see cref="TypedValue"/> based on the <c>value</c> *************** *** 284,287 **** --- 328,334 ---- /// <param name="type">The <see cref="IType"/> of the Property.</param> /// <param name="list">The <see cref="IList"/> to add the <see cref="TypedValue"/> to.</param> + /// <remarks> + /// This method will add <see cref="TypedValue"/> objects to the <c>list</c> parameter. + /// </remarks> protected void AddPropertyTypedValue(object value, IType type, IList list) { *************** *** 289,303 **** // or an ICollection that can be added to the list instead of modifying the // parameter passed in. ! if( value!=null ) { ! // TODO: h2.1 SYNCH: some code in here to check for ! // IsIgnoreCaseEnabled and IsLikeEnabled ! // string stringValue = value as string; ! // if( stringValue!=null ) ! // { ! // // ! // // ! // } ! list.Add( new TypedValue( type, value ) ); } --- 336,351 ---- // or an ICollection that can be added to the list instead of modifying the // parameter passed in. ! if( value != null ) { ! if( value is string ) ! { ! string stringValue = (string)value; ! // TODO: h2.1 SYNCH: some code in here to check for _isIgnoreCaseEnabled ! if( _isLikeEnabled ) ! { ! stringValue = _matchMode.ToMatchString( stringValue ); ! } ! value = stringValue; ! } list.Add( new TypedValue( type, value ) ); } *************** *** 306,320 **** protected void AddComponentTypedValues(string path, object component, IAbstractComponentType type, IList list) { ! //TODO: h2.1 SYNCH: resume here once IAbstractComponentType is fixed up. ! if( component!=null ) { string[] propertyNames = type.PropertyNames; IType[] subtypes = type.Subtypes; object[] values = type.GetPropertyValues( component ); ! for( int i=0; i<propertyNames.Length; i++ ) { ! object value = values[i]; ! IType subtype = subtypes[i]; ! string subpath = StringHelper.Qualify( path, propertyNames[i] ); if( IsPropertyIncluded( value, subpath, subtype ) ) { --- 354,367 ---- protected void AddComponentTypedValues(string path, object component, IAbstractComponentType type, IList list) { ! if( component != null ) { string[] propertyNames = type.PropertyNames; IType[] subtypes = type.Subtypes; object[] values = type.GetPropertyValues( component ); ! for( int i = 0; i < propertyNames.Length; i++ ) { ! object value = values[ i ]; ! IType subtype = subtypes[ i ]; ! string subpath = StringHelper.Qualify( path, propertyNames[ i ] ); if( IsPropertyIncluded( value, subpath, subtype ) ) { *************** *** 332,335 **** --- 379,383 ---- } } + /// <summary> /// *************** *** 341,353 **** /// <param name="sessionFactory"></param> protected void AppendPropertyCondition( ! String propertyName, ! object propertyValue, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! if( builder.Count>1 ) { builder.Add( " and " ); --- 389,401 ---- /// <param name="sessionFactory"></param> protected void AppendPropertyCondition( ! String propertyName, ! object propertyValue, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! if( builder.Count > 1 ) { builder.Add( " and " ); *************** *** 355,373 **** ICriterion crit; ! if ( propertyValue!=null ) { bool isString = propertyValue is String; crit = ( _isLikeEnabled && isString ) ? ! (ICriterion) new LikeExpression( propertyName, propertyValue) : ! (ICriterion) new EqExpression( propertyName, propertyValue ); ! } ! else { ! crit = new NullExpression(propertyName); } builder.Add( crit.ToSqlString( sessionFactory, persistentClass, alias, aliasClasses ) ); } ! /// <summary> /// --- 403,421 ---- ICriterion crit; ! if( propertyValue != null ) { bool isString = propertyValue is String; crit = ( _isLikeEnabled && isString ) ? ! (ICriterion)new LikeExpression( propertyName, propertyValue ) : ! (ICriterion)new EqExpression( propertyName, propertyValue ); ! } ! else { ! crit = new NullExpression( propertyName ); } builder.Add( crit.ToSqlString( sessionFactory, persistentClass, alias, aliasClasses ) ); } ! /// <summary> /// *************** *** 380,411 **** /// <param name="sessionFactory"></param> protected void AppendComponentCondition( ! String path, ! object component, ! IAbstractComponentType type, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! ! if (component!=null) { String[] propertyNames = type.PropertyNames; ! object[] values = type.GetPropertyValues(component, null); IType[] subtypes = type.Subtypes; ! for (int i=0; i<propertyNames.Length; i++) { ! String subpath = StringHelper.Qualify( path, propertyNames[i] ); ! object value = values[i]; ! if ( IsPropertyIncluded( value, subpath, subtypes[i] ) ) { ! IType subtype = subtypes[i]; ! if ( subtype.IsComponentType ) { AppendComponentCondition( subpath, value, ! (IAbstractComponentType) subtype, persistentClass, alias, --- 428,458 ---- /// <param name="sessionFactory"></param> protected void AppendComponentCondition( ! String path, ! object component, ! IAbstractComponentType type, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! if( component != null ) { String[] propertyNames = type.PropertyNames; ! object[] values = type.GetPropertyValues( component, null ); IType[] subtypes = type.Subtypes; ! for( int i = 0; i < propertyNames.Length; i++ ) { ! String subpath = StringHelper.Qualify( path, propertyNames[ i ] ); ! object value = values[ i ]; ! if( IsPropertyIncluded( value, subpath, subtypes[ i ] ) ) { ! IType subtype = subtypes[ i ]; ! if( subtype.IsComponentType ) { AppendComponentCondition( subpath, value, ! (IAbstractComponentType)subtype, persistentClass, alias, *************** *** 413,425 **** sessionFactory, builder ); ! } ! else { ! AppendPropertyCondition( subpath, ! value, persistentClass, alias, ! aliasClasses, sessionFactory, builder --- 460,472 ---- sessionFactory, builder ); ! } ! else { ! AppendPropertyCondition( subpath, ! value, persistentClass, alias, ! aliasClasses, sessionFactory, builder *************** *** 431,433 **** } } ! } --- 478,480 ---- } } ! } \ No newline at end of file Index: LtPropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtPropertyExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LtPropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 --- LtPropertyExpression.cs 18 Apr 2005 02:55:29 -0000 1.4 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { Index: InExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/InExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** InExpression.cs 17 Apr 2005 17:16:05 -0000 1.6 --- InExpression.cs 18 Apr 2005 02:55:29 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using NHibernate.Engine; Index: MatchMode.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/MatchMode.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchMode.cs 17 Apr 2005 17:16:05 -0000 1.2 --- MatchMode.cs 18 Apr 2005 02:55:29 -0000 1.3 *************** *** 4,8 **** namespace NHibernate.Expression { - // TODO: find where this is used and test/fix it up /// <summary> /// Represents an strategy for matching strings using "like". --- 4,7 ---- *************** *** 14,32 **** private static Hashtable Instances = new Hashtable(); /// <summary> ! /// /// </summary> ! /// <param name="intCode"></param> ! /// <param name="name"></param> protected MatchMode(int intCode, string name) { ! this._intCode = intCode; ! this._name = name; } /// <summary> ! /// /// </summary> ! /// <returns></returns> public override string ToString() { --- 13,46 ---- private static Hashtable Instances = new Hashtable(); + static MatchMode() + { + Instances.Add( MatchMode.Exact._intCode, MatchMode.Exact ); + Instances.Add( MatchMode.Start._intCode, MatchMode.Start ); + Instances.Add( MatchMode.End._intCode, MatchMode.End ); + Instances.Add( MatchMode.Anywhere._intCode, MatchMode.Anywhere ); + } + /// <summary> ! /// Initialize a new instance of the <see cref="MatchMode" /> class. /// </summary> ! /// <param name="intCode">The code that identifies the match mode.</param> ! /// <param name="name">The friendly name of the match mode.</param> ! /// <remarks> ! /// The parameter <c>intCode</c> is used as the key of <see cref="IDictionary"/> ! /// to store instances and to ensure only instance of a particular <see cref="MatchMode"/> ! /// is created. ! /// </remarks> protected MatchMode(int intCode, string name) { ! _intCode = intCode; ! _name = name; } + #region System.Object Members + /// <summary> ! /// The string representation of the <see cref="MatchMode"/>. /// </summary> ! /// <returns>The friendly name used to describe the <see cref="MatchMode"/>.</returns> public override string ToString() { *************** *** 34,40 **** } /// <summary> ! /// convert the pattern, by appending/prepending "%" /// </summary> public abstract string ToMatchString(string pattern); --- 48,61 ---- } + #endregion + /// <summary> ! /// Convert the pattern, by appending/prepending "%" /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns> + /// A <see cref="String"/> that contains a "%" in the appropriate place + /// for the Match Strategy. + /// </returns> public abstract string ToMatchString(string pattern); *************** *** 46,57 **** // } - static MatchMode() - { - Instances.Add( Exact._intCode, Exact ); - Instances.Add( Start._intCode, Start ); - Instances.Add( End._intCode, End ); - Instances.Add( Anywhere._intCode, Anywhere ); - } - /// <summary> /// Match the entire string to the pattern --- 67,70 ---- *************** *** 74,83 **** --- 87,108 ---- public static readonly MatchMode Anywhere = new AnywhereMatchMode(); + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the entire + /// string to the pattern. + /// </summary> private class ExactMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="ExactMatchMode" /> class. + /// </summary> public ExactMatchMode() : base( 0, "EXACT" ) { } + /// <summary> + /// Converts the string to the Exact MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> exactly the same as it was passed in.</returns> public override string ToMatchString(string pattern) { *************** *** 86,95 **** --- 111,132 ---- } + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the string + /// by appending "<c>%</c>" to the beginning. + /// </summary> private class StartMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="StartMatchMode" /> class. + /// </summary> public StartMatchMode() : base( 1, "START" ) { } + /// <summary> + /// Converts the string to the Start MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> with a "<c>%</c>" appended at the beginning.</returns> public override string ToMatchString(string pattern) { *************** *** 98,107 **** --- 135,156 ---- } + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the string + /// by appending "<c>%</c>" to the end. + /// </summary> private class EndMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="EndMatchMode" /> class. + /// </summary> public EndMatchMode() : base( 2, "END" ) { } + /// <summary> + /// Converts the string to the End MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> with a "<c>%</c>" appended at the end.</returns> public override string ToMatchString(string pattern) { *************** *** 111,120 **** --- 160,181 ---- } + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the string + /// by appending "<c>%</c>" to the beginning and end. + /// </summary> private class AnywhereMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="AnywhereMatchMode" /> class. + /// </summary> public AnywhereMatchMode() : base( 3, "ANYWHERE" ) { } + /// <summary> + /// Converts the string to the Exact MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> with a "<c>%</c>" appended at the beginning and the end.</returns> public override string ToMatchString(string pattern) { Index: LePropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LePropertyExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LePropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 --- LePropertyExpression.cs 18 Apr 2005 02:55:29 -0000 1.4 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { Index: LtExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LtExpression.cs 17 Apr 2005 17:16:05 -0000 1.4 --- LtExpression.cs 18 Apr 2005 02:55:29 -0000 1.5 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { Index: LeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LeExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 --- LeExpression.cs 18 Apr 2005 02:55:29 -0000 1.6 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { |
From: Michael D. <mik...@us...> - 2005-04-18 02:55:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18776/NHibernate.Test/ExpressionTest Modified Files: QueryByExampleTest.cs Log Message: Finished up the QBE Tests. Index: QueryByExampleTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** QueryByExampleTest.cs 17 Apr 2005 17:16:05 -0000 1.4 --- QueryByExampleTest.cs 18 Apr 2005 02:55:29 -0000 1.5 *************** *** 8,17 **** namespace NHibernate.Test.ExpressionTest { - /// <summary> - /// Summary description for QueryByExampleTest. - /// </summary> [TestFixture] public class QueryByExampleTest : TestCase { [SetUp] public void SetUp() --- 8,15 ---- namespace NHibernate.Test.ExpressionTest { [TestFixture] public class QueryByExampleTest : TestCase { + #region NUnit.Framework.TestFixture Members [SetUp] public void SetUp() *************** *** 21,25 **** --- 19,31 ---- } + [TearDown] + public override void TearDown() + { + DeleteData(); + base.TearDown(); + } + #endregion + [Test] public void TestSimpleQBE() *************** *** 40,44 **** [Test] - //[Ignore("Test Fails with Exception - do to with Criteria expression/parameter handling")] public void TestJunctionNotExpressionQBE() { --- 46,49 ---- *************** *** 55,61 **** IList result = crit.List(); Assert.IsNotNull(result); ! // if (!(GetDialect() ! // instanceof HSQLDialect) ) ! // assertEquals(2, result.size()); t.Commit(); } --- 60,66 ---- IList result = crit.List(); Assert.IsNotNull(result); ! //if ( !(dialect is HSQLDialect - h2.1 test ! ! Assert.AreEqual( 2, result.Count, "expected 2 objects" ); t.Commit(); } |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate Modified Files: ICriteria.cs NHibernate-1.1.csproj NHibernate.build Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** NHibernate-1.1.csproj 8 Apr 2005 04:27:27 -0000 1.80 --- NHibernate-1.1.csproj 17 Apr 2005 17:16:04 -0000 1.81 *************** *** 35,39 **** IncrementalBuild = "true" NoStdLib = "false" ! NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" --- 35,39 ---- IncrementalBuild = "true" NoStdLib = "false" ! NoWarn = "1573;1591" Optimize = "false" OutputPath = "bin\Debug\" Index: ICriteria.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/ICriteria.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ICriteria.cs 14 Mar 2005 18:54:43 -0000 1.8 --- ICriteria.cs 17 Apr 2005 17:16:04 -0000 1.9 *************** *** 60,64 **** /// <param name="expression"></param> /// <returns></returns> ! ICriteria Add( Expression.Expression expression ); /// <summary> --- 60,64 ---- /// <param name="expression"></param> /// <returns></returns> ! ICriteria Add( Expression.ICriterion expression ); /// <summary> *************** *** 79,83 **** /// resulting expression. /// </summary> ! Expression.Expression Expression { get; } /// <summary> --- 79,83 ---- /// resulting expression. /// </summary> ! Expression.ICriterion Expression { get; } /// <summary> Index: NHibernate.build =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate.build,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NHibernate.build 23 Jan 2005 16:26:10 -0000 1.9 --- NHibernate.build 17 Apr 2005 17:16:04 -0000 1.10 *************** *** 70,74 **** --- 70,93 ---- output="${build.dir}/bin/${nant.project.name}.dll" doc="${build.dir}/bin/${nant.project.name}.xml" + nowarn="1573,1591" > + <!-- + Documentation related warnings. Basically it's not going to output a warning when there + is no attempt at documentation. If the code has documentation but there is a problem with + it then lets warn the developer during the build. + + CS1571: XML comment on 'construct' has a duplicate param tag for 'parameter' + CS1572: XML comment on 'construct' has a param tag for 'parameter', but there is no parameter by that name + CS1573: Parameter 'parameter' has no matching param tag in XML comment (but other parameters do) + CS1574: XML comment on 'construct' has cref attribute 'item' that could not be found + CS1580: Invalid type for parameter 'parameter number' in XML comment cref attribute + CS1581: Invalid return type in XML comment cref attribute + CS1584: XML comment on 'member' has syntactically incorrect cref attribute 'invalid_syntax' + CS1587: XML comment is not placed on a valid language element + CS1589: Unable to include XML fragment 'fragment' of file 'file' -- reason + CS1590: Invalid XML include element -- Missing file attribute + CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' + CS1592: Badly formed XML in included comments file -- 'reason' + --> <sources failonempty="true"> |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Expression Modified Files: AbstractCriterion.cs AndExpression.cs BetweenExpression.cs Conjunction.cs Disjunction.cs EqExpression.cs EqPropertyExpression.cs Example.cs Expression.cs GeExpression.cs GtExpression.cs ICriterion.cs InExpression.cs InsensitiveLikeExpression.cs Junction.cs LeExpression.cs LePropertyExpression.cs LikeExpression.cs LogicalExpression.cs LtExpression.cs LtPropertyExpression.cs MatchMode.cs NotExpression.cs NotNullExpression.cs NullExpression.cs Order.cs OrExpression.cs PropertyExpression.cs SimpleExpression.cs SQLExpression.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: InsensitiveLikeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/InsensitiveLikeExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InsensitiveLikeExpression.cs 31 Dec 2004 17:54:19 -0000 1.4 --- InsensitiveLikeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Dialect; using NHibernate.Engine; *************** *** 8,29 **** { /// <summary> ! /// Summary description for InsensitiveLikeExpression. ! /// /// </summary> //TODO:H2.0.3 renamed this to ILikeExpression ! public class InsensitiveLikeExpression : Expression { ! private readonly string propertyName; ! private readonly object expressionValue; /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="expressionValue"></param> ! internal InsensitiveLikeExpression( string propertyName, object expressionValue ) { ! this.propertyName = propertyName; ! this.expressionValue = expressionValue; } --- 9,31 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents an "like" constraint ! /// that is <b>not</b> case sensitive. /// </summary> //TODO:H2.0.3 renamed this to ILikeExpression ! public class InsensitiveLikeExpression : AbstractCriterion { ! private readonly string _propertyName; ! private readonly object _value; /// <summary> ! /// Initialize a new instance of the <see cref="InsensitiveLikeExpression" /> ! /// class for a named Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> ! internal InsensitiveLikeExpression( string propertyName, object value ) { ! _propertyName = propertyName; ! _value = value; } *************** *** 35,46 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); --- 37,49 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( _propertyName ); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); ! // don't need to worry about aliasing or aliasClassing for parameter column names ! string[ ] paramColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); *************** *** 71,77 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return new TypedValue[ ] {Expression.GetTypedValue( sessionFactory, persistentClass, propertyName, expressionValue.ToString().ToLower() )}; } --- 74,80 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return new TypedValue[ ] { AbstractCriterion.GetTypedValue( sessionFactory, persistentClass, _propertyName, _value.ToString().ToLower(), aliasClasses )}; } *************** *** 79,83 **** public override string ToString() { ! return propertyName + " ilike " + expressionValue; } } --- 82,86 ---- public override string ToString() { ! return _propertyName + " ilike " + _value; } } Index: NotNullExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/NotNullExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NotNullExpression.cs 31 Dec 2004 17:55:35 -0000 1.6 --- NotNullExpression.cs 17 Apr 2005 17:16:05 -0000 1.7 *************** *** 1,25 **** using NHibernate.Engine; - using NHibernate.Persister; using NHibernate.SqlCommand; - using NHibernate.Type; namespace NHibernate.Expression { /// <summary> ! /// Constrains a property to be non-null /// </summary> ! public class NotNullExpression : Expression { ! private readonly string propertyName; private static readonly TypedValue[ ] NoValues = new TypedValue[0]; /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> internal NotNullExpression( string propertyName ) { ! this.propertyName = propertyName; } --- 1,26 ---- + using System; + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; namespace NHibernate.Expression { /// <summary> ! /// An <see cref="ICriterion"/> that represents "not null" constraint. /// </summary> ! public class NotNullExpression : AbstractCriterion { ! private readonly string _propertyName; private static readonly TypedValue[ ] NoValues = new TypedValue[0]; /// <summary> ! /// Initialize a new instance of the <see cref="NotNullExpression" /> class for a named ! /// Property that should not be null. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> internal NotNullExpression( string propertyName ) { ! _propertyName = propertyName; } *************** *** 31,41 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); --- 32,41 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); *************** *** 46,49 **** --- 46,50 ---- if( andNeeded ) { + // TODO: h2.1 SYNCH - why did hibernate change this to " or " sqlBuilder.Add( " AND " ); } *************** *** 64,68 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return NoValues; --- 65,69 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { return NoValues; *************** *** 72,76 **** public override string ToString() { ! return propertyName + " is not null"; } } --- 73,77 ---- public override string ToString() { ! return _propertyName + " is not null"; } } Index: SimpleExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SimpleExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SimpleExpression.cs 31 Dec 2004 17:55:48 -0000 1.6 --- SimpleExpression.cs 17 Apr 2005 17:16:05 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.Persister; *************** *** 7,29 **** { /// <summary> ! /// The base class for an Expression that compares a single Property /// to a value. /// </summary> ! public abstract class SimpleExpression : Expression { ! private readonly string propertyName; ! private readonly object expressionValue; /// <summary> ! /// Initialize a new instance of the SimpleExpression class for a named /// Property and its value. /// </summary> /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="expressionValue">The value for the Property.</param> ! internal SimpleExpression( string propertyName, object expressionValue ) { ! this.propertyName = propertyName; ! this.expressionValue = expressionValue; } --- 8,30 ---- { /// <summary> ! /// The base class for an <see cref="ICriterion"/> that compares a single Property /// to a value. /// </summary> ! public abstract class SimpleExpression : AbstractCriterion { ! private readonly string _propertyName; ! private readonly object _value; /// <summary> ! /// Initialize a new instance of the <see cref="SimpleExpression" /> class for a named /// Property and its value. /// </summary> /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> ! internal SimpleExpression( string propertyName, object value ) { ! _propertyName = propertyName; ! _value = value; } *************** *** 34,38 **** public string PropertyName { ! get { return propertyName; } } --- 35,39 ---- public string PropertyName { ! get { return _propertyName; } } *************** *** 43,47 **** public object Value { ! get { return expressionValue; } } --- 44,48 ---- public object Value { ! get { return _value; } } *************** *** 53,64 **** /// <param name="alias">The alias to use for the table.</param> /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); --- 54,66 ---- /// <param name="alias">The alias to use for the table.</param> /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( _propertyName ); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); ! // don't need to worry about aliasing or aliasClassing for parameter column names ! string[ ] paramColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName ); Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); *************** *** 86,92 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return new TypedValue[ ] {GetTypedValue( sessionFactory, persistentClass, propertyName, expressionValue )}; } --- 88,94 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return new TypedValue[ ] {AbstractCriterion.GetTypedValue( sessionFactory, persistentClass, _propertyName, _value, aliasClasses )}; } *************** *** 94,102 **** public override string ToString() { ! return propertyName + Op + expressionValue; } ! /// <summary></summary> ! protected abstract string Op { get; } //protected ??? } } \ No newline at end of file --- 96,107 ---- public override string ToString() { ! return _propertyName + Op + _value; } ! /// <summary> ! /// Get the Sql operator to use for the specific ! /// subclass of <see cref="SimpleExpression"/>. ! /// </summary> ! protected abstract string Op { get; } } } \ No newline at end of file Index: MatchMode.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/MatchMode.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MatchMode.cs 28 Mar 2005 12:45:58 -0000 1.1 --- MatchMode.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- namespace NHibernate.Expression { + // TODO: find where this is used and test/fix it up /// <summary> /// Represents an strategy for matching strings using "like". *************** *** 9,15 **** public abstract class MatchMode { ! private int intCode; ! private string name; ! private static Hashtable INSTANCES = new Hashtable(); /// <summary> --- 10,16 ---- public abstract class MatchMode { ! private int _intCode; ! private string _name; ! private static Hashtable Instances = new Hashtable(); /// <summary> *************** *** 20,25 **** protected MatchMode(int intCode, string name) { ! this.intCode = intCode; ! this.name = name; } --- 21,26 ---- protected MatchMode(int intCode, string name) { ! this._intCode = intCode; ! this._name = name; } *************** *** 30,34 **** public override string ToString() { ! return name; } --- 31,35 ---- public override string ToString() { ! return _name; } *************** *** 38,52 **** public abstract string ToMatchString(string pattern); ! private Object ReadResolve() ! { ! return INSTANCES[intCode]; ! } static MatchMode() { ! INSTANCES.Add(EXACT.intCode, EXACT); ! INSTANCES.Add(START.intCode, START); ! INSTANCES.Add(END.intCode, END); ! INSTANCES.Add(ANYWHERE.intCode, ANYWHERE); } --- 39,55 ---- public abstract string ToMatchString(string pattern); ! // TODO: need to fix up so serialization/deserialization ! // preserves the singleton ! // private Object ReadResolve() ! // { ! // return INSTANCES[intCode]; ! // } static MatchMode() { ! Instances.Add( Exact._intCode, Exact ); ! Instances.Add( Start._intCode, Start ); ! Instances.Add( End._intCode, End ); ! Instances.Add( Anywhere._intCode, Anywhere ); } *************** *** 54,76 **** /// Match the entire string to the pattern /// </summary> ! public static readonly MatchMode EXACT = new ExactMatchMode(); /// <summary> /// Match the start of the string to the pattern /// </summary> ! public static readonly MatchMode START = new StartMatchMode(); /// <summary> /// Match the end of the string to the pattern /// </summary> ! public static readonly MatchMode END = new EndMatchMode(); /// <summary> /// Match the pattern anywhere in the string /// </summary> ! public static readonly MatchMode ANYWHERE = new AnywhereMatchMode(); private class ExactMatchMode : MatchMode { ! public ExactMatchMode():base(0, "EXACT") { - } --- 57,81 ---- /// Match the entire string to the pattern /// </summary> ! public static readonly MatchMode Exact = new ExactMatchMode(); ! /// <summary> /// Match the start of the string to the pattern /// </summary> ! public static readonly MatchMode Start = new StartMatchMode(); ! /// <summary> /// Match the end of the string to the pattern /// </summary> ! public static readonly MatchMode End = new EndMatchMode(); ! /// <summary> /// Match the pattern anywhere in the string /// </summary> ! public static readonly MatchMode Anywhere = new AnywhereMatchMode(); private class ExactMatchMode : MatchMode { ! public ExactMatchMode() : base( 0, "EXACT" ) { } *************** *** 83,90 **** private class StartMatchMode : MatchMode { ! public StartMatchMode() : base(1, "START") { ! ! } public override string ToMatchString(string pattern) --- 88,94 ---- private class StartMatchMode : MatchMode { ! public StartMatchMode() : base( 1, "START" ) { ! } public override string ToMatchString(string pattern) *************** *** 96,100 **** private class EndMatchMode : MatchMode { ! public EndMatchMode() : base(2, "END") { } --- 100,104 ---- private class EndMatchMode : MatchMode { ! public EndMatchMode() : base( 2, "END" ) { } *************** *** 109,114 **** private class AnywhereMatchMode : MatchMode { ! public AnywhereMatchMode() : base(3, "ANYWHERE") ! { } --- 113,118 ---- private class AnywhereMatchMode : MatchMode { ! public AnywhereMatchMode() : base( 3, "ANYWHERE" ) ! { } *************** *** 121,123 **** } ! } --- 125,127 ---- } ! } \ No newline at end of file Index: PropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/PropertyExpression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PropertyExpression.cs 31 Dec 2004 17:55:48 -0000 1.2 --- PropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 5,26 **** { /// <summary> ! /// Superclass for comparisons between two properties (with SQL binary operators) /// </summary> ! public abstract class PropertyExpression : Expression { ! private string propertyName; ! private string otherPropertyName; private static TypedValue[ ] NoTypedValues = new TypedValue[0]; /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! protected PropertyExpression( string propertyName, string otherPropertyName ) { ! this.propertyName = propertyName; ! this.otherPropertyName = otherPropertyName; } --- 6,29 ---- { /// <summary> ! /// Superclass for an <see cref="ICriterion"/> that represents a ! /// constraint between two properties (with SQL binary operators). /// </summary> ! public abstract class PropertyExpression : AbstractCriterion { ! private string _lhsPropertyName; ! private string _rhsPropertyName; private static TypedValue[ ] NoTypedValues = new TypedValue[0]; /// <summary> ! /// Initialize a new instance of the <see cref="PropertyExpression" /> class ! /// that compares two mapped properties. /// </summary> ! /// <param name="lhsPropertyName">The name of the Property to use as the left hand side.</param> ! /// <param name="rhsPropertyName">The name of the Property to use as the right hand side.</param> ! protected PropertyExpression(string lhsPropertyName, string rhsPropertyName) { ! _lhsPropertyName = lhsPropertyName; ! _rhsPropertyName = rhsPropertyName; } *************** *** 32,41 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] otherColumnNames = GetColumns( factory, persistentClass, otherPropertyName, alias ); bool andNeeded = false; --- 35,44 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _lhsPropertyName, alias, aliasClasses ); ! string[ ] otherColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _rhsPropertyName, alias, aliasClasses ); bool andNeeded = false; *************** *** 63,67 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return NoTypedValues; --- 66,70 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { return NoTypedValues; *************** *** 71,78 **** public override string ToString() { ! return propertyName + Op + otherPropertyName; } ! /// <summary></summary> protected abstract string Op { get; } } --- 74,83 ---- public override string ToString() { ! return _lhsPropertyName + Op + _rhsPropertyName; } ! /// <summary> ! /// Get the Sql operator to use for the property expression. ! /// </summary> protected abstract string Op { get; } } Index: Order.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Order.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Order.cs 31 Dec 2004 17:55:35 -0000 1.5 --- Order.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; *************** *** 4,13 **** { /// <summary> ! /// Represents an order imposed upon a ICriteria result set /// </summary> public class Order { ! private bool ascending; ! private string propertyName; /// <summary> --- 5,15 ---- { /// <summary> ! /// Represents an order imposed upon a <see cref="ICriteria"/> ! /// result set. /// </summary> public class Order { ! private bool _ascending; ! private string _propertyName; /// <summary> *************** *** 18,23 **** protected Order( string propertyName, bool ascending ) { ! this.propertyName = propertyName; ! this.ascending = ascending; } --- 20,25 ---- protected Order( string propertyName, bool ascending ) { ! _propertyName = propertyName; ! _ascending = ascending; } *************** *** 32,41 **** public string ToStringForSql( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias ) { ! string[ ] columns = Expression.GetColumns( sessionFactory, persistentClass, propertyName, alias ); if( columns.Length != 1 ) { ! throw new HibernateException( "Cannot order by multi-column property: " + propertyName ); } ! return columns[ 0 ] + ( ascending ? " asc" : " desc" ); } --- 34,43 ---- public string ToStringForSql( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias ) { ! string[ ] columns = AbstractCriterion.GetColumns( sessionFactory, persistentClass, _propertyName, alias, emptyMap ); if( columns.Length != 1 ) { ! throw new HibernateException( "Cannot order by multi-column property: " + _propertyName ); } ! return columns[ 0 ] + ( _ascending ? " asc" : " desc" ); } *************** *** 59,62 **** --- 61,66 ---- return new Order( propertyName, false ); } + + private static readonly IDictionary emptyMap = new Hashtable( 0 ); } } \ No newline at end of file Index: SQLExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SQLExpression.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SQLExpression.cs 31 Dec 2004 17:55:48 -0000 1.8 --- SQLExpression.cs 17 Apr 2005 17:16:05 -0000 1.9 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 6,10 **** { /// <summary> ! /// Creates a SQLExpression /// </summary> /// <remarks> --- 7,11 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that creates a SQLExpression /// </summary> /// <remarks> *************** *** 12,19 **** /// write a correct <see cref="SqlString"/>. /// </remarks> ! public class SQLExpression : Expression { ! private readonly SqlString sql; ! private readonly TypedValue[ ] typedValues; /// <summary> --- 13,20 ---- /// write a correct <see cref="SqlString"/>. /// </remarks> ! public class SQLExpression : AbstractCriterion { ! private readonly SqlString _sql; ! private readonly TypedValue[ ] _typedValues; /// <summary> *************** *** 25,33 **** internal SQLExpression( SqlString sql, object[ ] values, IType[ ] types ) { ! this.sql = sql; ! typedValues = new TypedValue[values.Length]; ! for( int i = 0; i < typedValues.Length; i++ ) { ! typedValues[ i ] = new TypedValue( types[ i ], values[ i ] ); } } --- 26,34 ---- internal SQLExpression( SqlString sql, object[ ] values, IType[ ] types ) { ! _sql = sql; ! _typedValues = new TypedValue[values.Length]; ! for( int i = 0; i < _typedValues.Length; i++ ) { ! _typedValues[ i ] = new TypedValue( types[ i ], values[ i ] ); } } *************** *** 40,46 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { ! return sql.Replace( "$alias", alias ); } --- 41,48 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { ! // TODO: h2.1 SYNCH - need to add an overload to Replace that takes 3 params ! return _sql.Replace( "$alias", alias ); } *************** *** 51,57 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return typedValues; } --- 53,59 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return _typedValues; } *************** *** 59,63 **** public override string ToString() { ! return sql.ToString(); } } --- 61,65 ---- public override string ToString() { ! return _sql.ToString(); } } Index: NotExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/NotExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NotExpression.cs 31 Dec 2004 17:55:06 -0000 1.5 --- NotExpression.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using System.Collections; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 5,21 **** { /// <summary> ! /// Negates another expression. /// </summary> ! public class NotExpression : Expression { ! private Expression expression; /// <summary> ! /// /// </summary> ! /// <param name="expression"></param> ! internal NotExpression( Expression expression ) { ! this.expression = expression; } --- 6,23 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that negates another <see cref="ICriterion"/>. /// </summary> ! public class NotExpression : AbstractCriterion { ! private ICriterion _criterion; /// <summary> ! /// Initialize a new instance of the <see cref="NotExpression" /> class for an ! /// <see cref="ICriterion"/> /// </summary> ! /// <param name="criterion">The <see cref="ICriterion"/> to negate.</param> ! internal NotExpression( ICriterion criterion ) { ! _criterion = criterion; } *************** *** 27,36 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: set default capacity SqlStringBuilder builder = new SqlStringBuilder(); builder.Add( "not " ); ! builder.Add( expression.ToSqlString( factory, persistentClass, alias ) ); return builder.ToSqlString(); --- 29,39 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: set default capacity SqlStringBuilder builder = new SqlStringBuilder(); builder.Add( "not " ); ! // TODO: h2.1 SYNCH: add a MySqlDialect check ! builder.Add( _criterion.ToSqlString( factory, persistentClass, alias, aliasClasses ) ); return builder.ToSqlString(); *************** *** 43,49 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return expression.GetTypedValues( sessionFactory, persistentClass ); } --- 46,52 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { ! return _criterion.GetTypedValues( sessionFactory, persistentClass, aliasClasses ); } *************** *** 51,55 **** public override string ToString() { ! return "not " + expression.ToString(); } } --- 54,58 ---- public override string ToString() { ! return "not " + _criterion.ToString(); } } Index: LikeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LikeExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LikeExpression.cs 31 Dec 2004 17:54:36 -0000 1.4 --- LikeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 2,19 **** { /// <summary> ! /// Summary description for LikeExpression. /// </summary> public class LikeExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal LikeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 2,28 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents an "like" constraint. /// </summary> + /// <remarks> + /// The case sensitivity depends on the database settings for string + /// comparisons. Use <see cref="InsensitiveLikeExpression"/> if the + /// string comparison should not be case sensitive. + /// </remarks> public class LikeExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="LikeExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal LikeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="LikeExpression"/>. ! /// </summary> ! /// <value>The string "<c> like </c>"</value> protected override string Op { Index: EqExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/EqExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EqExpression.cs 31 Dec 2004 17:52:25 -0000 1.5 --- EqExpression.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 2,19 **** { /// <summary> ! /// An Expression that represents an "equal" constraint. /// </summary> public class EqExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal EqExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 2,23 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents an "equal" constraint. /// </summary> public class EqExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="EqExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal EqExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="EqExpression"/>. ! /// </summary> ! /// <value>The string "<c> = </c>"</value> protected override string Op { Index: OrExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/OrExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OrExpression.cs 31 Dec 2004 17:55:48 -0000 1.4 --- OrExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 2,6 **** { /// <summary> ! /// An Expression that combines two <see cref="Expression"/>s with an /// <c>"or"</c> between them. /// </summary> --- 2,6 ---- { /// <summary> ! /// An <see cref="ICriterion" /> that combines two <see cref="ICriterion"/>s with an /// <c>"or"</c> between them. /// </summary> *************** *** 8,16 **** { /// <summary> ! /// /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! internal OrExpression( Expression lhs, Expression rhs ) : base( lhs, rhs ) { } --- 8,17 ---- { /// <summary> ! /// Initialize a new instance of the <see cref="OrExpression" /> class for ! /// two <see cref="ICriterion"/>s. /// </summary> ! /// <param name="lhs">The <see cref="ICriterion"/> to use as the left hand side.</param> ! /// <param name="rhs">The <see cref="ICriterion"/> to use as the right hand side.</param> ! internal OrExpression( ICriterion lhs, ICriterion rhs ) : base( lhs, rhs ) { } Index: AndExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/AndExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AndExpression.cs 31 Dec 2004 17:52:10 -0000 1.4 --- AndExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 2,23 **** { /// <summary> ! /// An Expression that combines two <see cref="Expression"/>s with an ! /// <c>and</c> between them. /// </summary> public class AndExpression : LogicalExpression { /// <summary> ! /// /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! internal AndExpression( Expression lhs, Expression rhs ) : base( lhs, rhs ) { } /// <summary> ! /// Get the Sql operator to put between the two <see cref="Expression"/>s. /// </summary> ! /// <value>Returns "<c>and</c>"</value> protected override string Op { --- 2,24 ---- { /// <summary> ! /// An <see cref="LogicalExpression"/> that combines two <see cref="ICriterion"/>s ! /// with an <c>and</c> between them. /// </summary> public class AndExpression : LogicalExpression { /// <summary> ! /// Initializes a new instance of the <see cref="AndExpression"/> class ! /// that combines two <see cref="ICriterion"/>. /// </summary> ! /// <param name="lhs">The <see cref="ICriterion"/> to use as the left hand side.</param> ! /// <param name="rhs">The <see cref="ICriterion"/> to use as the right hand side.</param> ! internal AndExpression( ICriterion lhs, ICriterion rhs ) : base( lhs, rhs ) { } /// <summary> ! /// Get the Sql operator to put between the two <see cref="ICriterion"/>s. /// </summary> ! /// <value>The string "<c>and</c>"</value> protected override string Op { Index: LtPropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtPropertyExpression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LtPropertyExpression.cs 31 Dec 2004 17:55:06 -0000 1.2 --- LtPropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 *************** *** 1,18 **** namespace NHibernate.Expression { ! /// <summary></summary> public class LtPropertyExpression : PropertyExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! public LtPropertyExpression( string propertyName, string otherPropertyName ) ! : base( propertyName, otherPropertyName ) { } ! /// <summary></summary> protected override string Op { --- 1,25 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "less than" constraint ! /// between two properties. ! /// </summary> public class LtPropertyExpression : PropertyExpression { /// <summary> ! /// Initializes a new instance of the <see cref="LtPropertyExpression"/> class ! /// that compares two mapped properties using an "less than" constraint. /// </summary> ! /// <param name="lhsPropertyName">The name of the Property to use as the left hand side.</param> ! /// <param name="rhsPropertyName">The name of the Property to use as the right hand side.</param> ! public LtPropertyExpression( string lhsPropertyName, string rhsPropertyName ) ! : base( lhsPropertyName, rhsPropertyName ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="LtPropertyExpression"/>. ! /// </summary> ! /// <value>The string "<c> < </c>"</value> protected override string Op { Index: EqPropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/EqPropertyExpression.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EqPropertyExpression.cs 31 Dec 2004 17:52:25 -0000 1.2 --- EqPropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 *************** *** 1,18 **** namespace NHibernate.Expression { ! /// <summary></summary> public class EqPropertyExpression : PropertyExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! public EqPropertyExpression( string propertyName, string otherPropertyName ) ! : base( propertyName, otherPropertyName ) { } ! /// <summary></summary> protected override string Op { --- 1,25 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "equal" constraint ! /// between two properties. ! /// </summary> public class EqPropertyExpression : PropertyExpression { /// <summary> ! /// Initializes a new instance of the <see cref="EqPropertyExpression"/> class ! /// that compares two mapped properties using an "equal" constraint. /// </summary> ! /// <param name="lhsPropertyName">The name of the Property to use as the left hand side.</param> ! /// <param name="rhsPropertyName">The name of the Property to use as the right hand side.</param> ! public EqPropertyExpression( string lhsPropertyName, string rhsPropertyName ) ! : base( lhsPropertyName, rhsPropertyName ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="EqPropertyExpression"/>. ! /// </summary> ! /// <value>The string "<c> = </c>"</value> protected override string Op { Index: LtExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LtExpression.cs 31 Dec 2004 17:55:06 -0000 1.3 --- LtExpression.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 1,17 **** namespace NHibernate.Expression { ! /// <summary></summary> public class LtExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal LtExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 1,23 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "less than" constraint. ! /// </summary> public class LtExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="LtExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal LtExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="LtExpression"/>. ! /// </summary> ! /// <value>The string "<c> < </c>"</value> protected override string Op { Index: GeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/GeExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GeExpression.cs 31 Dec 2004 17:52:39 -0000 1.4 --- GeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 1,17 **** namespace NHibernate.Expression { ! /// <summary></summary> public class GeExpression : SimpleExpression { /// <summary> ! /// /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="value"></param> internal GeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary></summary> protected override string Op { --- 1,23 ---- namespace NHibernate.Expression { ! /// <summary> ! /// An <see cref="ICriterion"/> that represents an "greater than or equal" constraint. ! /// </summary> public class GeExpression : SimpleExpression { /// <summary> ! /// Initialize a new instance of the <see cref="GeExpression" /> class for a named ! /// Property and its value. /// </summary> ! /// <param name="propertyName">The name of the Property in the class.</param> ! /// <param name="value">The value for the Property.</param> internal GeExpression( string propertyName, object value ) : base( propertyName, value ) { } ! /// <summary> ! /// Get the Sql operator to use for the <see cref="GeExpression"/>. ! /// </summary> ! /// <value>The string "<c> >= </c>"</value> protected override string Op { Index: ICriterion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/ICriterion.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICriterion.cs 1 Mar 2005 16:25:08 -0000 1.1 --- ICriterion.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 1,7 **** using System.Collections; using NHibernate.Engine; - using NHibernate.Persister; using NHibernate.SqlCommand; - using NHibernate.Type; namespace NHibernate.Expression --- 1,5 ---- *************** *** 9,13 **** /// <summary> /// An object-oriented representation of a query criterion that may be used as a constraint ! /// in a <c>Criteria</c> query. /// </summary> /// <remarks> --- 7,11 ---- /// <summary> /// An object-oriented representation of a query criterion that may be used as a constraint ! /// in a <see cref="ICriteria"/> query. /// </summary> /// <remarks> *************** *** 19,38 **** { /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="alias"></param> /// <param name="aliasClasses"></param> ! /// <returns></returns> SqlString ToSqlString( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias, IDictionary aliasClasses ); /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="aliasClasses"></param> ! /// <returns></returns> TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ); } --- 17,35 ---- { /// <summary> ! /// Render a SqlString fragment for the expression. /// </summary> ! /// <param name="sessionFactory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> ! /// <param name="alias">The alias to use for the table.</param> /// <param name="aliasClasses"></param> ! /// <returns>A SqlString that contains a valid Sql fragment.</returns> SqlString ToSqlString( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias, IDictionary aliasClasses ); /// <summary> ! /// Return typed values for all parameters in the rendered SQL fragment /// </summary> ! /// <param name="sessionFactory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> ! /// <returns>An array of TypedValues for the Expression.</returns> TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ); } Index: AbstractCriterion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/AbstractCriterion.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractCriterion.cs 1 Mar 2005 16:25:08 -0000 1.1 --- AbstractCriterion.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using NHibernate.Engine; *************** *** 9,18 **** { /// <summary> ! /// Summary description for AbstractCriterion. /// </summary> public abstract class AbstractCriterion : ICriterion { /// <summary> ! /// /// </summary> protected AbstractCriterion() --- 10,21 ---- { /// <summary> ! /// Base class for <see cref="ICriterion"/> implementations. /// </summary> public abstract class AbstractCriterion : ICriterion { + private static readonly IDictionary EmptyDictionary = new Hashtable( 0 ); + /// <summary> ! /// Initializes a new instance of the <see cref="AbstractCriterion"/> class. /// </summary> protected AbstractCriterion() *************** *** 25,28 **** --- 28,36 ---- } + protected internal static string[] GetColumns(ISessionFactoryImplementor factory, System.Type persistentClass, string property) + { + return AbstractCriterion.GetColumns( factory, persistentClass, property, null, AbstractCriterion.EmptyDictionary ); + } + /// <summary> /// *************** *** 34,43 **** /// <param name="aliasClasses"></param> /// <returns></returns> ! protected static string[] GetColumns( ISessionFactoryImplementor factory, System.Type persistentClass, string property, string alias, IDictionary aliasClasses ) { if ( property.IndexOf( '.' ) > 0 ) { string root = StringHelper.Root( property ); ! System.Type clazz = (System.Type) aliasClasses[ root ]; if ( clazz != null ) { --- 42,51 ---- /// <param name="aliasClasses"></param> /// <returns></returns> ! protected internal static string[] GetColumns( ISessionFactoryImplementor factory, System.Type persistentClass, string property, string alias, IDictionary aliasClasses ) { if ( property.IndexOf( '.' ) > 0 ) { string root = StringHelper.Root( property ); ! System.Type clazz = aliasClasses[ root ] as System.Type; if ( clazz != null ) { *************** *** 48,56 **** } ! return GetPropertyMapping( persistentClass, factory ).ToColumns( alias, property ); } /// <summary> ! /// /// </summary> /// <param name="factory"></param> --- 56,64 ---- } ! return AbstractCriterion.GetPropertyMapping( persistentClass, factory ).ToColumns( alias, property ); } /// <summary> ! /// Get the a typed value for the given property value. /// </summary> /// <param name="factory"></param> *************** *** 72,80 **** } ! return GetPropertyMapping( persistentClass, factory ).ToType( property ); } /// <summary> ! /// /// </summary> /// <param name="factory"></param> --- 80,88 ---- } ! return AbstractCriterion.GetPropertyMapping( persistentClass, factory ).ToType( property ); } /// <summary> ! /// Get the <see cref="TypedValue"/> for the given property value. /// </summary> /// <param name="factory"></param> *************** *** 86,111 **** protected static TypedValue GetTypedValue( ISessionFactoryImplementor factory, System.Type persistentClass, string property, object value, IDictionary aliasClasses ) { ! return new TypedValue( GetType( factory, persistentClass, property, aliasClasses), value ); } #region ICriterion Members /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="alias"></param> /// <param name="aliasClasses"></param> ! /// <returns></returns> ! public abstract SqlString ToSqlString(ISessionFactoryImplementor sessionFactory, System.Type persistentClass, string alias, IDictionary aliasClasses); /// <summary> ! /// /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> /// <param name="aliasClasses"></param> ! /// <returns></returns> public abstract TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses); --- 94,131 ---- protected static TypedValue GetTypedValue( ISessionFactoryImplementor factory, System.Type persistentClass, string property, object value, IDictionary aliasClasses ) { ! return new TypedValue( AbstractCriterion.GetType( factory, persistentClass, property, aliasClasses), value ); } + /// <summary> + /// Gets a string representation of the <see cref="AbstractCriterion"/>. + /// </summary> + /// <returns> + /// A String that shows the contents of the <see cref="AbstractCriterion"/>. + /// </returns> + /// <remarks> + /// This is not a well formed Sql fragment. It is useful for logging what the <see cref="AbstractCriterion"/> + /// looks like. + /// </remarks> + public abstract override string ToString(); + #region ICriterion Members /// <summary> ! /// Render a SqlString for the expression. /// </summary> ! /// <param name="factory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> ! /// <param name="alias">The alias to use for the table.</param> /// <param name="aliasClasses"></param> ! /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public abstract SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses); /// <summary> ! /// Return typed values for all parameters in the rendered SQL fragment /// </summary> ! /// <param name="sessionFactory">The ISessionFactory that contains the mapping for the Type.</param> ! /// <param name="persistentClass">The Class the Expression is being built for.</param> /// <param name="aliasClasses"></param> ! /// <returns>An array of TypedValues for the Expression.</returns> public abstract TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses); Index: BetweenExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/BetweenExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BetweenExpression.cs 31 Dec 2004 17:52:10 -0000 1.6 --- BetweenExpression.cs 17 Apr 2005 17:16:05 -0000 1.7 *************** *** 1,2 **** --- 1,4 ---- + using System; + using System.Collections; using NHibernate.Engine; using NHibernate.Persister; *************** *** 7,20 **** { /// <summary> ! /// An Expression that represents a "between" constraint. /// </summary> ! public class BetweenExpression : Expression { ! private readonly string propertyName; ! private readonly object lo; ! private readonly object hi; /// <summary> ! /// Initialize a new instance of the BetweenExpression class for /// the named Property. /// </summary> --- 9,22 ---- { /// <summary> ! /// An <see cref="ICriterion"/> that represents a "between" constraint. /// </summary> ! public class BetweenExpression : AbstractCriterion { ! private readonly string _propertyName; ! private readonly object _lo; ! private readonly object _hi; /// <summary> ! /// Initialize a new instance of the <see cref="BetweenExpression" /> class for /// the named Property. /// </summary> *************** *** 24,30 **** internal BetweenExpression( string propertyName, object lo, object hi ) { ! this.propertyName = propertyName; ! this.lo = lo; ! this.hi = hi; } --- 26,32 ---- internal BetweenExpression( string propertyName, object lo, object hi ) { ! _propertyName = propertyName; ! _lo = lo; ! _hi = hi; } *************** *** 36,47 **** /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add a default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); string[ ] loParamColumnNames = new string[paramColumnNames.Length]; string[ ] hiParamColumnNames = new string[paramColumnNames.Length]; --- 38,50 ---- /// <param name="alias"></param> /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias, IDictionary aliasClasses ) { //TODO: add a default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( _propertyName ); ! string[ ] columnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName, alias, aliasClasses ); ! // don't need to worry about aliasing or aliasClassing for parameter column names ! string[ ] paramColumnNames = AbstractCriterion.GetColumns( factory, persistentClass, _propertyName ); string[ ] loParamColumnNames = new string[paramColumnNames.Length]; string[ ] hiParamColumnNames = new string[paramColumnNames.Length]; *************** *** 55,63 **** } - Parameter[ ] parameters = new Parameter[paramColumnNames.Length*2]; Parameter[ ] loParameters = Parameter.GenerateParameters( factory, alias, loParamColumnNames, propertyType ); Parameter[ ] hiParameters = Parameter.GenerateParameters( factory, alias, hiParamColumnNames, propertyType ); - - bool andNeeded = false; --- 58,63 ---- *************** *** 86,95 **** /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return new TypedValue[ ] { ! GetTypedValue( sessionFactory, persistentClass, propertyName, lo ), ! GetTypedValue( sessionFactory, persistentClass, propertyName, hi ) }; } --- 86,95 ---- /// <param name="persistentClass"></param> /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass, IDictionary aliasClasses ) { return new TypedValue[ ] { ! AbstractCriterion.G... [truncated message content] |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:15
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Util Modified Files: ArrayHelper.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: ArrayHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/ArrayHelper.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ArrayHelper.cs 1 Mar 2005 16:24:50 -0000 1.5 --- ArrayHelper.cs 17 Apr 2005 17:16:07 -0000 1.6 *************** *** 2,12 **** using System.Collections; using System.Data; using NHibernate.SqlTypes; namespace NHibernate.Util { ! /// <summary></summary> public sealed class ArrayHelper { private ArrayHelper() { --- 2,21 ---- using System.Collections; using System.Data; + using NHibernate.SqlTypes; + using NHibernate.Type; namespace NHibernate.Util { ! /// <summary> ! /// Helper class that contains common array functions and ! /// data structures used through out NHibernate. ! /// </summary> public sealed class ArrayHelper { + + public static readonly object[ ] EmptyObjectArray = new object[0]; + public static readonly IType[ ] EmptyTypeArray = new IType[0]; + private ArrayHelper() { |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:15
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Type Modified Files: ComponentType.cs CompositeCustomType.cs IAbstractComponentType.cs ObjectType.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: CompositeCustomType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/CompositeCustomType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CompositeCustomType.cs 1 Mar 2005 16:24:50 -0000 1.5 --- CompositeCustomType.cs 17 Apr 2005 17:16:06 -0000 1.6 *************** *** 71,83 **** public virtual object[ ] GetPropertyValues( object component, ISessionImplementor session ) { int len = Subtypes.Length; object[ ] result = new object[len]; for( int i = 0; i < len; i++ ) { ! result[ i ] = GetPropertyValue( component, i, session ); } return result; } - /// <summary> /// --- 71,87 ---- public virtual object[ ] GetPropertyValues( object component, ISessionImplementor session ) { + return GetPropertyValues( component ); + } + + public object[] GetPropertyValues(object component) + { int len = Subtypes.Length; object[ ] result = new object[len]; for( int i = 0; i < len; i++ ) { ! result[ i ] = GetPropertyValue( component, i ); } return result; } /// <summary> /// *************** *** 102,105 **** --- 106,114 ---- public virtual object GetPropertyValue( object component, int i, ISessionImplementor session ) { + return GetPropertyValue( component, i ); + } + + public object GetPropertyValue( object component, int i ) + { return userType.GetPropertyValue( component, i ); } Index: ComponentType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ComponentType.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ComponentType.cs 14 Mar 2005 18:54:20 -0000 1.14 --- ComponentType.cs 17 Apr 2005 17:16:06 -0000 1.15 *************** *** 68,72 **** /// </summary> /// <param name="componentClass"></param> ! /// <param name="properties"></param> /// <param name="propertyGetters"></param> /// <param name="propertySetters"></param> --- 68,72 ---- /// </summary> /// <param name="componentClass"></param> ! /// <param name="propertyNames"></param> /// <param name="propertyGetters"></param> /// <param name="propertySetters"></param> *************** *** 76,82 **** /// <param name="cascade"></param> /// <param name="parentProperty"></param> - /// <param name="embedded"></param> public ComponentType( System.Type componentClass, ! string[ ] properties, IGetter[ ] propertyGetters, ISetter[ ] propertySetters, --- 76,81 ---- /// <param name="cascade"></param> /// <param name="parentProperty"></param> public ComponentType( System.Type componentClass, ! string[ ] propertyNames, IGetter[ ] propertyGetters, ISetter[ ] propertySetters, *************** *** 85,94 **** OuterJoinFetchStrategy[ ] joinedFetch, Cascades.CascadeStyle[ ] cascade, ! string parentProperty, ! bool embedded ) // not used !?! { this.componentClass = componentClass; this.propertyTypes = propertyTypes; ! propertySpan = properties.Length; getters = propertyGetters; setters = propertySetters; --- 84,92 ---- OuterJoinFetchStrategy[ ] joinedFetch, Cascades.CascadeStyle[ ] cascade, ! string parentProperty) { this.componentClass = componentClass; this.propertyTypes = propertyTypes; ! propertySpan = propertyNames.Length; getters = propertyGetters; setters = propertySetters; *************** *** 114,118 **** parentGetter = pa.GetGetter( componentClass, parentProperty ); } ! this.propertyNames = properties; this.cascade = cascade; this.joinedFetch = joinedFetch; --- 112,116 ---- parentGetter = pa.GetGetter( componentClass, parentProperty ); } ! this.propertyNames = propertyNames; this.cascade = cascade; this.joinedFetch = joinedFetch; Index: IAbstractComponentType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/IAbstractComponentType.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IAbstractComponentType.cs 1 Mar 2005 16:24:50 -0000 1.9 --- IAbstractComponentType.cs 17 Apr 2005 17:16:06 -0000 1.10 *************** *** 24,28 **** /// <summary> ! /// /// </summary> /// <param name="component"></param> --- 24,35 ---- /// <summary> ! /// Optional Operation ! /// </summary> ! /// <param name="component"></param> ! /// <returns></returns> ! object[] GetPropertyValues(object component); ! ! /// <summary> ! /// Optional operation /// </summary> /// <param name="component"></param> Index: ObjectType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ObjectType.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ObjectType.cs 14 Mar 2005 18:54:20 -0000 1.12 --- ObjectType.cs 17 Apr 2005 17:16:06 -0000 1.13 *************** *** 343,346 **** --- 343,351 ---- } + public object[] GetPropertyValues( object component ) + { + throw new NotSupportedException(); + } + /// <summary></summary> public override bool IsComponentType |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate.Test/ExpressionTest Modified Files: BaseExpressionFixture.cs BetweenExpressionFixture.cs InExpressionFixture.cs InsensitiveLikeExpressionFixture.cs JunctionFixture.cs LogicalExpressionFixture.cs NotExpressionFixture.cs NotNullExpressionFixture.cs NullExpressionFixture.cs PropertyExpressionFixture.cs QueryByExampleTest.cs SimpleExpressionFixture.cs SQLExpressionFixture.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: InExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/InExpressionFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InExpressionFixture.cs 30 Jan 2005 19:39:52 -0000 1.3 --- InExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 26,32 **** ISession session = factory.OpenSession(); ! NExpression.Expression inExpression = NExpression.Expression.In("Count", new int[]{3,4,5}); ! SqlString sqlString = inExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.count_ in (:simple_alias.count__0, :simple_alias.count__1, :simple_alias.count__2)"; --- 26,32 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion inExpression = NExpression.Expression.In("Count", new int[]{3,4,5}); ! SqlString sqlString = inExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.count_ in (:simple_alias.count__0, :simple_alias.count__1, :simple_alias.count__2)"; Index: SQLExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/SQLExpressionFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SQLExpressionFixture.cs 30 Jan 2005 19:39:52 -0000 1.3 --- SQLExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 21,27 **** ISession session = factory.OpenSession(); ! NExpression.Expression sqlExpression = NExpression.Expression.Sql("$alias.address is not null"); ! SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address is not null"; --- 21,27 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion sqlExpression = NExpression.Expression.Sql("$alias.address is not null"); ! SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.address is not null"; *************** *** 37,43 **** ISession session = factory.OpenSession(); ! NExpression.Expression sqlExpression = NExpression.Expression.Sql( new SqlString( "$alias.address is not null") ); ! SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address is not null"; --- 37,43 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion sqlExpression = NExpression.Expression.Sql( new SqlString( "$alias.address is not null") ); ! SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.address is not null"; *************** *** 63,69 **** builder.Add( firstAndParam ); ! NExpression.Expression sqlExpression = NExpression.Expression.Sql(builder.ToSqlString(), "some address", NHibernateUtil.String ); ! SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); CompareSqlStrings(sqlString, expectedSql, expectedParams); --- 63,69 ---- builder.Add( firstAndParam ); ! NExpression.ICriterion sqlExpression = NExpression.Expression.Sql(builder.ToSqlString(), "some address", NHibernateUtil.String ); ! SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); CompareSqlStrings(sqlString, expectedSql, expectedParams); Index: SimpleExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/SimpleExpressionFixture.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleExpressionFixture.cs 30 Jan 2005 19:39:52 -0000 1.5 --- SimpleExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 31,37 **** ISession session = factory.OpenSession(); ! NExpression.Expression andExpression = NExpression.Expression.Eq("Address", "12 Adress"); ! SqlString sqlString = andExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address = :simple_alias.address"; --- 31,37 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion andExpression = NExpression.Expression.Eq("Address", "12 Adress"); ! SqlString sqlString = andExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.address = :simple_alias.address"; *************** *** 56,62 **** DateTime now = DateTime.Now; ! NExpression.Expression andExpression = NExpression.Expression.Eq( "Date", now ); ! SqlString sqlString = andExpression.ToSqlString( factoryImpl, typeof(SimpleComponent), "simp_comp" ); string quotedColumn = dialect.QuoteForColumnName( "d[at]e_" ); string expectedSql = "simp_comp." + quotedColumn + " = :simp_comp." + quotedColumn; --- 56,62 ---- DateTime now = DateTime.Now; ! NExpression.ICriterion andExpression = NExpression.Expression.Eq( "Date", now ); ! SqlString sqlString = andExpression.ToSqlString( factoryImpl, typeof(SimpleComponent), "simp_comp", BaseExpressionFixture.EmptyAliasClasses ); string quotedColumn = dialect.QuoteForColumnName( "d[at]e_" ); string expectedSql = "simp_comp." + quotedColumn + " = :simp_comp." + quotedColumn; *************** *** 72,78 **** ISession session = factory.OpenSession(); ! NExpression.Expression andExpression = NExpression.Expression.Ge( "Date", DateTime.Now ); ! SqlString sqlString = andExpression.ToSqlString( factoryImpl, typeof(Simple), "simple_alias" ); string expectedSql = "simple_alias.date_ >= :simple_alias.date_"; --- 72,78 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion andExpression = NExpression.Expression.Ge( "Date", DateTime.Now ); ! SqlString sqlString = andExpression.ToSqlString( factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.date_ >= :simple_alias.date_"; Index: NullExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/NullExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- NullExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 25,31 **** ISession session = factory.OpenSession(); ! NExpression.Expression expression = NExpression.Expression.IsNull("Address"); ! SqlString sqlString = expression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address IS NULL"; --- 25,31 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion expression = NExpression.Expression.IsNull("Address"); ! SqlString sqlString = expression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.address IS NULL"; Index: NotExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/NotExpressionFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NotExpressionFixture.cs 30 Jan 2005 19:39:52 -0000 1.3 --- NotExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 24,30 **** ISession session = factory.OpenSession(); ! NExpression.Expression notExpression = NExpression.Expression.Not(NExpression.Expression.Eq("Address", "12 Adress")); ! SqlString sqlString = notExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "not simple_alias.address = :simple_alias.address"; --- 24,30 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion notExpression = NExpression.Expression.Not(NExpression.Expression.Eq("Address", "12 Adress")); ! SqlString sqlString = notExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "not simple_alias.address = :simple_alias.address"; Index: QueryByExampleTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QueryByExampleTest.cs 9 Apr 2005 12:48:06 -0000 1.3 --- QueryByExampleTest.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 14,29 **** public class QueryByExampleTest : TestCase { - public QueryByExampleTest() - { - // - // TODO: Add constructor logic here - // - } - [SetUp] public void SetUp() { ExportSchema( new string[] { "Componentizable.hbm.xml"}); ! initData(); } --- 14,22 ---- public class QueryByExampleTest : TestCase { [SetUp] public void SetUp() { ExportSchema( new string[] { "Componentizable.hbm.xml"}); ! InitData(); } *************** *** 37,41 **** Componentizable master = GetMaster("hibernate", null, "ope%"); ICriteria crit = s.CreateCriteria(typeof(Componentizable)); ! Example ex = Example.create(master).EnableLike(); crit.Add(ex); IList result = crit.List(); --- 30,34 ---- Componentizable master = GetMaster("hibernate", null, "ope%"); ICriteria crit = s.CreateCriteria(typeof(Componentizable)); ! Example ex = Example.Create(master).EnableLike(); crit.Add(ex); IList result = crit.List(); *************** *** 47,51 **** [Test] ! [Ignore("Test Fails with Exception - do to with Criteria expression/parameter handling")] public void TestJunctionNotExpressionQBE() { --- 40,44 ---- [Test] ! //[Ignore("Test Fails with Exception - do to with Criteria expression/parameter handling")] public void TestJunctionNotExpressionQBE() { *************** *** 55,59 **** Componentizable master = GetMaster("hibernate", null, "ope%"); ICriteria crit = s.CreateCriteria(typeof(Componentizable)); ! Example ex = Example.create(master).EnableLike(); --- 48,52 ---- Componentizable master = GetMaster("hibernate", null, "ope%"); ICriteria crit = s.CreateCriteria(typeof(Componentizable)); ! Example ex = Example.Create(master).EnableLike(); *************** *** 77,81 **** Componentizable master = GetMaster("hibernate", null, "ope%"); ICriteria crit = s.CreateCriteria(typeof(Componentizable)); ! Example ex = Example.create(master).EnableLike() .ExcludeProperty("Component.SubComponent"); crit.Add(ex); --- 70,74 ---- Componentizable master = GetMaster("hibernate", null, "ope%"); ICriteria crit = s.CreateCriteria(typeof(Componentizable)); ! Example ex = Example.Create(master).EnableLike() .ExcludeProperty("Component.SubComponent"); crit.Add(ex); *************** *** 86,90 **** master = GetMaster("hibernate", "ORM tool", "fake stuff"); crit = s.CreateCriteria(typeof(Componentizable)); ! ex = Example.create(master).EnableLike() .ExcludeProperty("Component.SubComponent.SubName1"); crit.Add(ex); --- 79,83 ---- master = GetMaster("hibernate", "ORM tool", "fake stuff"); crit = s.CreateCriteria(typeof(Componentizable)); ! ex = Example.Create(master).EnableLike() .ExcludeProperty("Component.SubComponent.SubName1"); crit.Add(ex); *************** *** 96,100 **** } ! private void initData() { using( ISession s = sessions.OpenSession() ) --- 89,93 ---- } ! private void InitData() { using( ISession s = sessions.OpenSession() ) *************** *** 120,124 **** } ! private void deleteData() { using( ISession s = sessions.OpenSession() ) --- 113,117 ---- } ! private void DeleteData() { using( ISession s = sessions.OpenSession() ) Index: BetweenExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/BetweenExpressionFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BetweenExpressionFixture.cs 30 Jan 2005 19:39:52 -0000 1.3 --- BetweenExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.4 *************** *** 24,29 **** ISession session = factory.OpenSession(); ! NExpression.Expression betweenExpression = NExpression.Expression.Between("Count", 5, 10); ! SqlString sqlString = betweenExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); --- 24,29 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion betweenExpression = NExpression.Expression.Between("Count", 5, 10); ! SqlString sqlString = betweenExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); Index: LogicalExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/LogicalExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LogicalExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- LogicalExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 29,38 **** ISession session = factory.OpenSession(); ! NExpression.Expression orExpression = NExpression.Expression.Or(NExpression.Expression.IsNull("Address"),NExpression.Expression.Between("Count", 5, 10) ); ! SqlString sqlString = orExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); ! string expectedSql = "((simple_alias.address IS NULL) or (simple_alias.count_ between :simple_alias.count__lo and :simple_alias.count__hi))"; CompareSqlStrings(sqlString, expectedSql, 2); --- 29,38 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion orExpression = NExpression.Expression.Or(NExpression.Expression.IsNull("Address"),NExpression.Expression.Between("Count", 5, 10) ); ! SqlString sqlString = orExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); ! string expectedSql = "(simple_alias.address IS NULL or simple_alias.count_ between :simple_alias.count__lo and :simple_alias.count__hi)"; CompareSqlStrings(sqlString, expectedSql, 2); Index: InsensitiveLikeExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/InsensitiveLikeExpressionFixture.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InsensitiveLikeExpressionFixture.cs 16 Feb 2005 20:09:18 -0000 1.4 --- InsensitiveLikeExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 25,31 **** ISession session = factory.OpenSession(); ! NExpression.Expression expression = NExpression.Expression.InsensitiveLike("Address", "12 Adress"); ! SqlString sqlString = expression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "lower(simple_alias.address) like :simple_alias.address"; --- 25,31 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion expression = NExpression.Expression.InsensitiveLike("Address", "12 Adress"); ! SqlString sqlString = expression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "lower(simple_alias.address) like :simple_alias.address"; Index: NotNullExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/NotNullExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NotNullExpressionFixture.cs 20 Mar 2004 23:08:55 -0000 1.1 --- NotNullExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 24,30 **** ISession session = factory.OpenSession(); ! NExpression.Expression notNullExpression = NExpression.Expression.IsNotNull("Address"); ! SqlString sqlString = notNullExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address IS NOT NULL"; --- 24,30 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion notNullExpression = NExpression.Expression.IsNotNull("Address"); ! SqlString sqlString = notNullExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.address IS NOT NULL"; Index: BaseExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/BaseExpressionFixture.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BaseExpressionFixture.cs 18 Nov 2004 02:47:00 -0000 1.5 --- BaseExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.6 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Reflection; *************** *** 20,23 **** --- 21,26 ---- protected Dialect.Dialect dialect; + protected static readonly IDictionary EmptyAliasClasses = new Hashtable(); + [SetUp] public virtual void SetUp() Index: PropertyExpressionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/PropertyExpressionFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PropertyExpressionFixture.cs 2 Aug 2004 04:30:36 -0000 1.1 --- PropertyExpressionFixture.cs 17 Apr 2005 17:16:05 -0000 1.2 *************** *** 26,32 **** ISession session = factory.OpenSession(); ! NExpression.Expression andExpression = NExpression.Expression.EqProperty("Address", "Name"); ! SqlString sqlString = andExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address = simple_alias.Name"; --- 26,32 ---- ISession session = factory.OpenSession(); ! NExpression.ICriterion andExpression = NExpression.Expression.EqProperty("Address", "Name"); ! SqlString sqlString = andExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "simple_alias.address = simple_alias.Name"; Index: JunctionFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest/JunctionFixture.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JunctionFixture.cs 17 Jan 2005 03:40:51 -0000 1.4 --- JunctionFixture.cs 17 Apr 2005 17:16:05 -0000 1.5 *************** *** 37,41 **** public void SqlString() { ! SqlString sqlString = _conjunction.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "(simple_alias.address IS NULL and simple_alias.count_ between :simple_alias.count__lo and :simple_alias.count__hi)"; --- 37,41 ---- public void SqlString() { ! SqlString sqlString = _conjunction.ToSqlString(factoryImpl, typeof(Simple), "simple_alias", BaseExpressionFixture.EmptyAliasClasses ); string expectedSql = "(simple_alias.address IS NULL and simple_alias.count_ between :simple_alias.count__lo and :simple_alias.count__hi)"; *************** *** 48,52 **** public void GetTypedValues() { ! TypedValue[] typedValues = _conjunction.GetTypedValues( factoryImpl, typeof(Simple) ); TypedValue[] expectedTV = new TypedValue[2]; --- 48,52 ---- public void GetTypedValues() { ! TypedValue[] typedValues = _conjunction.GetTypedValues( factoryImpl, typeof(Simple), BaseExpressionFixture.EmptyAliasClasses ); TypedValue[] expectedTV = new TypedValue[2]; |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/SqlCommand Modified Files: Parameter.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: Parameter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Parameter.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Parameter.cs 30 Jan 2005 19:39:13 -0000 1.13 --- Parameter.cs 17 Apr 2005 17:16:06 -0000 1.14 *************** *** 1,4 **** - //using System.Data; - //using NHibernate.Driver; using System; using NHibernate.Engine; --- 1,2 ---- *************** *** 55,58 **** --- 53,60 ---- /// </summary> /// <value>The name of the Parameter.</value> + /// <remarks> + /// The Parameter name is not used by anything except to compare equality + /// and to generate a debug string. + /// </remarks> public string Name { |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Loader Modified Files: CriteriaLoader.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: CriteriaLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/CriteriaLoader.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CriteriaLoader.cs 14 Mar 2005 18:53:03 -0000 1.12 --- CriteriaLoader.cs 17 Apr 2005 17:16:06 -0000 1.13 *************** *** 62,66 **** IList associations = WalkTree( persister, Alias, factory ); InitClassPersisters( associations ); ! InitStatementString( associations, criteria.Expression.ToSqlString( factory, criteria.PersistentClass, Alias ), orderByBuilder.ToString(), factory ); PostInstantiate(); --- 62,67 ---- IList associations = WalkTree( persister, Alias, factory ); InitClassPersisters( associations ); ! // TODO: H2.1 SYNCH - new Hashtable() is a HACK until it is all up to H2.1 code ! InitStatementString( associations, criteria.Expression.ToSqlString( factory, criteria.PersistentClass, Alias, new Hashtable() ), orderByBuilder.ToString(), factory ); PostInstantiate(); *************** *** 80,85 **** while( iter.MoveNext() ) { ! Expression.Expression expr = ( Expression.Expression ) iter.Current; ! TypedValue[ ] tv = expr.GetTypedValues( session.Factory, criteria.PersistentClass ); for( int i = 0; i < tv.Length; i++ ) { --- 81,87 ---- while( iter.MoveNext() ) { ! Expression.ICriterion expr = ( Expression.ICriterion ) iter.Current; ! // TODO: h2.1 SYNCH - the new Hashtable() is a HACK ! TypedValue[ ] tv = expr.GetTypedValues( session.Factory, criteria.PersistentClass, new Hashtable() ); for( int i = 0; i < tv.Length; i++ ) { |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Impl Modified Files: CriteriaImpl.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: CriteriaImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CriteriaImpl.cs 14 Mar 2005 18:52:52 -0000 1.9 --- CriteriaImpl.cs 17 Apr 2005 17:16:06 -0000 1.10 *************** *** 130,134 **** //ADDED this /// <summary></summary> ! public NExpression.Expression Expression { get { return conjunction; } --- 130,134 ---- //ADDED this /// <summary></summary> ! public NExpression.ICriterion Expression { get { return conjunction; } *************** *** 231,235 **** /// <param name="expression"></param> /// <returns></returns> ! public ICriteria Add( NExpression.Expression expression ) { criteria.Add( expression ); --- 231,235 ---- /// <param name="expression"></param> /// <returns></returns> ! public ICriteria Add( NExpression.ICriterion expression ) { criteria.Add( expression ); |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate/Cfg Modified Files: Binder.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Binder.cs 12 Apr 2005 16:16:26 -0000 1.48 --- Binder.cs 17 Apr 2005 17:16:05 -0000 1.49 *************** *** 1016,1020 **** } ! componentType = new ComponentType( model.ComponentClass, names, getters, setters, foundCustomAccessor, types, joinedFetch, cascade, model.ParentProperty, model.IsEmbedded ); } model.Type = componentType; --- 1016,1020 ---- } ! componentType = new ComponentType( model.ComponentClass, names, getters, setters, foundCustomAccessor, types, joinedFetch, cascade, model.ParentProperty ); } model.Type = componentType; |
From: Michael D. <mik...@us...> - 2005-04-17 17:16:13
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10283/NHibernate.Test Modified Files: AssemblyInfo.cs FooBarTest.cs Log Message: Fixed up the QBE portion of NHibernate.Expression. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** FooBarTest.cs 31 Mar 2005 12:42:39 -0000 1.90 --- FooBarTest.cs 17 Apr 2005 17:16:04 -0000 1.91 *************** *** 959,964 **** Assert.IsTrue( list.Count==1 && list[0]==f ); ! Expression.Expression andExpression; ! Expression.Expression orExpression; andExpression = Expression.Expression.And( Expression.Expression.Eq( "Integer", f.Integer ), Expression.Expression.Like( "String", f.String ) ); --- 959,964 ---- Assert.IsTrue( list.Count==1 && list[0]==f ); ! Expression.ICriterion andExpression; ! Expression.ICriterion orExpression; andExpression = Expression.Expression.And( Expression.Expression.Eq( "Integer", f.Integer ), Expression.Expression.Like( "String", f.String ) ); Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/AssemblyInfo.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AssemblyInfo.cs 1 Mar 2005 16:24:41 -0000 1.12 --- AssemblyInfo.cs 17 Apr 2005 17:16:04 -0000 1.13 *************** *** 5,9 **** // <autogenerated> // This code was generated by a tool. ! // Runtime Version: 1.1.4322.2032 // // Changes to this file may cause incorrect behavior and will be lost if --- 5,9 ---- // <autogenerated> // This code was generated by a tool. ! // Runtime Version: 1.1.4322.573 // // Changes to this file may cause incorrect behavior and will be lost if |
From: Paul H. <pha...@us...> - 2005-04-15 10:23:08
|
Update of /cvsroot/nhibernate/nhibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26835/nhibernate Modified Files: releasenotes.txt Log Message: Improved memory consumption of Configuration, smaller footprint and releases objects faster. Index: releasenotes.txt =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/releasenotes.txt,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** releasenotes.txt 31 Mar 2005 12:40:22 -0000 1.30 --- releasenotes.txt 15 Apr 2005 10:22:56 -0000 1.31 *************** *** 16,19 **** --- 16,20 ---- - Added SaveOrUpdateCopy which allows synchronisation for detached objects - Added "foreign-key" attribute to many-to-one, one-to-one, many-to-many, key allowing a different column to be the foreign key target + - Improved memory consumption of Configuration, smaller footprint and releases objects faster. Build 0.7.0.0 |
From: Paul H. <pha...@us...> - 2005-04-12 16:17:06
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27129/nhibernate/src/NHibernate/Cfg Modified Files: Binder.cs Configuration.cs Log Message: Refactored to minmize memory utilisation Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Binder.cs 31 Mar 2005 12:41:27 -0000 1.47 --- Binder.cs 12 Apr 2005 16:16:26 -0000 1.48 *************** *** 19,23 **** --- 19,41 ---- private static XmlNamespaceManager nsmgr; + + // Make consts of all of these to avoid interning the strings at run-time private const string nsPrefix = "hbm"; + private const string nsKey = nsPrefix + ":key"; + private const string nsColumn = nsPrefix + ":column"; + private const string nsOneToMany = nsPrefix + ":one-to-many"; + private const string nsParam = nsPrefix + ":param"; + private const string nsIndex = nsPrefix + ":index"; + private const string nsGenerator = nsPrefix + ":generator"; + private const string nsCollectionId = nsPrefix + ":collection-id"; + private const string nsClass = nsPrefix + ":class"; + private const string nsSubclass = nsPrefix + ":subclass"; + private const string nsJoinedSubclass = nsPrefix + ":joined-subclass"; + private const string nsQuery = nsPrefix + ":query"; + private const string nsSqlQuery = nsPrefix + ":sql-query"; + private const string nsReturn = nsPrefix + ":return"; + private const string nsSynchronize = nsPrefix + ":synchronize"; + private const string nsImport = nsPrefix + ":import"; + internal static Dialect.Dialect dialect; *************** *** 34,70 **** return null; } ! // TODO: Make this stronger, assumes stuff about presence of culture, public key etc ! // Split off the assembly reference if it's present ! string[] parts = className.Split( ',' ); ! string name = parts[ 0 ]; ! if ( name.IndexOf( '.' ) == -1 && mapping.DefaultNamespace != null ) { ! // No namespace - use the default ! name = mapping.DefaultNamespace + "." + name; } ! ! string assm; ! if ( parts.Length == 1 ) { ! if ( mapping.DefaultAssembly == null ) { ! // No default, let it try and find it automatically ! assm = ""; } ! else { ! // No assembly - use the default ! assm = ", " + mapping.DefaultAssembly; } } - else - { - // Use the assembly reference provided - assm = ", " + parts[ 1 ]; - } - - // Rebuild the name - return name + assm; } --- 52,86 ---- return null; } + int commaPosn = className.IndexOf( ',' ); + int dotPosn = className.IndexOf( '.' ); ! // Check for namespace; ok to have a dot after the comma as it's part of the assembly name ! bool needNamespace = ( dotPosn == -1 || ( commaPosn > -1 && dotPosn > commaPosn ) ) && mapping.DefaultNamespace != null ; ! // Add if we don't have any commas and a default exists ! bool needAssembly = commaPosn == -1 && mapping.DefaultAssembly != null; ! ! if ( needNamespace == false && needAssembly == false ) { ! return className; } ! else { ! StringBuilder sb = new StringBuilder(); ! ! if ( needNamespace ) { ! sb.Append( mapping.DefaultNamespace ); ! sb.Append( "." ); } ! ! sb.Append( className ); ! ! if ( needAssembly ) { ! sb.Append( ", "); ! sb.Append( mapping.DefaultAssembly ); } + return sb.ToString(); } } *************** *** 226,230 **** log.Info("Mapping joined-subclass: " + model.Name + " -> " + model.Table.Name ); ! XmlNode keyNode = node.SelectSingleNode(nsPrefix + ":key", nsmgr); SimpleValue key = new SimpleValue(mytable); model.Key = key; --- 242,246 ---- log.Info("Mapping joined-subclass: " + model.Name + " -> " + model.Table.Name ); ! XmlNode keyNode = node.SelectSingleNode( nsKey, nsmgr ); SimpleValue key = new SimpleValue(mytable); model.Key = key; *************** *** 387,391 **** { int count=0; ! foreach(XmlNode subnode in node.SelectNodes(nsPrefix + ":column", nsmgr)) { Table table = model.Table; --- 403,407 ---- { int count=0; ! foreach(XmlNode subnode in node.SelectNodes( nsColumn, nsmgr )) { Table table = model.Table; *************** *** 596,600 **** InitOuterJoinFetchSetting( node, model ); ! XmlNode oneToManyNode = node.SelectSingleNode(nsPrefix + ":one-to-many", nsmgr); if ( oneToManyNode!=null ) { --- 612,616 ---- InitOuterJoinFetchSetting( node, model ); ! XmlNode oneToManyNode = node.SelectSingleNode( nsOneToMany, nsmgr ); if ( oneToManyNode!=null ) { *************** *** 1070,1078 **** } ! private static void MakeIdentifier(XmlNode node, SimpleValue model, Mappings mappings) { //GENERATOR ! XmlNode subnode = node.SelectSingleNode(nsPrefix + ":generator", nsmgr); if ( subnode!=null ) { --- 1086,1094 ---- } ! private static void MakeIdentifier( XmlNode node, SimpleValue model, Mappings mappings ) { //GENERATOR ! XmlNode subnode = node.SelectSingleNode( nsGenerator, nsmgr ); if ( subnode!=null ) { *************** *** 1097,1102 **** } ! //foreach(XmlNode childNode in subnode.SelectNodes("param")) { ! foreach(XmlNode childNode in subnode.SelectNodes(nsPrefix + ":param", nsmgr)) { parms.Add( --- 1113,1117 ---- } ! foreach( XmlNode childNode in subnode.SelectNodes( nsParam, nsmgr )) { parms.Add( *************** *** 1204,1208 **** BindCollectionSecondPass(node, model, classes, mappings); ! XmlNode subnode = node.SelectSingleNode(nsPrefix + ":index", nsmgr); IntegerValue iv = new IntegerValue( model.CollectionTable ); BindIntegerValue( subnode, iv, IndexedCollection.DefaultIndexColumnName, model.IsOneToMany, mappings ); --- 1219,1223 ---- BindCollectionSecondPass(node, model, classes, mappings); ! XmlNode subnode = node.SelectSingleNode( nsIndex, nsmgr); IntegerValue iv = new IntegerValue( model.CollectionTable ); BindIntegerValue( subnode, iv, IndexedCollection.DefaultIndexColumnName, model.IsOneToMany, mappings ); *************** *** 1214,1218 **** BindCollectionSecondPass(node, model, persitentClasses, mappings); ! XmlNode subnode = node.SelectSingleNode( nsPrefix + ":collection-id", nsmgr ); SimpleValue id = new SimpleValue( model.CollectionTable ); BindSimpleValue( subnode, id, false, IdentifierCollection.DefaultIdentifierColumnName, mappings); --- 1229,1233 ---- BindCollectionSecondPass(node, model, persitentClasses, mappings); ! XmlNode subnode = node.SelectSingleNode( nsCollectionId, nsmgr ); SimpleValue id = new SimpleValue( model.CollectionTable ); BindSimpleValue( subnode, id, false, IdentifierCollection.DefaultIdentifierColumnName, mappings); *************** *** 1391,1395 **** nsmgr.AddNamespace( nsPrefix, Configuration.MappingSchemaXMLNS ); ! foreach(XmlNode n in hmNode.SelectNodes( nsPrefix + ":class", nsmgr ) ) { RootClass rootclass = new RootClass(); --- 1406,1410 ---- nsmgr.AddNamespace( nsPrefix, Configuration.MappingSchemaXMLNS ); ! foreach(XmlNode n in hmNode.SelectNodes( nsClass, nsmgr ) ) { RootClass rootclass = new RootClass(); *************** *** 1398,1402 **** } ! foreach(XmlNode n in hmNode.SelectNodes( nsPrefix + ":subclass", nsmgr ) ) { PersistentClass superModel = GetSuperclass( model, n ); --- 1413,1417 ---- } ! foreach(XmlNode n in hmNode.SelectNodes( nsSubclass, nsmgr ) ) { PersistentClass superModel = GetSuperclass( model, n ); *************** *** 1404,1408 **** } ! foreach(XmlNode n in hmNode.SelectNodes( nsPrefix + ":joined-subclass", nsmgr ) ) { PersistentClass superModel = GetSuperclass(model, n); --- 1419,1423 ---- } ! foreach(XmlNode n in hmNode.SelectNodes( nsJoinedSubclass, nsmgr ) ) { PersistentClass superModel = GetSuperclass(model, n); *************** *** 1410,1414 **** } ! foreach(XmlNode n in hmNode.SelectNodes( nsPrefix + ":query", nsmgr ) ) { string qname = n.Attributes["name"].Value; --- 1425,1429 ---- } ! foreach(XmlNode n in hmNode.SelectNodes( nsQuery, nsmgr ) ) { string qname = n.Attributes["name"].Value; *************** *** 1418,1427 **** } ! foreach(XmlNode n in hmNode.SelectNodes( nsPrefix + ":sql-query", nsmgr ) ) { string qname = n.Attributes["name"].Value; NamedSQLQuery namedQuery = new NamedSQLQuery( n.InnerText ); ! foreach(XmlNode returns in n.SelectNodes( nsPrefix + ":return", nsmgr ) ) { string alias = returns.Attributes["alias"].Value; --- 1433,1442 ---- } ! foreach(XmlNode n in hmNode.SelectNodes( nsSqlQuery, nsmgr ) ) { string qname = n.Attributes["name"].Value; NamedSQLQuery namedQuery = new NamedSQLQuery( n.InnerText ); ! foreach(XmlNode returns in n.SelectNodes( nsReturn, nsmgr ) ) { string alias = returns.Attributes["alias"].Value; *************** *** 1439,1443 **** } ! foreach( XmlNode table in n.SelectNodes( nsPrefix + ":synchronise", nsmgr ) ) { namedQuery.AddSynchronizedTable( table.Attributes["table"].Value ); --- 1454,1458 ---- } ! foreach( XmlNode table in n.SelectNodes( nsSynchronize, nsmgr ) ) { namedQuery.AddSynchronizedTable( table.Attributes["table"].Value ); *************** *** 1448,1452 **** } ! foreach(XmlNode n in hmNode.SelectNodes(nsPrefix + ":import", nsmgr) ) { string className = FullClassName( n.Attributes["class"].Value, model ); --- 1463,1467 ---- } ! foreach(XmlNode n in hmNode.SelectNodes( nsImport, nsmgr) ) { string className = FullClassName( n.Attributes["class"].Value, model ); Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Configuration.cs 31 Mar 2005 12:41:27 -0000 1.37 --- Configuration.cs 12 Apr 2005 16:16:26 -0000 1.38 *************** *** 30,51 **** /// </para> /// </remarks> ! public class Configuration : IMapping { ! private Hashtable classes = new Hashtable(); ! private Hashtable imports = new Hashtable(); ! private Hashtable collections = new Hashtable(); ! private Hashtable tables = new Hashtable(); ! private Hashtable namedQueries = new Hashtable(); ! private Hashtable namedSqlQueries = new Hashtable(); ! private ArrayList secondPasses = new ArrayList(); ! private ArrayList propertyReferences = new ArrayList(); ! private IInterceptor interceptor = emptyInterceptor; ! private IDictionary properties = Environment.Properties; ! private IDictionary caches = new Hashtable(); private INamingStrategy namingStrategy = DefaultNamingStrategy.Instance; ! private XmlSchema mappingSchema; ! private XmlSchema cfgSchema; private static readonly ILog log = LogManager.GetLogger( typeof( Configuration ) ); --- 30,51 ---- /// </para> /// </remarks> ! public sealed class Configuration : IMapping { ! private Hashtable classes; ! private Hashtable imports; ! private Hashtable collections; ! private Hashtable tables; ! private Hashtable namedQueries; ! private Hashtable namedSqlQueries; ! private ArrayList secondPasses; ! private ArrayList propertyReferences; ! private IInterceptor interceptor; ! private IDictionary properties; ! private IDictionary caches; private INamingStrategy namingStrategy = DefaultNamingStrategy.Instance; ! private XmlSchemaCollection mappingSchemaCollection; ! private XmlSchemaCollection cfgSchemaCollection; private static readonly ILog log = LogManager.GetLogger( typeof( Configuration ) ); *************** *** 100,111 **** private const string CfgSchemaResource = "NHibernate.nhibernate-configuration-2.0.xsd"; private const string CfgNamespacePrefix = "cfg"; - private static XmlNamespaceManager CfgNamespaceMgr; /// <summary> /// Clear the internal state of the <see cref="Configuration"/> object. /// </summary> ! protected void Reset() { classes = new Hashtable(); collections = new Hashtable(); tables = new Hashtable(); --- 100,112 ---- private const string CfgSchemaResource = "NHibernate.nhibernate-configuration-2.0.xsd"; private const string CfgNamespacePrefix = "cfg"; /// <summary> /// Clear the internal state of the <see cref="Configuration"/> object. /// </summary> ! //protected void Reset() ! private void Reset() { classes = new Hashtable(); + imports = new Hashtable(); collections = new Hashtable(); tables = new Hashtable(); *************** *** 113,118 **** --- 114,121 ---- namedSqlQueries = new Hashtable(); secondPasses = new ArrayList(); + propertyReferences = new ArrayList(); interceptor = emptyInterceptor; properties = Environment.Properties; + caches = new Hashtable(); mapping = new Mapping( classes ); } *************** *** 124,129 **** { Reset(); ! mappingSchema = XmlSchema.Read( Assembly.GetExecutingAssembly().GetManifestResourceStream( MappingSchemaResource ), null ); ! cfgSchema = XmlSchema.Read( Assembly.GetExecutingAssembly().GetManifestResourceStream( CfgSchemaResource ), null ); } --- 127,162 ---- { Reset(); ! } ! ! /// <summary></summary> ! /// <remarks>Allocate on first use as we are expensive in time/space</remarks> ! private XmlSchemaCollection MappingSchemaCollection ! { ! get ! { ! if ( mappingSchemaCollection == null ) ! { ! mappingSchemaCollection = new XmlSchemaCollection(); ! mappingSchemaCollection.Add( XmlSchema.Read( Assembly.GetExecutingAssembly().GetManifestResourceStream( MappingSchemaResource ), null ) ); ! } ! return mappingSchemaCollection; ! } ! set { mappingSchemaCollection = value; } ! } ! ! /// <summary></summary> ! /// <remarks>Allocate on first use as we are expensive in time/space</remarks> ! private XmlSchemaCollection CfgSchemaCollection ! { ! get ! { ! if ( cfgSchemaCollection == null ) ! { ! cfgSchemaCollection = new XmlSchemaCollection(); ! cfgSchemaCollection.Add( XmlSchema.Read( Assembly.GetExecutingAssembly().GetManifestResourceStream( CfgSchemaResource ), null ) ); ! } ! return cfgSchemaCollection; ! } ! set { cfgSchemaCollection = value; } } *************** *** 271,275 **** /// </p> /// </remarks> ! public Configuration AddAssembly(Assembly assembly, bool skipOrdering) { IList resources = null; --- 304,308 ---- /// </p> /// </remarks> ! public Configuration AddAssembly( Assembly assembly, bool skipOrdering ) { IList resources = null; *************** *** 474,478 **** /// <summary> ! /// Adds the Mappings in the XmlReader after validating it against the /// nhibernate-mapping-2.0 schema. /// </summary> --- 507,511 ---- /// <summary> ! /// Adds the Mappings in the XmlReader after validating optionally it against the /// nhibernate-mapping-2.0 schema. /// </summary> *************** *** 481,493 **** public Configuration AddXmlReader( XmlReader hbmReader ) { - XmlValidatingReader validatingReader = null; try { validatingReader = new XmlValidatingReader( hbmReader ); validatingReader.ValidationType = ValidationType.Schema; ! validatingReader.Schemas.Add( mappingSchema ); - XmlDocument hbmDocument = new XmlDocument(); hbmDocument.Load( validatingReader ); Add( hbmDocument ); --- 514,526 ---- public Configuration AddXmlReader( XmlReader hbmReader ) { XmlValidatingReader validatingReader = null; try { + XmlDocument hbmDocument = new XmlDocument(); validatingReader = new XmlValidatingReader( hbmReader ); + validatingReader.ValidationEventHandler += new ValidationEventHandler( ValidationHandler ); validatingReader.ValidationType = ValidationType.Schema; ! validatingReader.Schemas.Add( MappingSchemaCollection ); hbmDocument.Load( validatingReader ); Add( hbmDocument ); *************** *** 504,507 **** --- 537,545 ---- } + private static void ValidationHandler( object o, ValidationEventArgs args ) + { + throw args.Exception; + } + /// <summary> /// Adds the Mappings from a <c>String</c> *************** *** 819,822 **** --- 857,864 ---- ConfigureCaches( settings ); + // Ok, don't need schemas anymore, so free them + MappingSchemaCollection = null; + CfgSchemaCollection = null; + return new SessionFactoryImpl( this, settings ); } *************** *** 839,843 **** /// </summary> /// <returns>A <see cref="Settings"/> object initialized from the settings properties.</returns> ! protected Settings BuildSettings() { return SettingsFactory.BuildSettings( properties ); --- 881,886 ---- /// </summary> /// <returns>A <see cref="Settings"/> object initialized from the settings properties.</returns> ! //protected Settings BuildSettings() ! private Settings BuildSettings() { return SettingsFactory.BuildSettings( properties ); *************** *** 901,904 **** --- 944,958 ---- /// <summary> + /// Set a custom naming strategy + /// </summary> + /// <param name="namingStrategy">the NamingStrategy to set</param> + /// <returns></returns> + public Configuration SetNamingStrategy( INamingStrategy namingStrategy ) + { + this.namingStrategy = namingStrategy; + return this; + } + + /// <summary> /// Gets the value of the configuration property. /// </summary> *************** *** 910,914 **** } ! private void AddProperties( XmlNode parent ) { foreach( XmlNode node in parent.SelectNodes( CfgNamespacePrefix + ":property", CfgNamespaceMgr ) ) --- 964,968 ---- } ! private void AddProperties( XmlNode parent, XmlNamespaceManager CfgNamespaceMgr ) { foreach( XmlNode node in parent.SelectNodes( CfgNamespacePrefix + ":property", CfgNamespaceMgr ) ) *************** *** 963,977 **** /// <summary> - /// Set a custom naming strategy - /// </summary> - /// <param name="namingStrategy">the NamingStrategy to set</param> - /// <returns></returns> - public Configuration SetNamingStrategy( INamingStrategy namingStrategy ) - { - this.namingStrategy = namingStrategy; - return this; - } - - /// <summary> /// Configure NHibernate using a resource contained in an Assembly. /// </summary> --- 1017,1020 ---- *************** *** 1027,1030 **** --- 1070,1074 ---- XmlDocument doc = new XmlDocument(); XmlValidatingReader validatingReader = null; + XmlNamespaceManager cfgNamespaceMgr; try *************** *** 1032,1044 **** validatingReader = new XmlValidatingReader( reader ); validatingReader.ValidationType = ValidationType.Schema; ! validatingReader.Schemas.Add( cfgSchema ); doc.Load( validatingReader ); ! CfgNamespaceMgr = new XmlNamespaceManager( doc.NameTable ); // note that the prefix has absolutely nothing to do with what the user // selects as their prefix in the document. It is the prefix we use to // build the XPath and the nsmgr takes care of translating our prefix into // the user defined prefix... ! CfgNamespaceMgr.AddNamespace( CfgNamespacePrefix, Configuration.CfgSchemaXMLNS ); } catch( Exception e ) --- 1076,1088 ---- validatingReader = new XmlValidatingReader( reader ); validatingReader.ValidationType = ValidationType.Schema; ! validatingReader.Schemas.Add( CfgSchemaCollection ); doc.Load( validatingReader ); ! cfgNamespaceMgr = new XmlNamespaceManager( doc.NameTable ); // note that the prefix has absolutely nothing to do with what the user // selects as their prefix in the document. It is the prefix we use to // build the XPath and the nsmgr takes care of translating our prefix into // the user defined prefix... ! cfgNamespaceMgr.AddNamespace( CfgNamespacePrefix, Configuration.CfgSchemaXMLNS ); } catch( Exception e ) *************** *** 1055,1059 **** } ! XmlNode sfNode = doc.DocumentElement.SelectSingleNode( "//" + CfgNamespacePrefix + ":session-factory", CfgNamespaceMgr ); XmlAttribute name = sfNode.Attributes[ "name" ]; if( name != null ) --- 1099,1103 ---- } ! XmlNode sfNode = doc.DocumentElement.SelectSingleNode( "//" + CfgNamespacePrefix + ":session-factory", cfgNamespaceMgr ); XmlAttribute name = sfNode.Attributes[ "name" ]; if( name != null ) *************** *** 1061,1065 **** properties[ Environment.SessionFactoryName ] = name.Value; } ! AddProperties( sfNode ); foreach( XmlNode mapElement in sfNode.ChildNodes ) --- 1105,1109 ---- properties[ Environment.SessionFactoryName ] = name.Value; } ! AddProperties( sfNode, cfgNamespaceMgr ); foreach( XmlNode mapElement in sfNode.ChildNodes ) *************** *** 1106,1111 **** /// </summary> /// <param name="settings"></param> ! protected void ConfigureCaches( Settings settings ) ! { log.Info( "instantiating and configuring caches" ); --- 1150,1156 ---- /// </summary> /// <param name="settings"></param> ! //protected void ConfigureCaches( Settings settings ) ! private void ConfigureCaches( Settings settings ) ! { log.Info( "instantiating and configuring caches" ); |
From: Michael D. <mik...@us...> - 2005-04-12 12:52:40
|
Update of /cvsroot/nhibernate/nhibernate/doc/reference/en/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4748/reference/en/modules Modified Files: persistent_classes.xml Log Message: more work on doco Index: persistent_classes.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/doc/reference/en/modules/persistent_classes.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** persistent_classes.xml 12 Apr 2005 02:45:38 -0000 1.2 --- persistent_classes.xml 12 Apr 2005 12:52:09 -0000 1.3 *************** *** 11,26 **** <title>Persistent Classes</title> ! <para></para> <sect1 id="persistent-classes-poco"> <title>A simple POCO example</title> ! <para></para> <sect2 id="persistent-classes-poco-accessors"> <title>Declare getters and setters for persistent fields (optional)</title> ! <para></para> </sect2> <sect2 id="persistent-classes-poco-constructor"> <title>Implement a default constructor</title> ! <para></para> </sect2> <sect2 id="persistent-classes-poco-identifier"> --- 11,115 ---- <title>Persistent Classes</title> ! <para> ! Persistent classes are classes in an application that implement the entitites ! of the business problem (ie - Customer and Order in an eCommerce application). ! Persistent classes have, as the name implies, transient and also persistent ! instances stored in the database. ! </para> ! <para> ! NHibernate works best if these classes follow some simple rules, also known ! as the Plain Old CLR Object (POCO) programming model. ! </para> <sect1 id="persistent-classes-poco"> <title>A simple POCO example</title> ! ! <para> ! A simple example using a class to represent a Cat. ! </para> ! <programlisting><![CDATA[public class Cat ! { ! private long _id; // identifier ! private string _name; ! private DateTime _birthdate; ! private Cat _mate; ! private Set _kittens; ! private Color _color; ! private char _sex; ! private float _weight; ! ! public long Id ! { ! get { return _id; } ! set { _id = value; } ! } ! ! public string Name ! { ! get { return _name; } ! set { _name = value; } ! } ! ! public DateTime Birthdate ! { ! get { return _birthdate; } ! set { _birthdate = value; } ! } ! ! public Cat Mate ! { ! get { return _mate; } ! set { _mate = value; } ! } ! ! public Set Kittens ! { ! get { return _kittens; } ! set { _kittens = value; } ! } ! ! public Color Color ! { ! get { return _color; } ! set { _color = value; } ! } ! ! public char Sex ! { ! get { return _sex; } ! set { _sex = value; } ! } ! ! public float Weight ! { ! get { return _weight; } ! set { _weight = value; } ! } ! ! } ! ]]></programlisting> ! <para> ! There are four main rules to follow here: ! </para> <sect2 id="persistent-classes-poco-accessors"> <title>Declare getters and setters for persistent fields (optional)</title> ! <para> ! <literal>Cat</literal> declares property getters and setters for all its persistent fields. ! It is good practice to use getters and setters instead of direct access to fields. However, ! it is possible to use NHibernate with fields instead of properties. ! </para> ! <para> ! Properties do <emphasis>not</emphasis> need to be declared as public - NHibernate can ! persist a property with a default, <literal>procted</literal>, <literal>internal</literal>, ! or <literal>private</literal> visibility. ! </para> </sect2> <sect2 id="persistent-classes-poco-constructor"> <title>Implement a default constructor</title> ! <para> ! <literal>Cat</literal> has an implicit default (no argument) constructor. All ! persistent classes must have a default construction (which may be non-public) so ! NHibernate can instantiate them using <literal>Constructor.Invoke()</literal>. ! </para> </sect2> <sect2 id="persistent-classes-poco-identifier"> |
From: Michael D. <mik...@us...> - 2005-04-12 12:51:42
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3896/NHibernate.Test Modified Files: NHibernate.Test-1.1.csproj Log Message: test fixtures for the code that is going into the documentation. Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** NHibernate.Test-1.1.csproj 9 Apr 2005 12:51:38 -0000 1.70 --- NHibernate.Test-1.1.csproj 12 Apr 2005 12:51:13 -0000 1.71 *************** *** 523,526 **** --- 523,569 ---- /> <File + RelPath = "NHSpecificTest\Docs\Associations\BiM21\Address.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecificTest\Docs\Associations\BiM21\Fixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecificTest\Docs\Associations\BiM21\Mappings.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "NHSpecificTest\Docs\Associations\BiM21\Person.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecificTest\Docs\ExampleParentChild\Child.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecificTest\Docs\ExampleParentChild\Mappings.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "NHSpecificTest\Docs\ExampleParentChild\Parent.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecificTest\Docs\ExampleParentChild\UpdateFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecificTest\Docs\PersistentClasses\Cat.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "PropertyTest\BasicSetterExceptionFixture.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2005-04-12 12:51:42
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/PersistentClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3896/NHibernate.Test/NHSpecificTest/Docs/PersistentClasses Added Files: Cat.cs Log Message: test fixtures for the code that is going into the documentation. --- NEW FILE: Cat.cs --- using System; using Iesi.Collections; namespace NHibernate.Test.NHSpecificTest.Docs.PersistentClasses { public class Cat { private long _id; // identifier private string _name; private DateTime _birthdate; private Cat _mate; private Set _kittens; private Color _color; private char _sex; private float _weight; public long Id { get { return _id; } set { _id = value; } } public string Name { get { return _name; } set { _name = value; } } public DateTime Birthdate { get { return _birthdate; } set { _birthdate = value; } } public Cat Mate { get { return _mate; } set { _mate = value; } } public Set Kittens { get { return _kittens; } set { _kittens = value; } } public Color Color { get { return _color; } set { _color = value; } } public char Sex { get { return _sex; } set { _sex = value; } } public float Weight { get { return _weight; } set { _weight = value; } } } public enum Color { Black, White, Mix } } |
From: Michael D. <mik...@us...> - 2005-04-12 12:51:41
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/ExampleParentChild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3896/NHibernate.Test/NHSpecificTest/Docs/ExampleParentChild Added Files: Child.cs Mappings.hbm.xml Parent.cs UpdateFixture.cs Log Message: test fixtures for the code that is going into the documentation. --- NEW FILE: Parent.cs --- using System; using Iesi.Collections; namespace NHibernate.Test.NHSpecificTest.Docs.ExampleParentChild { public class Parent { private long _id; private Iesi.Collections.ISet _children; public Parent() { } public long Id { get { return _id; } set { _id = value; } } public ISet Children { get { return _children; } set { _children = value; } } public void AddChild(Child c) { if( this.Children==null ) { this.Children = new HashedSet(); } this.Children.Add( c ); c.Parent = this; } } } --- NEW FILE: UpdateFixture.cs --- using System; using NHibernate; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.Docs.ExampleParentChild { [TestFixture] public class UpdateFixture : TestCase { #region NUnit.Framework.TestFixture Members [TestFixtureSetUp] public void TestFixtureSetUp() { ExportSchema( new string[] { "NHSpecificTest.Docs.ExampleParentChild.Mappings.hbm.xml"}, true, "NHibernate.Test" ); } [SetUp] public void SetUp() { // there are test in here where we don't need to resetup the // tables - so only set the tables up once } [TearDown] public override void TearDown() { //base.TearDown (); } [TestFixtureTearDown] public void TestFixtureTearDown() { // only do this at the end of the test fixture base.TearDown(); } #endregion [Test] public void Update() { ISession session1 = sessions.OpenSession(); Parent parent1 = new Parent(); Child child1 = new Child(); parent1.AddChild( child1 ); long pId = (long)session1.Save( parent1 ); long cId = (long)session1.Save( child1 ); session1.Flush(); session1.Close(); ISession session2 = sessions.OpenSession(); Parent parent = session2.Load( typeof( Parent ), pId ) as Parent; Child child = session2.Load( typeof( Child ), cId ) as Child; session2.Close(); parent.AddChild( child ); Child newChild = new Child(); parent.AddChild( newChild ); ISession session = sessions.OpenSession(); session.Update( parent ); session.Flush(); session.Close(); } } } --- NEW FILE: Child.cs --- using System; namespace NHibernate.Test.NHSpecificTest.Docs.ExampleParentChild { public class Child { private long _id; private Parent _parent; public Child() { } public long Id { get { return _id; } set { _id = value; } } public Parent Parent { get { return _parent; } set { _parent = value; } } } } --- NEW FILE: Mappings.hbm.xml --- (This appears to be a binary file; contents omitted.) |
From: Michael D. <mik...@us...> - 2005-04-12 12:51:41
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3896/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21 Added Files: Address.cs Fixture.cs Mappings.hbm.xml Person.cs Log Message: test fixtures for the code that is going into the documentation. --- NEW FILE: Mappings.hbm.xml --- <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="NHibernate.Test.NHSpecificTest.Docs.Associations.BiM21" assembly="NHibernate.Test" > <class name="Person"> <id name="Id" column="personId"> <generator class="native" /> </id> <many-to-one name="Address" column="addressId" not-null="true" /> </class> <class name="Address"> <id name="Id" column="addressId" unsaved-value="0"> <generator class="native" /> </id> <set name="People" inverse="true"> <key column="addressId" /> <one-to-many class="Person" /> </set> </class> </hibernate-mapping> --- NEW FILE: Address.cs --- using System; using Iesi.Collections; namespace NHibernate.Test.NHSpecificTest.Docs.Associations.BiM21 { public class Address { private Iesi.Collections.ISet _people; private int _id; public Address() { } public int Id { get { return _id; } set { _id = value; } } public ISet People { get { return _people; } set { _people = value; } } } } --- NEW FILE: Fixture.cs --- using System; using NHibernate; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.Docs.Associations.BiM21 { [TestFixture] public class Fixture : TestCase { #region NUnit.Framework.TestFixture Members [TestFixtureSetUp] public void TestFixtureSetUp() { ExportSchema( new string[] { "NHSpecificTest.Docs.Associations.BiM21.Mappings.hbm.xml"}, true, "NHibernate.Test" ); } [SetUp] public void SetUp() { // there are test in here where we don't need to resetup the // tables - so only set the tables up once } [TearDown] public override void TearDown() { //base.TearDown (); } [TestFixtureTearDown] public void TestFixtureTearDown() { // only do this at the end of the test fixture base.TearDown(); } #endregion [Test] public void TestCorrectUse() { ISession session = sessions.OpenSession(); Person fred = new Person(); Person wilma = new Person(); Address flinstoneWay = new Address(); fred.Address = flinstoneWay; wilma.Address = flinstoneWay; session.Save( flinstoneWay ); session.Save( fred ); session.Save( wilma ); session.Close(); } [Test] [ExpectedException( typeof(ADOException) )] public void TestErrorUsage() { using( ISession session = sessions.OpenSession() ) { Person fred = new Person(); Person wilma = new Person(); Address flinstoneWay = new Address(); fred.Address = flinstoneWay; wilma.Address = flinstoneWay; session.Save( fred ); } } } } --- NEW FILE: Person.cs --- using System; namespace NHibernate.Test.NHSpecificTest.Docs.Associations.BiM21 { public class Person { private int _id; private Address _address; public Person() { } public int Id { get { return _id; } set { _id = value; } } public Address Address { get { return _address; } set { _address = value; } } } } |
From: Michael D. <mik...@us...> - 2005-04-12 12:37:09
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28311/BiM21 Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations/BiM21 added to the repository |
From: Michael D. <mik...@us...> - 2005-04-12 12:36:51
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/PersistentClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28083/PersistentClasses Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/PersistentClasses added to the repository |
From: Michael D. <mik...@us...> - 2005-04-12 12:36:28
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/ExampleParentChild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28021/ExampleParentChild Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/ExampleParentChild added to the repository |
From: Michael D. <mik...@us...> - 2005-04-12 12:34:04
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26566/Associations Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs/Associations added to the repository |
From: Michael D. <mik...@us...> - 2005-04-12 12:11:17
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14762/Docs Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Docs added to the repository |
From: Michael D. <mik...@us...> - 2005-04-12 02:45:50
|
Update of /cvsroot/nhibernate/nhibernate/doc/reference/en/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13578/nhibernate/doc/reference/en/modules Modified Files: example_parentchild.xml persistent_classes.xml Log Message: more work on doco Index: example_parentchild.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/doc/reference/en/modules/example_parentchild.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** example_parentchild.xml 11 Apr 2005 03:45:37 -0000 1.2 --- example_parentchild.xml 12 Apr 2005 02:45:38 -0000 1.3 *************** *** 270,274 **** <sect1 id="example-parentchild-update"> <title>Using cascading <literal>update()</literal></title> ! <para></para> </sect1> </chapter> \ No newline at end of file --- 270,321 ---- <sect1 id="example-parentchild-update"> <title>Using cascading <literal>update()</literal></title> ! <para> ! Suppose we loaded up a <literal>Parent</literal> in one <literal>ISession</literal>, mode some changes in a UI ! action and wish to persist these changes in a new ISession (by calling <literal>Update()</literal>). The ! <literal>Parent</literal> will contain a collection of children and, since cascading update is enabled, NHibernate ! needs to know which children are newly instantiated and which represent existing rows in the database. Lets assume ! that both <literal>Parent</literal> and <literal>Child</literal> have (synthetic) identifier properties of type ! <literal>System.Int32</literal>. NHibernate will use the identifier property value to determine which of the ! children are new. ! <!-- TODO: add comments about version/timestamp when the build is released --> ! </para> ! <para> ! The <literal>unsaved-value</literal> attribute is used to specify the identifier value of a newly instantiated ! instance. <literal>unsaved-value</literal> defaults to "null", which is not a sensible default in the .net with ! ValueTypes, so you need to specify the unsaved-value ! </para> ! <programlisting><![CDATA[<id name="Id" type="Int64" unsaved-value="0" ]]></programlisting> ! <para> ! for the <literal>Child</literal> mapping. <!-- ! TODO: not implemented in production build yet ! (There is also an <literal>unsaved-value</literal> attribute ! for version and timestamp property mappings.)--> ! </para> ! <para> ! The following code will update <literal>parent</literal> and <literal>child</literal> and insert ! <literal>newChild</literal>. ! </para> ! ! <programlisting><![CDATA[//parent and child were both loaded in a previous session ! parent.AddChild( child ); ! Child newChild = new Child(); ! parent.AddChild( newChild ); ! session.Update( parent ); ! session.Flush();]]></programlisting> ! ! <para> ! <!-- TODO: discuss use of unsaved-value with version and timestamp --> ! </para> ! </sect1> ! ! <sect1 id="example-parentchild-conclusion"> ! <title>Conclusion</title> ! <para> ! There is quite a bit to digest here and it might look confusing first time around. However, in practice, it ! all works out quite nicely. Most NHibernate applications use the parent/child pattern in many places. ! </para> ! <para> ! <!-- TODO: describe composite-element --> ! </para> </sect1> </chapter> \ No newline at end of file Index: persistent_classes.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/doc/reference/en/modules/persistent_classes.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** persistent_classes.xml 8 Apr 2005 19:23:35 -0000 1.1 --- persistent_classes.xml 12 Apr 2005 02:45:38 -0000 1.2 *************** *** 0 **** --- 1,55 ---- + <!-- + before committing make sure to comment out the DOCTYPE + It is in here to get intellisense with XMLSpy. The + HomeEdition is a free download. + + --> + <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" + "../../support/docbook-dtd/docbookx.dtd"> + + <chapter id="persistent-classes"> + + <title>Persistent Classes</title> + <para></para> + + <sect1 id="persistent-classes-poco"> + <title>A simple POCO example</title> + <para></para> + <sect2 id="persistent-classes-poco-accessors"> + <title>Declare getters and setters for persistent fields (optional)</title> + <para></para> + </sect2> + <sect2 id="persistent-classes-poco-constructor"> + <title>Implement a default constructor</title> + <para></para> + </sect2> + <sect2 id="persistent-classes-poco-identifier"> + <title>Provide an identifier property (optional)</title> + <para></para> + </sect2> + <sect2 id="persistent-classes-poco-sealed"> + <title>Prefer non-sealed classes (optional)</title> + <para></para> + </sect2> + </sect1> + <sect1 id="persistent-classes-inheritance"> + <title>Implementing inheritence</title> + <para></para> + </sect1> + <sect1 id="persistent-classes-equalshashcode"> + <title>Implementing <literal>Equals()</literal> and <literal>GetHashCode()</literal></title> + <para></para> + </sect1> + <sect1 id="persistent-classes-lifecycle"> + <title>Lifecycle Callbacks</title> + <para></para> + </sect1> + <sect1 id="persistent-classes-validatable"> + <title>Validatable callback</title> + <para></para> + </sect1> + <sect1 id="persistent-classes-attribute"> + <title>Using Attributes instead of XML</title> + <para></para> + </sect1> + </chapter> \ No newline at end of file |