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: <ric...@us...> - 2009-08-25 12:44:38
|
Revision: 4699 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4699&view=rev Author: ricbrown Date: 2009-08-25 12:44:30 +0000 (Tue, 25 Aug 2009) Log Message: ----------- Fix NH-1939 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs branches/2.1.x/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj branches/2.1.x/nhibernate/src/NHibernate/nhibernate-mapping.xsd branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-08-19 19:43:56 UTC (rev 4698) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-08-25 12:44:30 UTC (rev 4699) @@ -2,7 +2,7 @@ /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -83,7 +83,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -110,7 +110,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -128,7 +128,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -193,7 +193,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -207,7 +207,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -372,7 +372,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -386,7 +386,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -413,7 +413,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheUsage { @@ -436,7 +436,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheInclude { @@ -451,7 +451,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -465,7 +465,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -524,7 +524,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOndelete { @@ -539,7 +539,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -565,7 +565,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -586,7 +586,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -618,7 +618,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -632,7 +632,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -770,7 +770,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -784,7 +784,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOuterJoinStrategy { @@ -803,7 +803,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFetchMode { @@ -818,7 +818,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLaziness { @@ -837,7 +837,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmNotFoundMode { @@ -852,7 +852,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -888,7 +888,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1005,7 +1005,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1023,7 +1023,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1041,7 +1041,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPropertyGeneration { @@ -1060,7 +1060,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1121,7 +1121,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1151,7 +1151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1255,7 +1255,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1277,7 +1277,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmRestrictedLaziness { @@ -1292,7 +1292,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1329,7 +1329,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1343,7 +1343,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1373,7 +1373,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCustomSQLCheck { @@ -1392,7 +1392,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionFetchMode { @@ -1411,7 +1411,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1591,7 +1591,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionLazy { @@ -1610,7 +1610,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1829,7 +1829,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1851,7 +1851,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTuplizerEntitymode { @@ -1870,7 +1870,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1920,7 +1920,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1970,7 +1970,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2015,7 +2015,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmUnsavedValueType { @@ -2034,7 +2034,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2086,7 +2086,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2104,7 +2104,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2158,7 +2158,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2185,7 +2185,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2271,7 +2271,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2335,7 +2335,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2520,7 +2520,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2714,7 +2714,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2733,7 +2733,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2752,7 +2752,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2778,7 +2778,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2808,7 +2808,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2843,7 +2843,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2878,7 +2878,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2971,7 +2971,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3113,7 +3113,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayOuterjoin { @@ -3132,7 +3132,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayFetch { @@ -3151,7 +3151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3335,7 +3335,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3518,7 +3518,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3551,7 +3551,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3604,7 +3604,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTimestampUnsavedvalue { @@ -3619,7 +3619,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTimestampSource { @@ -3634,7 +3634,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmVersionGeneration { @@ -3649,7 +3649,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3710,7 +3710,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3762,7 +3762,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3845,7 +3845,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmJoinFetch { @@ -3860,7 +3860,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4021,7 +4021,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4042,7 +4042,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4073,7 +4073,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4095,7 +4095,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4109,7 +4109,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLockMode { @@ -4136,7 +4136,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4175,7 +4175,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4189,7 +4189,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4220,7 +4220,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4238,7 +4238,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4313,7 +4313,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4331,7 +4331,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFlushMode { @@ -4350,7 +4350,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheMode { @@ -4377,7 +4377,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4467,7 +4467,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4606,7 +4606,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4764,7 +4764,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPolymorphismType { @@ -4779,7 +4779,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOptimisticLockMode { @@ -4802,7 +4802,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4816,7 +4816,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4836,7 +4836,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4845,12 +4845,16 @@ public partial class HbmDefinition { /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("param")] + public HbmParam[] param; + + /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string @class; } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4864,7 +4868,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4882,7 +4886,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4908,7 +4912,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4926,7 +4930,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5015,7 +5019,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5037,7 +5041,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.4000")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] Added: branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs 2009-08-25 12:44:30 UTC (rev 4699) @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace NHibernate.Cfg.MappingSchema +{ + partial class HbmDefinition : HbmBase + { + public IDictionary<string, string> FindParameterValues() + { + IDictionary<string, string> parameters = new Dictionary<string, string>(); + + if (param != null) + { + foreach (HbmParam parameter in param) + { + parameters.Add(parameter.name, parameter.GetText()); + } + } + + return parameters; + } + } +} \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs 2009-08-19 19:43:56 UTC (rev 4698) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs 2009-08-25 12:44:30 UTC (rev 4699) @@ -49,6 +49,8 @@ customObject.AddDialectScope(dialectName); } + customObject.SetParameterValues(definitionSchema.FindParameterValues()); + return customObject; } catch (TypeLoadException exception) Modified: branches/2.1.x/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs 2009-08-19 19:43:56 UTC (rev 4698) +++ branches/2.1.x/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs 2009-08-25 12:44:30 UTC (rev 4699) @@ -17,6 +17,7 @@ public abstract class AbstractAuxiliaryDatabaseObject : IAuxiliaryDatabaseObject { private readonly HashedSet<string> dialectScopes; + private IDictionary<string, string> parameters = new Dictionary<string, string>(); protected AbstractAuxiliaryDatabaseObject() { @@ -38,6 +39,11 @@ get { return dialectScopes; } } + public IDictionary<string, string> Parameters + { + get { return parameters; } + } + public bool AppliesToDialect(Dialect.Dialect dialect) { // empty means no scoping @@ -47,6 +53,10 @@ public abstract string SqlCreateString(Dialect.Dialect dialect, IMapping p, string defaultCatalog, string defaultSchema); public abstract string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema); - public void SetParameterValues(IDictionary<string, string> parameters) {} + public void SetParameterValues(IDictionary<string, string> parameters) + { + this.parameters = parameters; + } + } } \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-19 19:43:56 UTC (rev 4698) +++ branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-25 12:44:30 UTC (rev 4699) @@ -458,6 +458,7 @@ <Compile Include="Cache\FakeCache.cs" /> <Compile Include="Cfg\FilterSecondPassArgs.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> + <Compile Include="Cfg\MappingSchema\HbmDefinition.cs" /> <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> Modified: branches/2.1.x/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-08-19 19:43:56 UTC (rev 4698) +++ branches/2.1.x/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-08-25 12:44:30 UTC (rev 4699) @@ -367,6 +367,9 @@ </xs:element> <xs:element name="definition"> <xs:complexType> + <xs:sequence> + <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> <xs:attribute name="class" use="required" type="xs:string" /> </xs:complexType> </xs:element> Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs 2009-08-25 12:44:30 UTC (rev 4699) @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using NHibernate; +using NHibernate.Engine; +using NHibernate.Mapping; + +namespace NHibernate.Test.NHSpecificTest.NH1939 +{ + public class AuxType : AbstractAuxiliaryDatabaseObject + { + + override public string SqlCreateString(Dialect.Dialect dialect, IMapping p, string defaultCatalog, string defaultSchema) + { + return "select '" + Parameters["scriptParameter"] + "'"; + } + + override public string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema) + { + return "select 'drop script'"; + } + + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs 2009-08-25 12:44:30 UTC (rev 4699) @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NHibernate.Tool.hbm2ddl; +using System.Text; +using NHibernate.Cfg; + +namespace NHibernate.Test.NHSpecificTest.NH1939 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + private Configuration cfg; + private StringBuilder schemaBuilder; + + private void AddString(string sqlString) + { + schemaBuilder.Append(sqlString); + } + + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + return (dialect is Dialect.MsSql2000Dialect); + } + + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + cfg = configuration; + } + + [Test] + public void Can_Parameterise_Auxiliary_Database_Objects() + { + schemaBuilder = new StringBuilder(); + + SchemaExport schemaExport = new SchemaExport(cfg); + schemaExport.Execute(AddString, false, false); + + string schema = schemaBuilder.ToString(); + + Assert.That(schema.Contains("select 'drop script'"), Is.True, + "schema drop script not exported"); + + Assert.That(schema.Contains("select 'create script'"), Is.True, + "parameterised schema create script not exported"); + } + + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml 2009-08-25 12:44:30 UTC (rev 4699) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1939"> + + <database-object> + <definition class="AuxType"> + <param name="scriptParameter">create script</param> + </definition> + </database-object> + +</hibernate-mapping> Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-19 19:43:56 UTC (rev 4698) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-25 12:44:30 UTC (rev 4699) @@ -562,6 +562,8 @@ <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1914\Model.cs" /> + <Compile Include="NHSpecificTest\NH1939\AuxType.cs" /> + <Compile Include="NHSpecificTest\NH1939\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1972,6 +1974,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1939\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1927\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-19 19:44:07
|
Revision: 4698 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4698&view=rev Author: davybrion Date: 2009-08-19 19:43:56 +0000 (Wed, 19 Aug 2009) Log Message: ----------- NH-1935 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs Added: trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs 2009-08-19 19:43:56 UTC (rev 4698) @@ -0,0 +1,52 @@ +using System; +using System.Collections; +using System.ServiceModel; + +using NHibernate.Engine; + +namespace NHibernate.Context +{ + /// <summary> + /// Provides a <see cref="ISessionFactory.GetCurrentSession()">current session</see> + /// for the current OperationContext in WCF. Works only during the lifetime of a WCF operation. + /// </summary> + public class WcfOperationSessionContext : MapBasedSessionContext + { + public WcfOperationSessionContext(ISessionFactoryImplementor factory) : base(factory) {} + + private static WcfStateExtension WcfOperationState + { + get + { + var extension = OperationContext.Current.Extensions.Find<WcfStateExtension>(); + + if (extension == null) + { + extension = new WcfStateExtension(); + OperationContext.Current.Extensions.Add(extension); + } + + return extension; + } + } + + protected override IDictionary GetMap() + { + return WcfOperationState.Map; + } + + protected override void SetMap(IDictionary value) + { + WcfOperationState.Map = value; + } + } + + public class WcfStateExtension : IExtension<OperationContext> + { + public IDictionary Map { get; set; } + + // we don't really need implementations for these methods in this case + public void Attach(OperationContext owner) { } + public void Detach(OperationContext owner) { } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-08-18 05:51:57 UTC (rev 4697) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-08-19 19:43:56 UTC (rev 4698) @@ -1154,6 +1154,8 @@ return new WebSessionContext(this); case "managed_web": return new ManagedWebSessionContext(this); + case "wcf_operation": + return new WcfOperationSessionContext(this); } try Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-18 05:51:57 UTC (rev 4697) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-19 19:43:56 UTC (rev 4698) @@ -62,6 +62,9 @@ </Reference> <Reference Include="System.Data" /> <Reference Include="System.Data.OracleClient" /> + <Reference Include="System.ServiceModel"> + <RequiredTargetFramework>3.0</RequiredTargetFramework> + </Reference> <Reference Include="System.Transactions" /> <Reference Include="System.Web" /> <Reference Include="System.Xml" /> @@ -490,6 +493,7 @@ <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> + <Compile Include="Context\WcfOperationSessionContext.cs" /> <Compile Include="Criterion\GroupedProjection.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Criterion\QueryOverFetchBuilder.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-08-18 05:52:11
|
Revision: 4697 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4697&view=rev Author: ayenderahien Date: 2009-08-18 05:51:57 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Will now log the session factory that opened the session Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-08-18 05:19:22 UTC (rev 4696) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-08-18 05:51:57 UTC (rev 4697) @@ -1170,6 +1170,7 @@ } #region NHibernate specific + public string TryGetGuessEntityName(System.Type implementor) { string result; @@ -1177,6 +1178,16 @@ return result; } + public string Name + { + get { return name; } + } + + public string Uuid + { + get { return uuid; } + } + #endregion } } \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-08-18 05:19:22 UTC (rev 4696) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-08-18 05:51:57 UTC (rev 4697) @@ -226,7 +226,8 @@ if (log.IsDebugEnabled) { - log.Debug(string.Format("[session-id={0}] opened session at timestamp:{1}", SessionId, timestamp)); + log.DebugFormat("[session-id={0}] opened session at timestamp: {1}, for session factory: [{2}/{3}]", + SessionId, timestamp, factory.Name, factory.Uuid); } CheckAndUpdateSessionStatus(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-08-18 05:19:30
|
Revision: 4696 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4696&view=rev Author: ayenderahien Date: 2009-08-18 05:19:22 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Minor, removing comments that no longer make sense Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs 2009-08-17 20:50:37 UTC (rev 4695) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionFactoryObjectFactory.cs 2009-08-18 05:19:22 UTC (rev 4696) @@ -17,17 +17,11 @@ /// you are serializing in the same AppDomain then there will be no problem because the uid will /// be in this object. /// </para> - /// <para> - /// TODO: verify that the AppDomain statements are correct. - /// </para> /// </remarks> public static class SessionFactoryObjectFactory { - // to stop this class from being unloaded - this is a comment - // from h2.0.3 - is this applicable to .net also??? private static readonly ILog log; - // in h2.0.3 these use a class called "FastHashMap" private static readonly IDictionary<string, ISessionFactory> Instances = new Dictionary<string, ISessionFactory>(); private static readonly IDictionary<string, ISessionFactory> NamedInstances = new Dictionary<string, ISessionFactory>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-17 20:50:44
|
Revision: 4695 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4695&view=rev Author: ricbrown Date: 2009-08-17 20:50:37 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Merge r4694 (Fix NH-1911) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs 2009-08-17 20:40:40 UTC (rev 4694) +++ trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs 2009-08-17 20:50:37 UTC (rev 4695) @@ -57,7 +57,7 @@ { aggregate, "(", StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery, - enabledFilters)).ToString(), ") as y", + enabledFilters)), ") as y", loc.ToString(), "_" }); } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs 2009-08-17 20:50:37 UTC (rev 4695) @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NHibernate.Criterion; + +namespace NHibernate.Test.NHSpecificTest.NH1911 +{ + + [TestFixture] + public class Fixture : BugTestCase + { + + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.Save(new LogEvent() { Name = "name parameter", Level = "Fatal" }); + s.Save(new LogEvent() { Name = "name parameter", Level = "NonFatal" }); + s.Save(new LogEvent() { Name = "name parameter", Level = "Fatal" }); + t.Commit(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + base.OnSetUp(); + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.CreateQuery("delete from System.Object").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void ConditionalAggregateProjection() + { + IProjection isError = + Projections.Conditional( + Expression.Eq("Level", "Fatal"), + Projections.Constant(1), + Projections.Constant(0)); + + using (ISession s = OpenSession()) + { + IList<object[]> actual = + s.CreateCriteria<LogEvent>() + .Add(Expression.Eq("Name", "name parameter")) + .SetProjection(Projections.ProjectionList() + .Add(Projections.RowCount()) + .Add(Projections.Sum(isError))) + .List<object[]>(); + + Assert.That(actual.Count, Is.EqualTo(1)); + Assert.That(actual[0][0], Is.EqualTo(3)); + Assert.That(actual[0][1], Is.EqualTo(2)); + } + } + + } + +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml 2009-08-17 20:50:37 UTC (rev 4695) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1911"> + + <class name="LogEvent"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + <property name="Level" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs 2009-08-17 20:50:37 UTC (rev 4695) @@ -0,0 +1,20 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1911 +{ + + public class LogEvent + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string Level { get; set; } + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-17 20:40:40 UTC (rev 4694) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-17 20:50:37 UTC (rev 4695) @@ -579,6 +579,8 @@ <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Model.cs" /> + <Compile Include="NHSpecificTest\NH1911\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1911\Model.cs" /> <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> @@ -1996,6 +1998,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Customer.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Employee.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-17 20:40:48
|
Revision: 4694 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4694&view=rev Author: ricbrown Date: 2009-08-17 20:40:40 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Fix NH-1911 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs 2009-08-14 17:06:41 UTC (rev 4693) +++ branches/2.1.x/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs 2009-08-17 20:40:40 UTC (rev 4694) @@ -57,7 +57,7 @@ { aggregate, "(", StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery, - enabledFilters)).ToString(), ") as y", + enabledFilters)), ") as y", loc.ToString(), "_" }); } Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs 2009-08-17 20:40:40 UTC (rev 4694) @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NHibernate.Criterion; + +namespace NHibernate.Test.NHSpecificTest.NH1911 +{ + + [TestFixture] + public class Fixture : BugTestCase + { + + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.Save(new LogEvent() { Name = "name parameter", Level = "Fatal" }); + s.Save(new LogEvent() { Name = "name parameter", Level = "NonFatal" }); + s.Save(new LogEvent() { Name = "name parameter", Level = "Fatal" }); + t.Commit(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + base.OnSetUp(); + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.CreateQuery("delete from System.Object").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void ConditionalAggregateProjection() + { + IProjection isError = + Projections.Conditional( + Expression.Eq("Level", "Fatal"), + Projections.Constant(1), + Projections.Constant(0)); + + using (ISession s = OpenSession()) + { + IList<object[]> actual = + s.CreateCriteria<LogEvent>() + .Add(Expression.Eq("Name", "name parameter")) + .SetProjection(Projections.ProjectionList() + .Add(Projections.RowCount()) + .Add(Projections.Sum(isError))) + .List<object[]>(); + + Assert.That(actual.Count, Is.EqualTo(1)); + Assert.That(actual[0][0], Is.EqualTo(3)); + Assert.That(actual[0][1], Is.EqualTo(2)); + } + } + + } + +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml 2009-08-17 20:40:40 UTC (rev 4694) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1911"> + + <class name="LogEvent"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + <property name="Level" /> + </class> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs 2009-08-17 20:40:40 UTC (rev 4694) @@ -0,0 +1,20 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1911 +{ + + public class LogEvent + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string Level { get; set; } + } + +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 17:06:41 UTC (rev 4693) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-17 20:40:40 UTC (rev 4694) @@ -359,6 +359,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\NH1911\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1911\Model.cs" /> <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1920\Model.cs" /> <Compile Include="NHSpecificTest\NH1927\Fixture.cs" /> @@ -1970,6 +1972,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1927\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1928\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-14 17:06:48
|
Revision: 4693 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4693&view=rev Author: ricbrown Date: 2009-08-14 17:06:41 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Merge r4692 (Fix NH-1920) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-08-14 16:53:29 UTC (rev 4692) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-08-14 17:06:41 UTC (rev 4693) @@ -106,21 +106,6 @@ return dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames); } - protected override int BindParameterValues(IDbCommand statement, QueryParameters queryParameters, int startIndex, - ISessionImplementor session) - { - int position = startIndex; - - IList<IParameterSpecification> parameterSpecs = _queryTranslator.CollectedParameterSpecifications; - - foreach (var spec in parameterSpecs) - { - position += spec.Bind(statement, queryParameters, session, position); - } - - return position - startIndex; - } - protected override string[] Aliases { get { return _sqlAliases; } Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs 2009-08-14 17:06:41 UTC (rev 4693) @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1920 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void Can_Query_Without_Collection_Size_Condition() + { + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.SaveOrUpdate(new Customer() { IsDeleted = false }); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.EnableFilter("state").SetParameter("deleted", false); + var result = sess + .CreateQuery("from Customer c join c.Orders o where c.id > :cid") + .SetParameter("cid", 0) + .List(); + Assert.That(result.Count == 0); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.Delete("from System.Object"); + tx.Commit(); + } + } + + [Test] + public void Can_Query_With_Collection_Size_Condition() + { + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.SaveOrUpdate(new Customer() { IsDeleted = false }); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.EnableFilter("state").SetParameter("deleted", false); + var result = sess + .CreateQuery("from Customer c join c.Orders o where c.id > :cid and c.Orders.size > 0") + .SetParameter("cid", 0) + .List(); + Assert.That(result.Count == 0); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.Delete("from System.Object"); + tx.Commit(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml 2009-08-14 17:06:41 UTC (rev 4693) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1920"> + + <class name="Customer" table="Customers"> + <id name="Id"> + <generator class="native" /> + </id> + <bag name="Orders"> + <key column="Customer_Id" /> + <one-to-many class="Order" /> + <filter name="state" condition=":deleted = IsDeleted" /> + </bag> + <property name="IsDeleted" not-null="true" /> + </class> + + <class name="Order" table="Orders"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="IsDeleted" not-null="true" /> + <property name="Memo" not-null="false" /> + <many-to-one name="Customer" class="Customer" column="Customer_Id" /> + <filter name="state" condition=":deleted = IsDeleted" /> + </class> + + <filter-def name="state" condition=":deleted = IsDeleted"> + <filter-param name="deleted" type="Boolean"/> + </filter-def> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs 2009-08-14 17:06:41 UTC (rev 4693) @@ -0,0 +1,28 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1920 +{ + + public class Customer + { + public virtual int Id { get; set; } + public virtual bool IsDeleted { get; set; } + public virtual IList<Order> Orders { get; set; } + } + + public class Order + { + public virtual int Id { get; set; } + public virtual bool IsDeleted { get; set; } + public virtual string Memo { get; set; } + public virtual Customer Customer { get; set; } + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 16:53:29 UTC (rev 4692) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 17:06:41 UTC (rev 4693) @@ -581,6 +581,8 @@ <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1914\Model.cs" /> + <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1920\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1994,6 +1996,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Customer.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Employee.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Order.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-14 16:53:36
|
Revision: 4692 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4692&view=rev Author: ricbrown Date: 2009-08-14 16:53:29 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Fix NH-1920 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-08-14 06:57:52 UTC (rev 4691) +++ branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-08-14 16:53:29 UTC (rev 4692) @@ -106,21 +106,6 @@ return dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames); } - protected override int BindParameterValues(IDbCommand statement, QueryParameters queryParameters, int startIndex, - ISessionImplementor session) - { - int position = startIndex; - - IList<IParameterSpecification> parameterSpecs = _queryTranslator.CollectedParameterSpecifications; - - foreach (var spec in parameterSpecs) - { - position += spec.Bind(statement, queryParameters, session, position); - } - - return position - startIndex; - } - protected override string[] Aliases { get { return _sqlAliases; } Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs 2009-08-14 16:53:29 UTC (rev 4692) @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1920 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void Can_Query_Without_Collection_Size_Condition() + { + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.SaveOrUpdate(new Customer() { IsDeleted = false }); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.EnableFilter("state").SetParameter("deleted", false); + var result = sess + .CreateQuery("from Customer c join c.Orders o where c.id > :cid") + .SetParameter("cid", 0) + .List(); + Assert.That(result.Count == 0); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.Delete("from System.Object"); + tx.Commit(); + } + } + + [Test] + public void Can_Query_With_Collection_Size_Condition() + { + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.SaveOrUpdate(new Customer() { IsDeleted = false }); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.EnableFilter("state").SetParameter("deleted", false); + var result = sess + .CreateQuery("from Customer c join c.Orders o where c.id > :cid and c.Orders.size > 0") + .SetParameter("cid", 0) + .List(); + Assert.That(result.Count == 0); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.Delete("from System.Object"); + tx.Commit(); + } + } + + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml 2009-08-14 16:53:29 UTC (rev 4692) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1920"> + + <class name="Customer" table="Customers"> + <id name="Id"> + <generator class="native" /> + </id> + <bag name="Orders"> + <key column="Customer_Id" /> + <one-to-many class="Order" /> + <filter name="state" condition=":deleted = IsDeleted" /> + </bag> + <property name="IsDeleted" not-null="true" /> + </class> + + <class name="Order" table="Orders"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="IsDeleted" not-null="true" /> + <property name="Memo" not-null="false" /> + <many-to-one name="Customer" class="Customer" column="Customer_Id" /> + <filter name="state" condition=":deleted = IsDeleted" /> + </class> + + <filter-def name="state" condition=":deleted = IsDeleted"> + <filter-param name="deleted" type="Boolean"/> + </filter-def> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs 2009-08-14 16:53:29 UTC (rev 4692) @@ -0,0 +1,28 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1920 +{ + + public class Customer + { + public virtual int Id { get; set; } + public virtual bool IsDeleted { get; set; } + public virtual IList<Order> Orders { get; set; } + } + + public class Order + { + public virtual int Id { get; set; } + public virtual bool IsDeleted { get; set; } + public virtual string Memo { get; set; } + public virtual Customer Customer { get; set; } + } + +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 06:57:52 UTC (rev 4691) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 16:53:29 UTC (rev 4692) @@ -359,8 +359,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> - <Compile Include="NHSpecificTest\NH1919\Fixture.cs" /> - <Compile Include="NHSpecificTest\NH1919\Model.cs" /> + <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1920\Model.cs" /> <Compile Include="NHSpecificTest\NH1927\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1927\Model.cs" /> <Compile Include="NHSpecificTest\NH1928\Fixture.cs" /> @@ -1970,7 +1970,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> - <EmbeddedResource Include="NHSpecificTest\NH1919\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1927\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1928\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1914\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-08-14 06:58:09
|
Revision: 4691 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4691&view=rev Author: ayenderahien Date: 2009-08-14 06:57:52 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Fixing NH-1927, will not duplicate filter condition to where clause if it is already on the join clause. Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-08-14 05:26:21 UTC (rev 4690) +++ branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-08-14 06:57:52 UTC (rev 4691) @@ -575,7 +575,9 @@ if (enabledFilters.Count > 0) { var manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFilters); - outerjoin.AddCondition(manyToOneFilterFragment); + var joinClauseDoesNotContainsFilterAlready = outerjoin.ToFromFragmentString.IndexOfCaseInsensitive(manyToOneFilterFragment) == -1; + if(joinClauseDoesNotContainsFilterAlready) + outerjoin.AddCondition(manyToOneFilterFragment); } } last = oj; Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927 ___________________________________________________________________ Added: svn:mergeinfo + Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Fixture.cs 2009-08-14 06:57:52 UTC (rev 4691) @@ -0,0 +1,105 @@ +using System; +using NHibernate.Criterion; +using NHibernate.SqlCommand; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1927 +{ + [TestFixture] + public class Fixture : BugTestCase + { + private static readonly DateTime MAX_DATE = new DateTime(3000, 1, 1); + private static readonly DateTime VALID_DATE = new DateTime(2000, 1, 1); + + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + var joe = new Customer() {ValidUntil = MAX_DATE}; + session.Save(joe); + + tx.Commit(); + } + } + } + + protected override void OnTearDown() + { + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + session.Delete("from Invoice"); + session.Delete("from Customer"); + tx.Commit(); + } + } + base.OnTearDown(); + } + + private delegate Customer QueryFactoryFunc(ISession session); + + private void TestQuery(QueryFactoryFunc queryFactoryFunc) + { + // test without filter + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + Assert.That(queryFactoryFunc(session), Is.Not.Null, "failed with filter off"); + tx.Commit(); + } + + // test with the validity filter + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.EnableFilter("validity").SetParameter("date", VALID_DATE); + Assert.That(queryFactoryFunc(session), Is.Not.Null, "failed with filter on"); + tx.Commit(); + } + + } + + [Test] + public void CriteriaWithEagerFetch() + { + TestQuery(s => s.CreateCriteria(typeof (Customer)) + .SetFetchMode("Invoices", FetchMode.Eager) + .UniqueResult<Customer>() + ); + } + + [Test] + public void CriteriaWithoutEagerFetch() + { + TestQuery(s => s + .CreateCriteria(typeof(Customer)) + .UniqueResult<Customer>() + ); + } + + [Test] + public void HqlWithEagerFetch() + { + TestQuery(s => s.CreateQuery(@" + select c + from Customer c + left join fetch c.Invoices" + ) + .UniqueResult<Customer>()); + } + + [Test] + public void HqlWithoutEagerFetch() + { + TestQuery(s => s.CreateQuery(@" + select c + from Customer c" + ) + .UniqueResult<Customer>()); + } + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Mappings.hbm.xml 2009-08-14 06:57:52 UTC (rev 4691) @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1927"> + + <class name="Customer" > + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <set name="Invoices" inverse="true" lazy="true" > + <key column="CustomerID"/> + <one-to-many class="Invoice"/> + <filter name="validity" condition="ValidUntil > :date" /> + </set> + + <property name="ValidUntil" type="DateTime" /> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <property name="ValidUntil" type="DateTime" /> + <many-to-one name="Customer" column="CustomerID" class="Customer"/> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <filter-def name="validity"> + <filter-param name="date" type="DateTime"/> + </filter-def> +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/Model.cs 2009-08-14 06:57:52 UTC (rev 4691) @@ -0,0 +1,19 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1927 +{ + public class Customer + { + public virtual int ID { get; private set; } + public virtual ISet<Invoice> Invoices { get; set; } + public virtual DateTime ValidUntil { get; set; } + } + + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime ValidUntil { get; set; } + public virtual Customer Customer { get; set; } + } +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 05:26:21 UTC (rev 4690) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 06:57:52 UTC (rev 4691) @@ -359,6 +359,10 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\NH1919\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1919\Model.cs" /> + <Compile Include="NHSpecificTest\NH1927\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1927\Model.cs" /> <Compile Include="NHSpecificTest\NH1928\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1928\Model.cs" /> <Compile Include="NHSpecificTest\NH1044\Domain.cs" /> @@ -1966,6 +1970,8 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1919\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1927\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1928\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1914\Mappings.hbm.xml" /> <EmbeddedResource Include="IdTest\AssignedClass.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-08-14 05:26:30
|
Revision: 4690 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4690&view=rev Author: ayenderahien Date: 2009-08-14 05:26:21 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Fixing NH-1928 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-08-13 11:56:42 UTC (rev 4689) +++ branches/2.1.x/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-08-14 05:26:21 UTC (rev 4690) @@ -64,7 +64,17 @@ if (afterNewLine && (indx + 1 < stringLength) && sqlString.Substring(indx, 2) == "--") { var closeCommentIdx = sqlString.IndexOf(Environment.NewLine, indx + 2); - recognizer.Other(sqlString.Substring(indx, closeCommentIdx - indx)); + string comment; + if (closeCommentIdx == -1) + { + closeCommentIdx = sqlString.Length; + comment = sqlString.Substring(indx); + } + else + { + comment = sqlString.Substring(indx, closeCommentIdx - indx + Environment.NewLine.Length); + } + recognizer.Other(comment); indx = closeCommentIdx + NewLineLength - 1; continue; } Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928 ___________________________________________________________________ Added: svn:mergeinfo + Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Fixture.cs 2009-08-14 05:26:21 UTC (rev 4690) @@ -0,0 +1,73 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1928 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void SqlCommentAtBeginningOfLine() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + var query = session.CreateSQLQuery( + @" +select 1 +from + Customer +where +-- this is a comment + Name = 'Joe' + and Age > 50 +"); + + Assert.DoesNotThrow(() => query.List()); + tx.Commit(); + } + } + + [Test] + public void SqlCommentAtBeginningOfLastLine() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + var query = session.CreateSQLQuery( + @" +select 1 +from + Customer +where + Name = 'Joe' + and Age > 50 +-- this is a comment"); + + Assert.DoesNotThrow(() => query.List()); + tx.Commit(); + } + } + + [Test] + public void SqlCommentAfterBeginningOfLine() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + var query = session.CreateSQLQuery( + @" +select 1 +from + Customer +where + -- this is a comment + Name = 'Joe' + and Age > 50 +"); + + Assert.DoesNotThrow(() => query.List()); + tx.Commit(); + } + } + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Mappings.hbm.xml 2009-08-14 05:26:21 UTC (rev 4690) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1928"> + + <class name="Customer" > + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <property name="Age" type="Int32" /> + <property name="Name" type="String" /> + </class> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/Model.cs 2009-08-14 05:26:21 UTC (rev 4690) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH1928 +{ + public class Customer + { + public virtual int ID { get; private set; } + public virtual string Name { get; set; } + public virtual int Age { get; set; } + } +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-13 11:56:42 UTC (rev 4689) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 05:26:21 UTC (rev 4690) @@ -359,6 +359,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\NH1928\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1928\Model.cs" /> <Compile Include="NHSpecificTest\NH1044\Domain.cs" /> <Compile Include="NHSpecificTest\NH1044\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1069\Domain.cs" /> @@ -1964,6 +1966,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1928\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1914\Mappings.hbm.xml" /> <EmbeddedResource Include="IdTest\AssignedClass.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-08-13 11:56:52
|
Revision: 4689 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4689&view=rev Author: steverstrong Date: 2009-08-13 11:56:42 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Added initial test for Linq provider to show the approach taken to integrate with the core Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/IQueryTranslatorFactory.cs trunk/nhibernate/src/NHibernate/ISession.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/IQueryExpression.cs trunk/nhibernate/src/NHibernate/Linq/ trunk/nhibernate/src/NHibernate/Linq/LinqExpression.cs trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs trunk/nhibernate/src/NHibernate/Linq/Query.cs trunk/nhibernate/src/NHibernate/Linq/QueryProvider.cs trunk/nhibernate/src/NHibernate/Linq/TypeHelper.cs trunk/nhibernate/src/NHibernate.Test/Linq/ trunk/nhibernate/src/NHibernate.Test/Linq/BasicLinqTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Address.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Entity.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/OrderLine.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Product.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/ProductCategory.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Region.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Shipper.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Supplier.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Territory.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/ trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Customer.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Employee.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Order.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/OrderLine.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Product.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/ProductCategory.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Region.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Shipper.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Supplier.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Territory.hbm.xml Property Changed: ---------------- trunk/nhibernate/src/ trunk/nhibernate/src/NHibernate/ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/ trunk/nhibernate/src/NHibernate.ByteCode.LinFu/ trunk/nhibernate/src/NHibernate.ByteCode.LinFu.Tests/ trunk/nhibernate/src/NHibernate.DomainModel/ trunk/nhibernate/src/NHibernate.Test/ Property changes on: trunk/nhibernate/src ___________________________________________________________________ Modified: svn:ignore - *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest + *.suo CloverSrc _ReSharper* *.resharperoptions *.resharper.user CloverBuild Ankh.Load *.resharper ConsoleTest _UpgradeReport_Files NHibernate.userprefs NHibernate.usertasks UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML UpgradeLog5.XML UpgradeLog6.XML UpgradeLog7.XML UpgradeLog8.XML UpgradeLog9.XML NHibernate.sln.proj NHibernate.sln.AssemblySurfaceCache.user NHibernate.sln.cache Property changes on: trunk/nhibernate/src/NHibernate ___________________________________________________________________ Modified: svn:ignore - obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* + obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* _ReSharper.NHibernate NHibernate.pidb Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -81,6 +81,14 @@ /// <returns></returns> IList List(string query, QueryParameters parameters); + /// <summary> + /// Execute a <c>List()</c> expression query + /// </summary> + /// <param name="queryExpression"></param> + /// <param name="parameters"></param> + /// <returns></returns> + IList List(IQueryExpression queryExpression, QueryParameters parameters); + void List(string query, QueryParameters parameters, IList results); /// <summary> Modified: trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -6,6 +6,7 @@ using log4net; using NHibernate.Event; using NHibernate.Hql; +using NHibernate.Hql.Ast.ANTLR; using NHibernate.Type; using NHibernate.Util; @@ -30,10 +31,16 @@ public HQLQueryPlan(string hql, bool shallow, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) - : this(hql, null, shallow, enabledFilters, factory) + : this(hql, (string) null, shallow, enabledFilters, factory) { } + public HQLQueryPlan(string expressionStr, IQueryExpression queryExpression, bool shallow, + IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) + : this(expressionStr, queryExpression, null, shallow, enabledFilters, factory) + { + } + protected internal HQLQueryPlan(string hql, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) { @@ -98,9 +105,39 @@ } } } - } + protected internal HQLQueryPlan(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow, + IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) + { + sourceQuery = expressionStr; + this.shallow = shallow; + + enabledFilterNames = new HashedSet<string>(enabledFilters.Keys); + + // TODO - no support for polymorphism here - done during Expression -> AST translation? + // TODO - polymorphism approach used in method above also sucks. Could be done in AST much more cleanly? Look at this... + IQueryTranslatorFactory2 qtFactory = new ASTQueryTranslatorFactory(); + + IQueryTranslator translator = qtFactory.CreateQueryTranslator(expressionStr, queryExpression, enabledFilters, + factory); + + translator.Compile(factory.Settings.QuerySubstitutions, shallow); + + translators = new[] { translator }; + + sqlStrings = new List<string>(translator.CollectSqlStrings).ToArray(); + + querySpaces = new HashedSet<string>(translator.QuerySpaces); + + // TODO - need to build parameterMetadata. Current function no good, since is parses the HQL. Might need to walk the AST here, + // probably inside the QueryTranslator. That's probably a better place for the parsing to be anyway; possibly worth moving for classic as well... + //parameterMetadata = BuildParameterMetadata(translator.GetParameterTranslations(), hql); + parameterMetadata = new ParameterMetadata(new OrdinalParameterDescriptor[0], new Dictionary<string, NamedParameterDescriptor>()); + + returnMetadata = new ReturnMetadata(translator.ReturnAliases, translator.ReturnTypes); + } + public string SourceQuery { get { return sourceQuery; } Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -72,6 +72,35 @@ return plan; } + public HQLQueryPlan GetHQLQueryPlan(IQueryExpression queryExpression, bool shallow, IDictionary<string, IFilter> enabledFilters) + { + string expressionStr = queryExpression.Key; + + var key = new HQLQueryPlanKey(expressionStr, shallow, enabledFilters); + var plan = (HQLQueryPlan)planCache[key]; + + if (plan == null) + { + if (log.IsDebugEnabled) + { + log.Debug("unable to locate HQL query plan in cache; generating (" + expressionStr + ")"); + } + plan = new HQLQueryPlan(expressionStr, queryExpression, shallow, enabledFilters, factory); + } + else + { + if (log.IsDebugEnabled) + { + log.Debug("located HQL query plan in cache (" + expressionStr + ")"); + } + } + + planCache.Put(key, plan); + + return plan; + } + + public FilterQueryPlan GetFilterQueryPlan(string filterString, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters) { var key = new FilterQueryPlanKey(filterString, collectionRole, shallow, enabledFilters); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/ASTQueryTranslatorFactory.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -10,7 +10,7 @@ /// Author: Gavin King /// Ported by: Steve Strong /// </summary> - public class ASTQueryTranslatorFactory : IQueryTranslatorFactory + public class ASTQueryTranslatorFactory : IQueryTranslatorFactory2 { public IQueryTranslator CreateQueryTranslator(string queryIdentifier, string queryString, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory) { @@ -21,5 +21,10 @@ { return new QueryTranslatorImpl(queryIdentifier, queryString, filters, factory); } + + public IQueryTranslator CreateQueryTranslator(string queryIdentifier, IQueryExpression queryExpression, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory) + { + return new QueryTranslatorImpl(queryIdentifier, queryExpression, filters, factory); + } } } Property changes on: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated ___________________________________________________________________ Added: svn:ignore + Hql.tokens HqlSqlWalker.tokens SqlGenerator.tokens Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -58,6 +58,28 @@ _factory = factory; } + /// <summary> + /// Creates a new AST-based query translator. + /// </summary> + /// <param name="queryIdentifier">The query-identifier (used in stats collection)</param> + /// <param name="queryExpression">The hql query to translate</param> + /// <param name="enabledFilters">Currently enabled filters</param> + /// <param name="factory">The session factory constructing this translator instance.</param> + public QueryTranslatorImpl( + string queryIdentifier, + IQueryExpression queryExpression, + IDictionary<string, IFilter> enabledFilters, + ISessionFactoryImplementor factory) + { + _queryIdentifier = queryIdentifier; + _hql = queryExpression.ToString(); + _compiled = false; + _shallowQuery = false; + _enabledFilters = enabledFilters; + _factory = factory; + _parser = new HqlParseEngine(queryExpression.Translate(factory), factory); + } + /// <summary> /// Compile a "normal" query. This method may be called multiple /// times. Subsequent invocations are no-ops. Modified: trunk/nhibernate/src/NHibernate/Hql/IQueryTranslatorFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/IQueryTranslatorFactory.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Hql/IQueryTranslatorFactory.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -39,4 +39,26 @@ /// <returns>An appropriate translator.</returns> IFilterTranslator CreateFilterTranslator(string queryIdentifier, string queryString, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory); } + + /// <summary> + /// Facade for generation of <see cref="NHibernate.Hql.IQueryTranslator"/> + /// and <see cref="NHibernate.Hql.IFilterTranslator"/> instances. + /// </summary> + public interface IQueryTranslatorFactory2 : IQueryTranslatorFactory + { + /// <summary> + /// Construct a <see cref="NHibernate.Hql.IQueryTranslator"/> instance + /// capable of translating a Linq expression. + /// </summary> + /// <param name="queryIdentifier"> + /// The query-identifier (used in <see cref="NHibernate.Stat.QueryStatistics"/> collection). + /// This is typically the same as the queryString parameter except for the case of + /// split polymorphic queries which result in multiple physical sql queries. + /// </param> + /// <param name="queryExpression">The query expression to be translated</param> + /// <param name="filters">Currently enabled filters</param> + /// <param name="factory">The session factory</param> + /// <returns>An appropriate translator.</returns> + IQueryTranslator CreateQueryTranslator(string queryIdentifier, IQueryExpression queryExpression, IDictionary<string, IFilter> filters, ISessionFactoryImplementor factory); + } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/IQueryExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryExpression.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/IQueryExpression.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,11 @@ +using NHibernate.Hql.Ast.ANTLR.Tree; + +namespace NHibernate +{ + public interface IQueryExpression + { + IASTNode Translate(ISessionFactory sessionFactory); + string Key { get; } + System.Type Type { get; } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/IQueryExpression.cs ___________________________________________________________________ Added: svn:executable + * Modified: trunk/nhibernate/src/NHibernate/ISession.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ISession.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/ISession.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -804,6 +804,13 @@ /// <returns>The query</returns> IQuery CreateQuery(string queryString); + /// <summary> + /// Create a new instance of <c>Query</c> for the given query expression + /// <param name="queryExpression"/>A hibernate query expression</param> + /// <returns>The query</returns> + /// </summary> + IQuery CreateQuery(IQueryExpression queryExpression); + /// <summary> /// Create a new instance of <c>Query</c> for the given collection and filter string /// </summary> Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -76,6 +76,8 @@ public abstract void CloseSessionFromDistributedTransaction(); public abstract IList List(string query, QueryParameters parameters); public abstract void List(string query, QueryParameters parameters, IList results); + public abstract IList List(IQueryExpression queryExpression, QueryParameters parameters); + public abstract void List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results); public abstract IList<T> List<T>(string query, QueryParameters queryParameters); public abstract IList<T> List<T>(CriteriaImpl criteria); public abstract void List(CriteriaImpl criteria, IList results); @@ -245,6 +247,18 @@ } } + public virtual IQuery CreateQuery(IQueryExpression queryExpression) + { + using (new SessionIdLoggingContext(SessionId)) + { + CheckAndUpdateSessionStatus(); + QueryImpl query = new QueryImpl(queryExpression, this, + GetHQLQueryPlan(queryExpression, false).ParameterMetadata); + query.SetComment("[expression]"); + return query; + } + } + public virtual IQuery CreateQuery(string queryString) { using (new SessionIdLoggingContext(SessionId)) @@ -275,6 +289,14 @@ } } + protected internal virtual HQLQueryPlan GetHQLQueryPlan(IQueryExpression queryExpression, bool shallow) + { + using (new SessionIdLoggingContext(SessionId)) + { + return factory.QueryPlanCache.GetHQLQueryPlan(queryExpression, shallow, EnabledFilters); + } + } + protected internal virtual NativeSQLQueryPlan GetNativeSQLQueryPlan(NativeSQLQuerySpecification spec) { using (new SessionIdLoggingContext(SessionId)) Modified: trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -13,6 +13,7 @@ public class QueryImpl : AbstractQueryImpl { private readonly Dictionary<string, LockMode> lockModes = new Dictionary<string, LockMode>(2); + private readonly IQueryExpression _queryExpression; public QueryImpl(string queryString, FlushMode flushMode, ISessionImplementor session, ParameterMetadata parameterMetadata) : base(queryString, flushMode, session, parameterMetadata) @@ -24,6 +25,12 @@ { } + public QueryImpl(IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata) + : base(queryExpression.Key, FlushMode.Unspecified, session, parameterMetadata) + { + _queryExpression = queryExpression; + } + public override IEnumerable Enumerable() { VerifyParameters(); @@ -61,7 +68,14 @@ Before(); try { - return Session.List(ExpandParameterLists(namedParams), GetQueryParameters(namedParams)); + if (_queryExpression == null) + { + return Session.List(ExpandParameterLists(namedParams), GetQueryParameters(namedParams)); + } + else + { + return Session.List(_queryExpression, GetQueryParameters(namedParams)); + } } finally { Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -645,6 +645,50 @@ } } + public override IList List(IQueryExpression queryExpression, QueryParameters parameters) + { + IList results = (IList) typeof(List<>).MakeGenericType(queryExpression.Type) + .GetConstructor(System.Type.EmptyTypes) + .Invoke(null); + + List(queryExpression, parameters, results); + + return results; + } + + public override void List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) + { + using (new SessionIdLoggingContext(SessionId)) + { + CheckAndUpdateSessionStatus(); + queryParameters.ValidateParameters(); + HQLQueryPlan plan = GetHQLQueryPlan(queryExpression, false); + AutoFlushIfRequired(plan.QuerySpaces); + + bool success = false; + dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called + try + { + plan.PerformList(queryParameters, this, results); + success = true; + } + catch (HibernateException) + { + // Do not call Convert on HibernateExceptions + throw; + } + catch (Exception e) + { + throw Convert(e, "Could not execute query"); + } + finally + { + dontFlushFromFind--; + AfterOperation(success); + } + } + } + public override IQueryTranslator[] GetQueries(string query, bool scalar) { using (new SessionIdLoggingContext(SessionId)) Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -133,6 +133,16 @@ } } + public override IList List(IQueryExpression queryExpression, QueryParameters parameters) + { + throw new System.NotImplementedException(); + } + + public override void List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) + { + throw new System.NotImplementedException(); + } + public override IList<T> List<T>(string query, QueryParameters queryParameters) { using (new SessionIdLoggingContext(SessionId)) Added: trunk/nhibernate/src/NHibernate/Linq/LinqExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/LinqExpression.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/LinqExpression.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,41 @@ +using System; +using System.Linq.Expressions; +using NHibernate.Hql.Ast.ANTLR; +using NHibernate.Hql.Ast.ANTLR.Tree; + +namespace NHibernate.Linq +{ + class LinqExpression : IQueryExpression + { + private readonly Expression _linqExpression; + + internal LinqExpression(Expression linqExpression) + { + _linqExpression = linqExpression; + } + + public IASTNode Translate(ISessionFactory sessionFactory) + { + ASTFactory factory = new ASTFactory(new ASTTreeAdaptor()); + + return factory.CreateNode(HqlSqlWalker.QUERY, "query", + factory.CreateNode(HqlSqlWalker.SELECT_FROM, "select from", + factory.CreateNode(HqlSqlWalker.FROM, "from", + factory.CreateNode( + HqlSqlWalker.RANGE, "range", + factory.CreateNode( + HqlSqlWalker.IDENT, + "Product"))))); + } + + public string Key + { + get { return _linqExpression.ToString(); } + } + + public System.Type Type + { + get { return _linqExpression.Type.GetGenericArguments()[0]; } + } + } +} Property changes on: trunk/nhibernate/src/NHibernate/Linq/LinqExpression.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,12 @@ +using System.Linq; + +namespace NHibernate.Linq +{ + public static class ExtensionMethods + { + public static IQueryable<T> Query<T>(this ISession session) + { + return new Query<T>(new NhQueryProvider(session)); + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,20 @@ +using System.Linq.Expressions; + +namespace NHibernate.Linq +{ + public class NhQueryProvider : QueryProvider + { + private readonly ISession _session; + + public NhQueryProvider(ISession session) + { + _session = session; + } + + public override object Execute(Expression expression) + { + // walk the expression tree and build an HQL AST to mirror it + return _session.CreateQuery(new LinqExpression(expression)).List(); + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate/Linq/Query.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/Query.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/Query.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,85 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; + +namespace NHibernate.Linq +{ + /// <summary> + /// A default implementation of IQueryable for use with QueryProvider + /// </summary> + public class Query<T> : IOrderedQueryable<T> + { + private readonly Expression _expression; + private readonly IQueryProvider _provider; + + public Query(IQueryProvider provider) + { + if (provider == null) + { + throw new ArgumentNullException("provider"); + } + _provider = provider; + _expression = Expression.Constant(this); + } + + public Query(IQueryProvider provider, Expression expression) + { + if (provider == null) + { + throw new ArgumentNullException("provider"); + } + if (expression == null) + { + throw new ArgumentNullException("expression"); + } + if (!typeof (IQueryable<T>).IsAssignableFrom(expression.Type)) + { + throw new ArgumentOutOfRangeException("expression"); + } + _provider = provider; + _expression = expression; + } + + #region IQueryable<T> Members + + public Expression Expression + { + get { return _expression; } + } + + public System.Type ElementType + { + get { return typeof (T); } + } + + public IQueryProvider Provider + { + get { return _provider; } + } + + public IEnumerator<T> GetEnumerator() + { + return ((IEnumerable<T>) _provider.Execute(_expression)).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable) _provider.Execute(_expression)).GetEnumerator(); + } + + #endregion + + public override string ToString() + { + if (_expression.NodeType == ExpressionType.Constant && + ((ConstantExpression) _expression).Value == this) + { + return "Query(" + typeof (T) + ")"; + } + + return _expression.ToString(); + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq/Query.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate/Linq/QueryProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/QueryProvider.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/QueryProvider.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,49 @@ +using System; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; + +namespace NHibernate.Linq +{ + /// <summary> + /// A basic abstract LINQ query provider + /// </summary> + public abstract class QueryProvider : IQueryProvider + { + #region IQueryProvider Members + + IQueryable<T> IQueryProvider.CreateQuery<T>(Expression expression) + { + return new Query<T>(this, expression); + } + + IQueryable IQueryProvider.CreateQuery(Expression expression) + { + System.Type elementType = TypeHelper.GetElementType(expression.Type); + try + { + return + (IQueryable) + Activator.CreateInstance(typeof (Query<>).MakeGenericType(elementType), new object[] {this, expression}); + } + catch (TargetInvocationException tie) + { + throw tie.InnerException; + } + } + + T IQueryProvider.Execute<T>(Expression expression) + { + return (T) Execute(expression); + } + + object IQueryProvider.Execute(Expression expression) + { + return Execute(expression); + } + + #endregion + + public abstract object Execute(Expression expression); + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq/QueryProvider.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate/Linq/TypeHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/TypeHelper.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/TypeHelper.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// This source code is made available under the terms of the Microsoft Public License (MS-PL) + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; + +namespace NHibernate.Linq +{ + /// <summary> + /// Type related helper methods + /// </summary> + public static class TypeHelper + { + public static System.Type FindIEnumerable(System.Type seqType) + { + if (seqType == null || seqType == typeof (string)) + return null; + if (seqType.IsArray) + return typeof (IEnumerable<>).MakeGenericType(seqType.GetElementType()); + if (seqType.IsGenericType) + { + foreach (System.Type arg in seqType.GetGenericArguments()) + { + System.Type ienum = typeof (IEnumerable<>).MakeGenericType(arg); + if (ienum.IsAssignableFrom(seqType)) + { + return ienum; + } + } + } + System.Type[] ifaces = seqType.GetInterfaces(); + if (ifaces != null && ifaces.Length > 0) + { + foreach (System.Type iface in ifaces) + { + System.Type ienum = FindIEnumerable(iface); + if (ienum != null) return ienum; + } + } + if (seqType.BaseType != null && seqType.BaseType != typeof (object)) + { + return FindIEnumerable(seqType.BaseType); + } + return null; + } + + public static System.Type GetSequenceType(System.Type elementType) + { + return typeof (IEnumerable<>).MakeGenericType(elementType); + } + + public static System.Type GetElementType(System.Type seqType) + { + System.Type ienum = FindIEnumerable(seqType); + if (ienum == null) return seqType; + return ienum.GetGenericArguments()[0]; + } + + public static bool IsNullableType(System.Type type) + { + return type != null && type.IsGenericType && type.GetGenericTypeDefinition() == typeof (Nullable<>); + } + + public static bool IsNullAssignable(System.Type type) + { + return !type.IsValueType || IsNullableType(type); + } + + public static System.Type GetNonNullableType(System.Type type) + { + if (IsNullableType(type)) + { + return type.GetGenericArguments()[0]; + } + return type; + } + + public static System.Type GetNullAssignableType(System.Type type) + { + if (!IsNullAssignable(type)) + { + return typeof (Nullable<>).MakeGenericType(type); + } + return type; + } + + public static ConstantExpression GetNullConstant(System.Type type) + { + return Expression.Constant(null, GetNullAssignableType(type)); + } + + public static System.Type GetMemberType(MemberInfo mi) + { + var fi = mi as FieldInfo; + if (fi != null) return fi.FieldType; + var pi = mi as PropertyInfo; + if (pi != null) return pi.PropertyType; + var ei = mi as EventInfo; + if (ei != null) return ei.EventHandlerType; + return null; + } + + public static object GetDefault(System.Type type) + { + bool isNullable = !type.IsValueType || IsNullableType(type); + if (!isNullable) + return Activator.CreateInstance(type); + return null; + } + + public static bool IsReadOnly(MemberInfo member) + { + switch (member.MemberType) + { + case MemberTypes.Field: + return (((FieldInfo) member).Attributes & FieldAttributes.InitOnly) != 0; + case MemberTypes.Property: + var pi = (PropertyInfo) member; + return !pi.CanWrite || pi.GetSetMethod() == null; + default: + return true; + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq/TypeHelper.cs ___________________________________________________________________ Added: svn:executable + * Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-10 15:41:06 UTC (rev 4688) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-13 11:56:42 UTC (rev 4689) @@ -544,10 +544,17 @@ <Compile Include="Hql\Ast\ANTLR\Tree\ASTErrorNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> + <Compile Include="IQueryExpression.cs" /> <Compile Include="IQueryOver.cs" /> <Compile Include="Criterion\QueryOver.cs" /> <Compile Include="Impl\ExpressionProcessor.cs" /> <Compile Include="Impl\SessionIdLoggingContext.cs" /> + <Compile Include="Linq\LinqExpression.cs" /> + <Compile Include="Linq\LinqExtensionMethods.cs" /> + <Compile Include="Linq\NhQueryProvider.cs" /> + <Compile Include="Linq\Query.cs" /> + <Compile Include="Linq\QueryProvider.cs" /> + <Compile Include="Linq\TypeHelper.cs" /> <Compile Include="Param\AbstractExplicitParameterSpecification.cs" /> <Compile Include="Param\AggregatedIndexCollectionSelectorParameterSpecifications.cs" /> <Compile Include="Param\CollectionFilterKeyParameterSpecification.cs" /> Property changes on: trunk/nhibernate/src/NHibernate.ByteCode.LinFu ___________________________________________________________________ Modified: svn:ignore - obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* + obj .#* *.user *.xsx AssemblyInfo.cs *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* NHibernate.ByteCode.LinFu.pidb Property changes on: trunk/nhibernate/src/NHibernate.ByteCode.LinFu.Tests ___________________________________________________________________ Modified: svn:ignore - obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml + obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml NHibernate.ByteCode.LinFu.Tests.pidb Property changes on: trunk/nhibernate/src/NHibernate.DomainModel ___________________________________________________________________ Modified: svn:ignore - bin obj .#* *.user *.xsx AssemblyInfo.cs [Bb]in [Dd]ebug [Rr]elease *.aps *.eto + bin obj .#* *.user *.xsx AssemblyInfo.cs [Bb]in [Dd]ebug [Rr]elease *.aps *.eto NHibernate.DomainModel.pidb Property changes on: trunk/nhibernate/src/NHibernate.Test ___________________________________________________________________ Modified: svn:ignore - bin obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml + bin obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml NHibernate.Test.pidb test-results Added: trunk/nhibernate/src/NHibernate.Test/Linq/BasicLinqTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/BasicLinqTests.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/BasicLinqTests.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,19 @@ +using System.Linq; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [TestFixture] + public class BasicLinqTests : LinqTestCase + { + [Test] + public void DummySelect() + { + var soldOutProducts = from p in db.Products select p; + + var results = soldOutProducts.ToList(); + + Assert.AreEqual(0, results.Count); + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/BasicLinqTests.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Address.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Address.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Address.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,117 @@ +namespace NHibernate.Test.Linq.Entities +{ + public class Address + { + private readonly string _city; + private readonly string _country; + private readonly string _fax; + private readonly string _phoneNumber; + private readonly string _postalCode; + private readonly string _region; + private readonly string _street; + + public Address() : this(null, null, null, null, null, null, null) + { + } + + public Address(string street, string city, string region, string postalCode, + string country, string phoneNumber, string fax) + { + _street = street; + _city = city; + _region = region; + _postalCode = postalCode; + _country = country; + _phoneNumber = phoneNumber; + _fax = fax; + } + + public string Street + { + get { return _street; } + } + + public string City + { + get { return _city; } + } + + public string Region + { + get { return _region; } + } + + public string PostalCode + { + get { return _postalCode; } + } + + public string Country + { + get { return _country; } + } + + public string PhoneNumber + { + get { return _phoneNumber; } + } + + public string Fax + { + get { return _fax; } + } + + public static bool operator ==(Address address1, Address address2) + { + if (!ReferenceEquals(address1, null) && + ReferenceEquals(address2, null)) + { + return false; + } + + if (ReferenceEquals(address1, null) && + !ReferenceEquals(address2, null)) + { + return false; + } + + return address1.Equals(address2); + } + + public static bool operator !=(Address address1, Address address2) + { + return !(address1 == address2); + } + + public override bool Equals(object obj) + { + var address = obj as Address; + + if (address != null) + { + return + _street == address.Street && + _city == address.City && + _region == address.Region && + _postalCode == address.PostalCode && + _country == address.Country && + _phoneNumber == address.PhoneNumber && + _fax == address.Fax; + } + + return base.Equals(obj); + } + + public override int GetHashCode() + { + return + (_street ?? string.Empty).GetHashCode() ^ + (_city ?? string.Empty).GetHashCode() ^ + (_region ?? string.Empty).GetHashCode() ^ + (_postalCode ?? string.Empty).GetHashCode() ^ + (_country ?? string.Empty).GetHashCode() ^ + (_phoneNumber ?? string.Empty).GetHashCode() ^ + (_fax ?? string.Empty).GetHashCode(); + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Address.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.Linq.Entities +{ + public class Customer : Entity<Customer> + { + private readonly ISet<Order> _orders; + private Address _address; + private string _companyName; + private string _contactName; + private string _contactTitle; + + public Customer() : this(null) + { + } + + public Customer(string companyName) + { + _orders = new HashedSet<Order>(); + + _companyName = companyName; + } + + public virtual string CompanyName + { + get { return _companyName; } + set { _companyName = value; } + } + + public virtual string ContactName + { + get { return _contactName; } + set { _contactName = value; } + } + + public virtual string ContactTitle + { + get { return _contactTitle; } + set { _contactTitle = value; } + } + + public virtual Address Address + { + get { return _address; } + set { _address = value; } + } + + public virtual ReadOnlyCollection<Order> Orders + { + get { return new ReadOnlyCollection<Order>(new List<Order>(_orders)); } + } + + public virtual void AddOrder(Order order) + { + if (!_orders.Contains(order)) + { + _orders.Add(order); + order.Customer = this; + } + } + + public virtual void RemoveOrder(Order order) + { + if (_orders.Contains(order)) + { + _orders.Remove(order); + order.Customer = null; + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.Linq.Entities +{ + public class Employee : Entity<Employee> + { + private readonly ISet<Order> _orders; + private readonly ISet<Employee> _subordinates; + private readonly IList<Territory> _territories; + private Address _address; + private DateTime? _birthDate; + private string _extension; + private string _firstName; + private DateTime? _hireDate; + private string _lastName; + private string _notes; + private Employee _superior; + private string _title; + private string _titleOfCourtesy; + + public Employee() + : this(null, null) + { + } + + public Employee(string firstName, string lastName) + { + _firstName = firstName; + _lastName = lastName; + + _subordinates = new HashedSet<Employee>(); + _orders = new HashedSet<Order>(); + _territories = new List<Territory>(); + } + + public virtual string FirstName + { + get { return _firstName; } + set { _firstName = value; } + } + + public virtual string LastName + { + get { return _lastName; } + set { _lastName = value; } + } + + public virtual string Title + { + get { return _title; } + set { _title = value; } + } + + public virtual string TitleOfCourtesy + { + get { return _titleOfCourtesy; } + set { _titleOfCourtesy = value; } + } + + public virtual DateTime? BirthDate + { + get { return _birthDate; } + set { _birthDate = value; } + } + + public virtual DateTime? HireDate + { + get { return _hireDate; } + set { _hireDate = value; } + } + + public virtual Address Address + { + get { return _address; } + set { _address = value; } + } + + public virtual string Extension + { + get { return _extension; } + set { _extension = value; } + } + + public virtual string Notes + { + get { return _notes; } + set { _notes = value; } + } + + public virtual Employee Superior + { + get { return _superior; } + set { _superior = value; } + } + + public virtual ReadOnlyCollection<Employee> Subordinates + { + get { return new ReadOnlyCollection<Employee>(new List<Employee>(_subordinates)); } + } + + public virtual ReadOnlyCollection<Territory> Territories + { + get { return new ReadOnlyCollection<Territory>(_territories); } + } + + public virtual ReadOnlyCollection<Order> Orders + { + get { return new ReadOnlyCollection<Order>(new List<Order>(_orders)); } + } + + public virtual void AddSubordinate(Employee subordinate) + { + if (!_subordinates.Contains(subordinate)) + { + subordinate.Superior = this; + _subordinates.Add(subordinate); + } + } + + public virtual void RemoveSubordinate(Employee subordinate) + { + if (_subordinates.Contains(subordinate)) + { + subordinate.Superior = null; + _subordinates.Remove(subordinate); + } + } + + public virtual void AddOrder(Order order) + { + if (!_orders.Contains(order)) + { + order.Employee = this; + _orders.Add(order); + } + } + + public virtual void RemoveOrder(Order order) + { + if (_orders.Contains(order)) + { + order.Employee = null; + _orders.Remove(order); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Entity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Entity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Entity.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.Linq.Entities +{ + public abstract class Entity<T> + { + private long _id = -1; + + public virtual long Id { get { return _id; } set { _id = value; }} + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Entity.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,40 @@ +using System.Linq; +using NHibernate.Linq; + +namespace NHibernate.Test.Linq.Entities +{ + public class Northwind + { + private readonly ISession _session; + + public Northwind(ISession session) + { + _session = session; + } + + public IQueryable<Customer> Customers + { + get { return _session.Query<Customer>(); } + } + + public IQueryable<Product> Products + { + get { return _session.Query<Product>(); } + } + + public IQueryable<Order> Orders + { + get { return _session.Query<Order>(); } + } + + public IQueryable<OrderLine> OrderLines + { + get { return _session.Query<OrderLine>(); } + } + + public IQueryable<Employee> Employees + { + get { return _session.Query<Employee>(); } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.Linq.Entities +{ + public class Order : Entity<Order> + { + private readonly ISet<OrderLine> _orderLines; + private Customer _customer; + private Employee _employee; + private decimal? _freight; + private DateTime? _orderDate; + private DateTime? _requiredDate; + private string _shippedTo; + private Shipper _shipper; + private Address _shippingAddress; + private DateTime? _shippingDate; + + public Order() : this(null) + { + } + + public Order(Customer customer) + { + _orderLines = new HashedSet<OrderLine>(); + + _customer = customer; + } + + public virtual Customer Customer + { + get { return _customer; } + set { _customer = value; } + } + + public virtual Employee Employee + { + get { return _employee; } + set { _employee = value; } + } + + public virtual DateTime? OrderDate + { + get { return _orderDate; } + set { _orderDate = value; } + } + + public virtual DateTime? RequiredDate + { + get { return _requiredDate; } + set { _requiredDate = value; } + } + + public virtual DateTime? ShippingDate + { + get { return _shippingDate; } + set { _shippingDate = value; } + } + + public virtual Shipper Shipper + { + get { return _shipper; } + set { _shipper = value; } + } + + public virtual decimal? Freight + { + get { return _freight; } + set { _freight = value; } + } + + public virtual string ShippedTo + { + get { return _shippedTo; } + set { _shippedTo = value; } + } + + public virtual Address ShippingAddress + { + get { return _shippingAddress; } + set { _shippingAddress = value; } + } + + public virtual ReadOnlyCollection<OrderLine> OrderLines + { + get { return new ReadOnlyCollection<OrderLine>(new List<OrderLine>(_orderLines)); } + } + + public virtual void AddOrderLine(OrderLine orderLine) + { + if (!_orderLines.Contains(orderLine)) + { + orderLine.Order = this; + _orderLines.Add(orderLine); + } + } + + public virtual void RemoveOrderLine(OrderLine orderLine) + { + if (_orderLines.Contains(orderLine)) + { + _orderLines.Remove(orderLine); + orderLine.Order = null; + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/OrderLine.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/OrderLine.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/OrderLine.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,51 @@ +namespace NHibernate.Test.Linq.Entities +{ + public class OrderLine : Entity<OrderLine> + { + private decimal _discount; + private Order _order; + private Product _product; + private int _quantity; + private decimal _unitPrice; + + public OrderLine() : this(null, null) + { + } + + public OrderLine(Order order, Product product) + { + _order = order; + _product = product; + } + + public virtual Order Order + { + get { return _order; } + set { _order = value; } + } + + public virtual Product Product + { + get { return _product; } + set { _product = value; } + } + + public virtual decimal UnitPrice + { + get { return _unitPrice; } + set { _unitPrice = value; } + } + + public virtual int Quantity + { + get { return _quantity; } + set { _quantity = value; } + } + + public virtual decimal Discount + { + get { return _discount; } + set { _discount = value; } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/OrderLine.cs ___________________________________________________________________ Added: svn:executable + * Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Product.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Product.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Product.cs 2009-08-13 11:56:42 UTC (rev 4689) @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace NHibernate.Test.Linq.Entities +{ + public class Product : Entity<Product> + { + private readonly IList<OrderLine> _orderLines; + private ProductCategory _category; + private bool _discontinued; + private string _name; + private string _quantityPerUnit; + private int _reorderLevel; + private Supplier _supplier; + private decimal? _unitPrice; + private int _unitsInStock; + private int _unitsOnOrder; + + public Product() : this(null) + { + } + + public Product(string name) + { + _orderLines = new List<OrderLine>(); + + _name = name; + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + + public virtual Supplier Supplier + { + get { return _supplier; } + set { _supplier = value; } + } + + public virtual ProductCategory Category + { + get { return _category; } + set { _category = value; } + } + + public virtual string QuantityPerUnit + { + get { return _quantityPerUnit; } + set { _quantityPerUnit = value; } + } + + public virtual decimal? UnitPrice + { + get { return _unitPrice; } + set { _unitPrice = value; } + } + + public virtual int UnitsInStock + { + get { return _unitsInSt... [truncated message content] |
From: <ric...@us...> - 2009-08-10 15:41:14
|
Revision: 4688 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4688&view=rev Author: ricbrown Date: 2009-08-10 15:41:06 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Merge r4687 (Fix NH-1914) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs 2009-08-10 15:31:22 UTC (rev 4687) +++ trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -1,3 +1,5 @@ +using log4net; +using NHibernate.Id; using NHibernate.Persister.Entity; using NHibernate.Proxy; using NHibernate.Type; @@ -7,6 +9,8 @@ /// <summary> Algorithms related to foreign key constraint transparency </summary> public static class ForeignKeys { + private static readonly ILog log = LogManager.GetLogger(typeof(ForeignKeys)); + public class Nullifier { private readonly bool isDelete; @@ -195,6 +199,17 @@ if (assumed.HasValue) return assumed.Value; + if (persister.IdentifierGenerator is Assigned) + { + // When using assigned identifiers we cannot tell if an entity + // is transient or detached without querying the database. + // This could potentially cause Select N+1 in cascaded saves, so warn the user. + log.Warn("Unable to determine if " + entity.ToString() + + " with assigned identifier " + persister.GetIdentifier(entity, session.EntityMode) + + " is transient or detached; querying the database." + + " Use explicit Save() or Update() in session to prevent this."); + } + // hit the database, after checking the session cache for a snapshot System.Object[] snapshot = session.PersistenceContext.GetDatabaseSnapshot(persister.GetIdentifier(entity, session.EntityMode), persister); Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-08-10 15:31:22 UTC (rev 4687) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -3630,7 +3630,19 @@ // check the id unsaved-value bool? result2 = entityMetamodel.IdentifierProperty.UnsavedValue.IsUnsaved(id); if (result2.HasValue) - return result2; + { + if (IdentifierGenerator is Assigned) + { + // if using assigned identifier, we can only make assumptions + // if the value is a known unsaved-value + if (result2.Value) + return true; + } + else + { + return result2; + } + } // check to see if it is in the second-level cache if (HasCache) Added: trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.IdTest +{ + public class Parent + { + public string Id { get; set; } + public string Name { get; set; } + public IList<Child> Children { get; set; } + } + + public class Child + { + public string Id { get; set; } + public Parent Parent { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false"> + + <class name="NHibernate.Test.IdTest.Parent, NHibernate.Test"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <bag name="Children" inverse="true" cascade="all"> + <key column="Parent"/> + <one-to-many class="NHibernate.Test.IdTest.Child, NHibernate.Test"/> + </bag> + </class> + + <class name="NHibernate.Test.IdTest.Child, NHibernate.Test"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <many-to-one name="Parent" class="NHibernate.Test.IdTest.Parent, NHibernate.Test" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,255 @@ +using System; +using System.Collections.Generic; +using log4net; +using log4net.Core; +using NUnit.Framework; + +namespace NHibernate.Test.IdTest +{ + + [TestFixture] + public class AssignedFixture : IdFixtureBase + { + + private string[] GetAssignedIdentifierWarnings(LogSpy ls) + { + List<string> warnings = new List<string>(); + + foreach (string logEntry in ls.GetWholeLog().Split('\n')) + if (logEntry.Contains("Unable to determine if") && logEntry.Contains("is transient or detached")) + warnings.Add(logEntry); + + return warnings.ToArray(); + } + + protected override string TypeName + { + get { return "Assigned"; } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from Child").ExecuteUpdate(); + s.CreateQuery("delete from Parent").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void SaveOrUpdate_Save() + { + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.SaveOrUpdate(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(p) from Parent p").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(1)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(1)); + Assert.IsTrue(warnings[0].Contains("parent")); + } + } + + [Test] + public void SaveNoWarning() + { + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.Save(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(p) from Parent p").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(1)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + } + + [Test] + public void SaveOrUpdate_Update() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Parent() { Id = "parent", Name = "before" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Name = "after", + }; + + s.SaveOrUpdate(parent); + t.Commit(); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(1)); + Assert.IsTrue(warnings[0].Contains("parent")); + } + + using (ISession s = OpenSession()) + { + Parent parent = s.CreateQuery("from Parent").UniqueResult<Parent>(); + Assert.That(parent.Name, Is.EqualTo("after")); + } + } + + [Test] + public void UpdateNoWarning() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Parent() { Id = "parent", Name = "before" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Name = "after", + }; + + s.Update(parent); + t.Commit(); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + + using (ISession s = OpenSession()) + { + Parent parent = s.CreateQuery("from Parent").UniqueResult<Parent>(); + Assert.That(parent.Name, Is.EqualTo("after")); + } + } + + [Test] + public void InsertCascade() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Child() { Id = "detachedChild" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + parent.Children.Add(new Child() { Id = "detachedChild", Parent = parent }); + parent.Children.Add(new Child() { Id = "transientChild", Parent = parent }); + + s.Save(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(c) from Child c").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(2)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(2)); + Assert.IsTrue(warnings[0].Contains("detachedChild")); + Assert.IsTrue(warnings[1].Contains("transientChild")); + } + } + + [Test] + public void InsertCascadeNoWarning() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Child() { Id = "persistedChild" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.Save(parent); + + Child child1 = s.Load<Child>("persistedChild"); + child1.Parent = parent; + parent.Children.Add(child1); + + Child child2 = new Child() { Id = "transientChild", Parent = parent }; + s.Save(child2); + parent.Children.Add(child2); + + t.Commit(); + + long actual = s.CreateQuery("select count(c) from Child c").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(2)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + } + + } + +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1914 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void CascadeInsertAssigned() + { + IDS _IDS = new IDS(); + _IDS.Identifier = Guid.NewGuid().ToString(); + _IDS.Name = "IDS"; + _IDS.CRSPLUTs = new Dictionary<String, ListOfHLUT>(); + _IDS.CRSPLUTs.Add("a", new ListOfHLUT()); + + + HLUT _HLUT = new HLUT(); + _HLUT.Identifier = 1123; + _HLUT.Name = "HLUT"; + _HLUT.Entries = new List<Entry>(); + _HLUT.Entries.Add(new Entry(1.1, .1)); + _HLUT.Entries.Add(new Entry(2.2, .2)); + + _IDS.CRSPLUTs["a"].Values.Add(_HLUT); + + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.Save(_IDS); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + IDS _IDSRead = s.Load<IDS>(_IDS.Identifier); + + Assert.IsNotNull(_IDSRead); + Assert.IsNotNull(_IDSRead.CRSPLUTs); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"]); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"].Values[0]); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"].Values[0].Entries); + + s.Delete(_IDSRead); + t.Commit(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1914" + default-lazy="false"> + + <class name="IDS" table="IDS"> + <id name="Identifier"> + <generator class="assigned" /> + </id> + <property name="Name" not-null="true" /> + <map name="CRSPLUTs" table="CRSPLUTs" cascade="all-delete-orphan"> + <key column="ParentID"/> + <index column="OrganID" type="String"/> + <one-to-many class="ListOfHLUT"/> + </map> + </class> + + <class name="ListOfHLUT" table="ListOfHLUT"> + <id name="ID" column="CollectionID"> + <generator class="native" /> + </id> + <list name="Values" table="CustomValues" cascade="all"> + <key column="ParentID"/> + <index column="Indexer" type="Int32"/> + <one-to-many class="HLUT"/> + </list> + </class> + + <class name="HLUT" table="HLUT"> + + <!--NotWorking with below id generation.--> + <id name="Identifier" unsaved-value="0"> + <generator class="assigned" /> + </id> + + <!--Working with below id generation.--> + <!-- + <id name="Identifier" unsaved-value="any"> + <generator class="native" /> + </id>--> + + <property name="Name" not-null="true" /> + <list name="Entries" table="Entries" cascade="all"> + <key column="ParentID"/> + <index column="Indexer" type="Int32"/> + <composite-element class="Entry"> + <property name="Key1" type="Double" access="field" /> + <property name="Value" type="Double" access="field"/> + </composite-element> + </list> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,269 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1914 +{ + public class IDS + { + public String Identifier { get; set; } + + public String Name { get; set; } + + public IDictionary<String,ListOfHLUT> CRSPLUTs { get; set; } + } + + public class ListOfHLUT : CustomList<HLUT> + { + public ListOfHLUT() : base() { } + public ListOfHLUT(IEnumerable<HLUT> theValues) : base(theValues) { } + } + + public class HLUT : LUT + { + public String Name { get; set; } + } + + public class LUT + { + public long Identifier { get; set; } + + public IList<Entry> Entries { get; set; } + } + + public struct Entry + { + public Entry(Double theKey, Double theValue) + { + Key1 = theKey; + Value = theValue; + } + + public Double Key1; + + public Double Value; + } + + public class CustomList<T> : IList<T>, IList, ILifecycle + { + #region Constructors + + public CustomList() + { + myValues = new List<T>(); + } + + public CustomList(IEnumerable<T> theValues) + { + myValues = new List<T>(theValues); + } + #endregion + + #region Member Variables + protected IList<T> myValues; + #endregion + + #region NHibernate Members + [XmlIgnore] + public virtual String Identifier { get; set; } + + [XmlIgnore] + public virtual long ID { get; set; } + + [XmlIgnore] + public virtual IList<T> Values + { + get + { + return myValues; + } + set + { + myValues = value; + } + } + #endregion + + #region ILifecycle Members + + public LifecycleVeto OnDelete(ISession s) + { + return LifecycleVeto.NoVeto; + } + + public void OnLoad(ISession s, object id) + { + + } + + public LifecycleVeto OnSave(ISession s) + { + return LifecycleVeto.NoVeto; + } + + public LifecycleVeto OnUpdate(ISession s) + { + return LifecycleVeto.NoVeto; + } + + #endregion + + #region IList<T> Members + + public int IndexOf(T item) + { + return myValues.IndexOf(item); + } + + public void Insert(int index, T item) + { + myValues.Insert(index, item); + } + + public void RemoveAt(int index) + { + myValues.RemoveAt(index); + } + + public T this[int index] + { + get + { + return myValues[index]; + } + set + { + myValues[index] = value; + } + } + + #endregion + + #region ICollection<T> Members + + public void Add(T item) + { + myValues.Add(item); + } + + public void Clear() + { + myValues.Clear(); + } + + public bool Contains(T item) + { + return myValues.Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + myValues.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return myValues.Count; } + } + + public bool IsReadOnly + { + get { return myValues.IsReadOnly; } + } + + public bool Remove(T item) + { + return myValues.Remove(item); + } + + #endregion + + #region IEnumerable<T> Members + + public IEnumerator<T> GetEnumerator() + { + return myValues.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + #region IList Members + + public int Add(object value) + { + return ((IList)myValues).Add(value); + } + + public bool Contains(object value) + { + return ((IList)myValues).Contains(value); + } + + public int IndexOf(object value) + { + return ((IList)myValues).IndexOf(value); + } + + public void Insert(int index, object value) + { + ((IList)myValues).Insert(index, value); + } + + public bool IsFixedSize + { + get { return ((IList)myValues).IsFixedSize; } + } + + public void Remove(object value) + { + ((IList)myValues).Remove(value); + } + + object IList.this[int index] + { + get + { + return ((IList)myValues)[index]; + } + set + { + ((IList)myValues)[index] = value; + } + } + + #endregion + + #region ICollection Members + + public void CopyTo(Array array, int index) + { + ((IList)myValues).CopyTo(array, index); + } + + public bool IsSynchronized + { + get { return ((IList)myValues).IsSynchronized; } + } + + public object SyncRoot + { + get { return ((IList)myValues).SyncRoot; } + } + + #endregion + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-10 15:31:22 UTC (rev 4687) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-10 15:41:06 UTC (rev 4688) @@ -355,6 +355,8 @@ <Compile Include="HQL\Ast\WithClauseFixture.cs" /> <Compile Include="HQL\Ast\Zoo.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> + <Compile Include="IdTest\AssignedClass.cs" /> + <Compile Include="IdTest\AssignedFixture.cs" /> <Compile Include="IdTest\TableGeneratorFixture.cs" /> <Compile Include="LazyOneToOne\Employee.cs" /> <Compile Include="LazyOneToOne\Employment.cs" /> @@ -562,6 +564,8 @@ <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Model.cs" /> + <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1975,6 +1979,8 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="IdTest\AssignedClass.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1914\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-10 15:31:30
|
Revision: 4687 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4687&view=rev Author: ricbrown Date: 2009-08-10 15:31:22 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Fix NH-1914 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Engine/ForeignKeys.cs branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Engine/ForeignKeys.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Engine/ForeignKeys.cs 2009-08-08 17:49:24 UTC (rev 4686) +++ branches/2.1.x/nhibernate/src/NHibernate/Engine/ForeignKeys.cs 2009-08-10 15:31:22 UTC (rev 4687) @@ -1,3 +1,5 @@ +using log4net; +using NHibernate.Id; using NHibernate.Persister.Entity; using NHibernate.Proxy; using NHibernate.Type; @@ -7,6 +9,8 @@ /// <summary> Algorithms related to foreign key constraint transparency </summary> public static class ForeignKeys { + private static readonly ILog log = LogManager.GetLogger(typeof(ForeignKeys)); + public class Nullifier { private readonly bool isDelete; @@ -195,6 +199,17 @@ if (assumed.HasValue) return assumed.Value; + if (persister.IdentifierGenerator is Assigned) + { + // When using assigned identifiers we cannot tell if an entity + // is transient or detached without querying the database. + // This could potentially cause Select N+1 in cascaded saves, so warn the user. + log.Warn("Unable to determine if " + entity.ToString() + + " with assigned identifier " + persister.GetIdentifier(entity, session.EntityMode) + + " is transient or detached; querying the database." + + " Use explicit Save() or Update() in session to prevent this."); + } + // hit the database, after checking the session cache for a snapshot System.Object[] snapshot = session.PersistenceContext.GetDatabaseSnapshot(persister.GetIdentifier(entity, session.EntityMode), persister); Modified: branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-08-08 17:49:24 UTC (rev 4686) +++ branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-08-10 15:31:22 UTC (rev 4687) @@ -3630,7 +3630,19 @@ // check the id unsaved-value bool? result2 = entityMetamodel.IdentifierProperty.UnsavedValue.IsUnsaved(id); if (result2.HasValue) - return result2; + { + if (IdentifierGenerator is Assigned) + { + // if using assigned identifier, we can only make assumptions + // if the value is a known unsaved-value + if (result2.Value) + return true; + } + else + { + return result2; + } + } // check to see if it is in the second-level cache if (HasCache) Added: branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs 2009-08-10 15:31:22 UTC (rev 4687) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.IdTest +{ + public class Parent + { + public string Id { get; set; } + public string Name { get; set; } + public IList<Child> Children { get; set; } + } + + public class Child + { + public string Id { get; set; } + public Parent Parent { get; set; } + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml 2009-08-10 15:31:22 UTC (rev 4687) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false"> + + <class name="NHibernate.Test.IdTest.Parent, NHibernate.Test"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <bag name="Children" inverse="true" cascade="all"> + <key column="Parent"/> + <one-to-many class="NHibernate.Test.IdTest.Child, NHibernate.Test"/> + </bag> + </class> + + <class name="NHibernate.Test.IdTest.Child, NHibernate.Test"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <many-to-one name="Parent" class="NHibernate.Test.IdTest.Parent, NHibernate.Test" /> + </class> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs 2009-08-10 15:31:22 UTC (rev 4687) @@ -0,0 +1,255 @@ +using System; +using System.Collections.Generic; +using log4net; +using log4net.Core; +using NUnit.Framework; + +namespace NHibernate.Test.IdTest +{ + + [TestFixture] + public class AssignedFixture : IdFixtureBase + { + + private string[] GetAssignedIdentifierWarnings(LogSpy ls) + { + List<string> warnings = new List<string>(); + + foreach (string logEntry in ls.GetWholeLog().Split('\n')) + if (logEntry.Contains("Unable to determine if") && logEntry.Contains("is transient or detached")) + warnings.Add(logEntry); + + return warnings.ToArray(); + } + + protected override string TypeName + { + get { return "Assigned"; } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from Child").ExecuteUpdate(); + s.CreateQuery("delete from Parent").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void SaveOrUpdate_Save() + { + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.SaveOrUpdate(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(p) from Parent p").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(1)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(1)); + Assert.IsTrue(warnings[0].Contains("parent")); + } + } + + [Test] + public void SaveNoWarning() + { + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.Save(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(p) from Parent p").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(1)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + } + + [Test] + public void SaveOrUpdate_Update() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Parent() { Id = "parent", Name = "before" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Name = "after", + }; + + s.SaveOrUpdate(parent); + t.Commit(); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(1)); + Assert.IsTrue(warnings[0].Contains("parent")); + } + + using (ISession s = OpenSession()) + { + Parent parent = s.CreateQuery("from Parent").UniqueResult<Parent>(); + Assert.That(parent.Name, Is.EqualTo("after")); + } + } + + [Test] + public void UpdateNoWarning() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Parent() { Id = "parent", Name = "before" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Name = "after", + }; + + s.Update(parent); + t.Commit(); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + + using (ISession s = OpenSession()) + { + Parent parent = s.CreateQuery("from Parent").UniqueResult<Parent>(); + Assert.That(parent.Name, Is.EqualTo("after")); + } + } + + [Test] + public void InsertCascade() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Child() { Id = "detachedChild" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + parent.Children.Add(new Child() { Id = "detachedChild", Parent = parent }); + parent.Children.Add(new Child() { Id = "transientChild", Parent = parent }); + + s.Save(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(c) from Child c").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(2)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(2)); + Assert.IsTrue(warnings[0].Contains("detachedChild")); + Assert.IsTrue(warnings[1].Contains("transientChild")); + } + } + + [Test] + public void InsertCascadeNoWarning() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Child() { Id = "persistedChild" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.Save(parent); + + Child child1 = s.Load<Child>("persistedChild"); + child1.Parent = parent; + parent.Children.Add(child1); + + Child child2 = new Child() { Id = "transientChild", Parent = parent }; + s.Save(child2); + parent.Children.Add(child2); + + t.Commit(); + + long actual = s.CreateQuery("select count(c) from Child c").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(2)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + } + + } + +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs 2009-08-10 15:31:22 UTC (rev 4687) @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1914 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void CascadeInsertAssigned() + { + IDS _IDS = new IDS(); + _IDS.Identifier = Guid.NewGuid().ToString(); + _IDS.Name = "IDS"; + _IDS.CRSPLUTs = new Dictionary<String, ListOfHLUT>(); + _IDS.CRSPLUTs.Add("a", new ListOfHLUT()); + + + HLUT _HLUT = new HLUT(); + _HLUT.Identifier = 1123; + _HLUT.Name = "HLUT"; + _HLUT.Entries = new List<Entry>(); + _HLUT.Entries.Add(new Entry(1.1, .1)); + _HLUT.Entries.Add(new Entry(2.2, .2)); + + _IDS.CRSPLUTs["a"].Values.Add(_HLUT); + + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.Save(_IDS); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + IDS _IDSRead = s.Load<IDS>(_IDS.Identifier); + + Assert.IsNotNull(_IDSRead); + Assert.IsNotNull(_IDSRead.CRSPLUTs); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"]); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"].Values[0]); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"].Values[0].Entries); + + s.Delete(_IDSRead); + t.Commit(); + } + } + + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml 2009-08-10 15:31:22 UTC (rev 4687) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1914" + default-lazy="false"> + + <class name="IDS" table="IDS"> + <id name="Identifier"> + <generator class="assigned" /> + </id> + <property name="Name" not-null="true" /> + <map name="CRSPLUTs" table="CRSPLUTs" cascade="all-delete-orphan"> + <key column="ParentID"/> + <index column="OrganID" type="String"/> + <one-to-many class="ListOfHLUT"/> + </map> + </class> + + <class name="ListOfHLUT" table="ListOfHLUT"> + <id name="ID" column="CollectionID"> + <generator class="native" /> + </id> + <list name="Values" table="CustomValues" cascade="all"> + <key column="ParentID"/> + <index column="Indexer" type="Int32"/> + <one-to-many class="HLUT"/> + </list> + </class> + + <class name="HLUT" table="HLUT"> + + <!--NotWorking with below id generation.--> + <id name="Identifier" unsaved-value="0"> + <generator class="assigned" /> + </id> + + <!--Working with below id generation.--> + <!-- + <id name="Identifier" unsaved-value="any"> + <generator class="native" /> + </id>--> + + <property name="Name" not-null="true" /> + <list name="Entries" table="Entries" cascade="all"> + <key column="ParentID"/> + <index column="Indexer" type="Int32"/> + <composite-element class="Entry"> + <property name="Key1" type="Double" access="field" /> + <property name="Value" type="Double" access="field"/> + </composite-element> + </list> + </class> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs 2009-08-10 15:31:22 UTC (rev 4687) @@ -0,0 +1,269 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1914 +{ + public class IDS + { + public String Identifier { get; set; } + + public String Name { get; set; } + + public IDictionary<String,ListOfHLUT> CRSPLUTs { get; set; } + } + + public class ListOfHLUT : CustomList<HLUT> + { + public ListOfHLUT() : base() { } + public ListOfHLUT(IEnumerable<HLUT> theValues) : base(theValues) { } + } + + public class HLUT : LUT + { + public String Name { get; set; } + } + + public class LUT + { + public long Identifier { get; set; } + + public IList<Entry> Entries { get; set; } + } + + public struct Entry + { + public Entry(Double theKey, Double theValue) + { + Key1 = theKey; + Value = theValue; + } + + public Double Key1; + + public Double Value; + } + + public class CustomList<T> : IList<T>, IList, ILifecycle + { + #region Constructors + + public CustomList() + { + myValues = new List<T>(); + } + + public CustomList(IEnumerable<T> theValues) + { + myValues = new List<T>(theValues); + } + #endregion + + #region Member Variables + protected IList<T> myValues; + #endregion + + #region NHibernate Members + [XmlIgnore] + public virtual String Identifier { get; set; } + + [XmlIgnore] + public virtual long ID { get; set; } + + [XmlIgnore] + public virtual IList<T> Values + { + get + { + return myValues; + } + set + { + myValues = value; + } + } + #endregion + + #region ILifecycle Members + + public LifecycleVeto OnDelete(ISession s) + { + return LifecycleVeto.NoVeto; + } + + public void OnLoad(ISession s, object id) + { + + } + + public LifecycleVeto OnSave(ISession s) + { + return LifecycleVeto.NoVeto; + } + + public LifecycleVeto OnUpdate(ISession s) + { + return LifecycleVeto.NoVeto; + } + + #endregion + + #region IList<T> Members + + public int IndexOf(T item) + { + return myValues.IndexOf(item); + } + + public void Insert(int index, T item) + { + myValues.Insert(index, item); + } + + public void RemoveAt(int index) + { + myValues.RemoveAt(index); + } + + public T this[int index] + { + get + { + return myValues[index]; + } + set + { + myValues[index] = value; + } + } + + #endregion + + #region ICollection<T> Members + + public void Add(T item) + { + myValues.Add(item); + } + + public void Clear() + { + myValues.Clear(); + } + + public bool Contains(T item) + { + return myValues.Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + myValues.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return myValues.Count; } + } + + public bool IsReadOnly + { + get { return myValues.IsReadOnly; } + } + + public bool Remove(T item) + { + return myValues.Remove(item); + } + + #endregion + + #region IEnumerable<T> Members + + public IEnumerator<T> GetEnumerator() + { + return myValues.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + #region IList Members + + public int Add(object value) + { + return ((IList)myValues).Add(value); + } + + public bool Contains(object value) + { + return ((IList)myValues).Contains(value); + } + + public int IndexOf(object value) + { + return ((IList)myValues).IndexOf(value); + } + + public void Insert(int index, object value) + { + ((IList)myValues).Insert(index, value); + } + + public bool IsFixedSize + { + get { return ((IList)myValues).IsFixedSize; } + } + + public void Remove(object value) + { + ((IList)myValues).Remove(value); + } + + object IList.this[int index] + { + get + { + return ((IList)myValues)[index]; + } + set + { + ((IList)myValues)[index] = value; + } + } + + #endregion + + #region ICollection Members + + public void CopyTo(Array array, int index) + { + ((IList)myValues).CopyTo(array, index); + } + + public bool IsSynchronized + { + get { return ((IList)myValues).IsSynchronized; } + } + + public object SyncRoot + { + get { return ((IList)myValues).SyncRoot; } + } + + #endregion + } +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-08 17:49:24 UTC (rev 4686) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-10 15:31:22 UTC (rev 4687) @@ -343,6 +343,8 @@ <Compile Include="HQL\Ast\WithClauseFixture.cs" /> <Compile Include="HQL\Ast\Zoo.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> + <Compile Include="IdTest\AssignedClass.cs" /> + <Compile Include="IdTest\AssignedFixture.cs" /> <Compile Include="IdTest\TableGeneratorFixture.cs" /> <Compile Include="LazyOneToOne\Employee.cs" /> <Compile Include="LazyOneToOne\Employment.cs" /> @@ -550,6 +552,8 @@ <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Model.cs" /> + <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1960,6 +1964,8 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1914\Mappings.hbm.xml" /> + <EmbeddedResource Include="IdTest\AssignedClass.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1908\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-08 17:49:34
|
Revision: 4686 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4686&view=rev Author: davybrion Date: 2009-08-08 17:49:24 +0000 (Sat, 08 Aug 2009) Log Message: ----------- applied patch from Jakob Andersen for NH-1917 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-08-08 17:37:48 UTC (rev 4685) +++ branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-08-08 17:49:24 UTC (rev 4686) @@ -57,5 +57,15 @@ return "select uuid()"; } } + + public override SqlString AppendIdentitySelectToInsert (NHibernate.SqlCommand.SqlString insertString) + { + return insertString.Append(";" + IdentitySelectString); + } + + public override bool SupportsInsertSelectIdentity + { + get { return true; } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-08 17:37:57
|
Revision: 4685 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4685&view=rev Author: davybrion Date: 2009-08-08 17:37:48 +0000 (Sat, 08 Aug 2009) Log Message: ----------- applied patch from Jakob Andersen for NH-1917 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-08-05 19:58:32 UTC (rev 4684) +++ trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-08-08 17:37:48 UTC (rev 4685) @@ -57,5 +57,15 @@ return "select uuid()"; } } + + public override SqlString AppendIdentitySelectToInsert (NHibernate.SqlCommand.SqlString insertString) + { + return insertString.Append(";" + IdentitySelectString); + } + + public override bool SupportsInsertSelectIdentity + { + get { return true; } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-05 19:58:40
|
Revision: 4684 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4684&view=rev Author: davybrion Date: 2009-08-05 19:58:32 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Fix NH-1913 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-08-05 19:46:31 UTC (rev 4683) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-08-05 19:58:32 UTC (rev 4684) @@ -1,6 +1,7 @@ using System.Data; using System.Text; using NHibernate.AdoNet.Util; +using NHibernate.Util; namespace NHibernate.AdoNet { @@ -21,6 +22,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); + SetCommandTimeout(); //we always create this, because we need to deal with a scenario in which //the user change the logging configuration at runtime. Trying to put this //behind an if(log.IsDebugEnabled) will cause a null reference exception @@ -28,6 +30,26 @@ currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } + private void SetCommandTimeout() + { + int timeout = PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1); + + if (timeout > 0) + { + try + { + currentBatch.CommandTimeout = timeout; + } + catch (Exception e) + { + if (log.IsWarnEnabled) + { + log.Warn(e.ToString()); + } + } + } + } + public override int BatchSize { get { return batchSize; } Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2009-08-05 19:46:31 UTC (rev 4683) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2009-08-05 19:58:32 UTC (rev 4684) @@ -18,6 +18,7 @@ private object instance; private PropSetter<SqlConnection> connectionSetter; private PropSetter<SqlTransaction> transactionSetter; + private PropSetter<int> commandTimeoutSetter; private PropGetter<SqlConnection> connectionGetter; private SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand> commandGetter; private AppendCommand doAppend; @@ -41,6 +42,9 @@ transactionSetter = (PropSetter<SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter<SqlTransaction>), instance, "set_Transaction"); + commandTimeoutSetter = (PropSetter<int>) + Delegate.CreateDelegate(typeof(PropSetter<int>), + instance, "set_CommandTimeout"); connectionGetter = (PropGetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter<SqlConnection>), instance, "get_Connection"); @@ -130,6 +134,11 @@ set { transactionSetter(value); } } + public int CommandTimeout + { + set { commandTimeoutSetter(value); } + } + ///<summary> ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. ///</summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-05 19:46:38
|
Revision: 4683 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4683&view=rev Author: davybrion Date: 2009-08-05 19:46:31 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Fix NH-1913 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-08-04 19:52:18 UTC (rev 4682) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-08-05 19:46:31 UTC (rev 4683) @@ -1,6 +1,7 @@ using System.Data; using System.Text; using NHibernate.AdoNet.Util; +using NHibernate.Util; namespace NHibernate.AdoNet { @@ -21,6 +22,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); + SetCommandTimeout(); //we always create this, because we need to deal with a scenario in which //the user change the logging configuration at runtime. Trying to put this //behind an if(log.IsDebugEnabled) will cause a null reference exception @@ -28,6 +30,26 @@ currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } + private void SetCommandTimeout() + { + int timeout = PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1); + + if (timeout > 0) + { + try + { + currentBatch.CommandTimeout = timeout; + } + catch (Exception e) + { + if (log.IsWarnEnabled) + { + log.Warn(e.ToString()); + } + } + } + } + public override int BatchSize { get { return batchSize; } Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2009-08-04 19:52:18 UTC (rev 4682) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2009-08-05 19:46:31 UTC (rev 4683) @@ -18,6 +18,7 @@ private object instance; private PropSetter<SqlConnection> connectionSetter; private PropSetter<SqlTransaction> transactionSetter; + private PropSetter<int> commandTimeoutSetter; private PropGetter<SqlConnection> connectionGetter; private SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand> commandGetter; private AppendCommand doAppend; @@ -41,6 +42,9 @@ transactionSetter = (PropSetter<SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter<SqlTransaction>), instance, "set_Transaction"); + commandTimeoutSetter = (PropSetter<int>) + Delegate.CreateDelegate(typeof(PropSetter<int>), + instance, "set_CommandTimeout"); connectionGetter = (PropGetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter<SqlConnection>), instance, "get_Connection"); @@ -130,6 +134,11 @@ set { transactionSetter(value); } } + public int CommandTimeout + { + set { commandTimeoutSetter(value); } + } + ///<summary> ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. ///</summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-04 19:52:39
|
Revision: 4682 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4682&view=rev Author: davybrion Date: 2009-08-04 19:52:18 +0000 (Tue, 04 Aug 2009) Log Message: ----------- fix NH-1904 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs Property Changed: ---------------- trunk/nhibernate/src/ Property changes on: trunk/nhibernate/src ___________________________________________________________________ Modified: svn:mergeinfo - /branches/2.1.x/nhibernate/src:4659,4671 + /branches/2.1.x/nhibernate/src:4659,4671,4681 Modified: trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2009-08-04 19:35:21 UTC (rev 4681) +++ trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2009-08-04 19:52:18 UTC (rev 4682) @@ -130,13 +130,18 @@ return null; } - // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does - // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly - // stating that casing should be ignored so we get the same behavior for both structs and classes - PropertyInfo property = - type.GetProperty(propertyName, - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase); + BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; + if (type.IsValueType) + { + // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does + // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly + // stating that casing should be ignored so we get the same behavior for both structs and classes + bindingFlags = bindingFlags | BindingFlags.IgnoreCase; + } + + PropertyInfo property = type.GetProperty(propertyName, bindingFlags); + if (property != null && property.CanWrite) { return new BasicSetter(type, property, propertyName); Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs 2009-08-04 19:35:21 UTC (rev 4681) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs 2009-08-04 19:52:18 UTC (rev 4682) @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; - -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH1904 -{ - [TestFixture] - public class Fixture : BugTestCase - { - [Test] - public void ExecuteQuery() - { - using (ISession session = OpenSession()) - using (ITransaction transaction = session.BeginTransaction()) - { - Invoice invoice = new Invoice(); - invoice.Issued = DateTime.Now; - - session.Save(invoice); - transaction.Commit(); - } - - using (ISession session = OpenSession()) - { - IList<Invoice> invoices = session.CreateCriteria<Invoice>().List<Invoice>(); - } - } - - protected override void OnTearDown() - { - base.OnTearDown(); - using (ISession session = OpenSession()) - { - session.CreateQuery("delete from Invoice").ExecuteUpdate(); - session.Flush(); - } - } - } -} Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs (from rev 4681, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs 2009-08-04 19:52:18 UTC (rev 4682) @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; + +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1904 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void ExecuteQuery() + { + using (ISession session = OpenSession()) + using (ITransaction transaction = session.BeginTransaction()) + { + Invoice invoice = new Invoice(); + invoice.Issued = DateTime.Now; + + session.Save(invoice); + transaction.Commit(); + } + + using (ISession session = OpenSession()) + { + IList<Invoice> invoices = session.CreateCriteria<Invoice>().List<Invoice>(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + session.CreateQuery("delete from Invoice").ExecuteUpdate(); + session.Flush(); + } + } + } +} Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml 2009-08-04 19:35:21 UTC (rev 4681) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml 2009-08-04 19:52:18 UTC (rev 4682) @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" - assembly="NHibernate.Test" - namespace="NHibernate.Test.NHSpecificTest.NH1904"> - - <class name="Invoice"> - <id name="ID" type="Int32"> - <generator class="hilo" /> - </id> - - <property name="Issued" type="DateTime" /> - </class> - -</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml (from rev 4681, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml 2009-08-04 19:52:18 UTC (rev 4682) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1904"> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <property name="Issued" type="DateTime" /> + </class> + +</hibernate-mapping> Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs 2009-08-04 19:35:21 UTC (rev 4681) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs 2009-08-04 19:52:18 UTC (rev 4682) @@ -1,12 +0,0 @@ -using System; - -namespace NHibernate.Test.NHSpecificTest.NH1904 -{ - public class Invoice - { - public virtual int ID { get; private set; } - public virtual DateTime Issued { get; set; } - - protected virtual DateTime issued { get; set; } - } -} Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs (from rev 4681, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs 2009-08-04 19:52:18 UTC (rev 4682) @@ -0,0 +1,12 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1904 +{ + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime Issued { get; set; } + + protected virtual DateTime issued { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 19:35:21 UTC (rev 4681) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 19:52:18 UTC (rev 4682) @@ -556,6 +556,8 @@ <Compile Include="NHSpecificTest\NH1898\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> + <Compile Include="NHSpecificTest\NH1904\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1904\Model.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> @@ -1973,6 +1975,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-04 19:35:30
|
Revision: 4681 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4681&view=rev Author: davybrion Date: 2009-08-04 19:35:21 +0000 (Tue, 04 Aug 2009) Log Message: ----------- fix NH-1904 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2009-08-04 12:51:17 UTC (rev 4680) +++ branches/2.1.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2009-08-04 19:35:21 UTC (rev 4681) @@ -130,13 +130,18 @@ return null; } - // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does - // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly - // stating that casing should be ignored so we get the same behavior for both structs and classes - PropertyInfo property = - type.GetProperty(propertyName, - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase); + BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; + if (type.IsValueType) + { + // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does + // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly + // stating that casing should be ignored so we get the same behavior for both structs and classes + bindingFlags = bindingFlags | BindingFlags.IgnoreCase; + } + + PropertyInfo property = type.GetProperty(propertyName, bindingFlags); + if (property != null && property.CanWrite) { return new BasicSetter(type, property, propertyName); Copied: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs (from rev 4680, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs) =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs 2009-08-04 19:35:21 UTC (rev 4681) @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; + +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1904 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void ExecuteQuery() + { + using (ISession session = OpenSession()) + using (ITransaction transaction = session.BeginTransaction()) + { + Invoice invoice = new Invoice(); + invoice.Issued = DateTime.Now; + + session.Save(invoice); + transaction.Commit(); + } + + using (ISession session = OpenSession()) + { + IList<Invoice> invoices = session.CreateCriteria<Invoice>().List<Invoice>(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + session.CreateQuery("delete from Invoice").ExecuteUpdate(); + session.Flush(); + } + } + } +} Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Fixture.cs ___________________________________________________________________ Added: svn:mergeinfo + /trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs:4657 Copied: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml (from rev 4680, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml) =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml 2009-08-04 19:35:21 UTC (rev 4681) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1904"> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <property name="Issued" type="DateTime" /> + </class> + +</hibernate-mapping> Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Mappings.hbm.xml ___________________________________________________________________ Added: svn:mergeinfo + /trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml:4657 Copied: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs (from rev 4680, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs) =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs 2009-08-04 19:35:21 UTC (rev 4681) @@ -0,0 +1,12 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1904 +{ + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime Issued { get; set; } + + protected virtual DateTime issued { get; set; } + } +} Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs ___________________________________________________________________ Added: svn:mergeinfo + /trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs:4657 Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:51:17 UTC (rev 4680) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 19:35:21 UTC (rev 4681) @@ -544,6 +544,8 @@ <Compile Include="NHSpecificTest\NH1898\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> + <Compile Include="NHSpecificTest\NH1904\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1904\Model.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> @@ -1958,6 +1960,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1908\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-04 12:51:24
|
Revision: 4680 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4680&view=rev Author: ricbrown Date: 2009-08-04 12:51:17 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Merge r4679 (Fix NH-1908) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-04 12:49:38 UTC (rev 4679) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-04 12:51:17 UTC (rev 4680) @@ -72,19 +72,13 @@ // NH Different behaviour NH-1776 // Analyze all named parameters declared after filters // in general all named parameters but depend on the complexity of the query (see sub query) - foreach (ParameterInfo entry in _namedParameters.Values) + RestoreOriginalParameterLocations(); + foreach (int filterParameterLocation in parameters.FilteredParameterLocations) { - int amountOfPush = 0; - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) + foreach (ParameterInfo entry in _namedParameters.Values) { - // a parameter span, at least, one value; where span more than one all values are cosecutive - // the first position determines the position of the others values - if (entry.SqlLocations[0]+amountOfPush >= existingParameterLocation) - { - amountOfPush++; - } + entry.IncrementLocationAfterFilterLocation(filterParameterLocation); } - entry.IncrementLocation(amountOfPush); } } @@ -123,6 +117,14 @@ get { return _ordinalParameters.Length; } } + private void RestoreOriginalParameterLocations() + { + foreach (ParameterInfo entry in _namedParameters.Values) + { + entry.RestoreOriginalParameterLocations(); + } + } + private ParameterInfo GetOrdinalParameterInfo(int ordinalPosition) { // remember that ordinal parameters numbers are 1-based!!! @@ -169,15 +171,22 @@ public IType ExpectedType { get; private set; } - public void IncrementLocation(int amountOfPush) + public void RestoreOriginalParameterLocations() { - if(amountOfPush <= 0) + for (int i = 0; i < sqlLocations.Length; i++) { - return; // short cut + sqlLocations[i] = originalLocation[i]; } + } + + public void IncrementLocationAfterFilterLocation(int filterParameterLocation) + { for (int i = 0; i < sqlLocations.Length; i++) { - sqlLocations[i] = originalLocation[i] + amountOfPush; + if (sqlLocations[i] >= filterParameterLocation) + { + sqlLocations[i]++; + } } } } Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2009-08-04 12:51:17 UTC (rev 4680) @@ -0,0 +1,35 @@ +using System; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1908 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void QueryPropertyInBothFilterAndQuery() + { + using (ISession s = OpenSession()) + { + s.EnableFilter("validity") + .SetParameter("date", DateTime.Now); + + s.CreateQuery(@" + select + inv.ID + from + Invoice inv + join inv.Category cat with cat.ValidUntil > :now + left join cat.ParentCategory parentCat + where + inv.ID = :invId + and inv.Issued < :now + ") + .SetDateTime("now", DateTime.Now) + .SetInt32("invId", -999) + .List(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml 2009-08-04 12:51:17 UTC (rev 4680) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1908"> + + <class name="Category"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + <property name="ValidUntil" type="DateTime" /> + <many-to-one name="ParentCategory" column="CategoryId" class="Category" /> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <many-to-one name="Category" column="CategoryId" class="Category" /> + <property name="Issued" type="DateTime" /> + </class> + + <filter-def name="validity"> + <filter-param name="date" type="DateTime"/> + </filter-def> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2009-08-04 12:51:17 UTC (rev 4680) @@ -0,0 +1,18 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1908 +{ + public class Category + { + public virtual int ID { get; private set; } + public virtual Category ParentCategory { get; set; } + public virtual DateTime ValidUntil { get; set; } + } + + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime Issued { get; set; } + public virtual Category Category { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:49:38 UTC (rev 4679) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:51:17 UTC (rev 4680) @@ -558,6 +558,8 @@ <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> + <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1974,6 +1976,7 @@ <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1908\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1898\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-04 12:49:55
|
Revision: 4679 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4679&view=rev Author: ricbrown Date: 2009-08-04 12:49:38 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Fix NH-1908 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-03 22:45:29 UTC (rev 4678) +++ branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-04 12:49:38 UTC (rev 4679) @@ -72,19 +72,13 @@ // NH Different behaviour NH-1776 // Analyze all named parameters declared after filters // in general all named parameters but depend on the complexity of the query (see sub query) - foreach (ParameterInfo entry in _namedParameters.Values) + RestoreOriginalParameterLocations(); + foreach (int filterParameterLocation in parameters.FilteredParameterLocations) { - int amountOfPush = 0; - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) + foreach (ParameterInfo entry in _namedParameters.Values) { - // a parameter span, at least, one value; where span more than one all values are cosecutive - // the first position determines the position of the others values - if (entry.SqlLocations[0]+amountOfPush >= existingParameterLocation) - { - amountOfPush++; - } + entry.IncrementLocationAfterFilterLocation(filterParameterLocation); } - entry.IncrementLocation(amountOfPush); } } @@ -123,6 +117,14 @@ get { return _ordinalParameters.Length; } } + private void RestoreOriginalParameterLocations() + { + foreach (ParameterInfo entry in _namedParameters.Values) + { + entry.RestoreOriginalParameterLocations(); + } + } + private ParameterInfo GetOrdinalParameterInfo(int ordinalPosition) { // remember that ordinal parameters numbers are 1-based!!! @@ -169,15 +171,22 @@ public IType ExpectedType { get; private set; } - public void IncrementLocation(int amountOfPush) + public void RestoreOriginalParameterLocations() { - if(amountOfPush <= 0) + for (int i = 0; i < sqlLocations.Length; i++) { - return; // short cut + sqlLocations[i] = originalLocation[i]; } + } + + public void IncrementLocationAfterFilterLocation(int filterParameterLocation) + { for (int i = 0; i < sqlLocations.Length; i++) { - sqlLocations[i] = originalLocation[i] + amountOfPush; + if (sqlLocations[i] >= filterParameterLocation) + { + sqlLocations[i]++; + } } } } Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2009-08-04 12:49:38 UTC (rev 4679) @@ -0,0 +1,35 @@ +using System; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1908 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void QueryPropertyInBothFilterAndQuery() + { + using (ISession s = OpenSession()) + { + s.EnableFilter("validity") + .SetParameter("date", DateTime.Now); + + s.CreateQuery(@" + select + inv.ID + from + Invoice inv + join inv.Category cat with cat.ValidUntil > :now + left join cat.ParentCategory parentCat + where + inv.ID = :invId + and inv.Issued < :now + ") + .SetDateTime("now", DateTime.Now) + .SetInt32("invId", -999) + .List(); + } + } + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml 2009-08-04 12:49:38 UTC (rev 4679) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1908"> + + <class name="Category"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + <property name="ValidUntil" type="DateTime" /> + <many-to-one name="ParentCategory" column="CategoryId" class="Category" /> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <many-to-one name="Category" column="CategoryId" class="Category" /> + <property name="Issued" type="DateTime" /> + </class> + + <filter-def name="validity"> + <filter-param name="date" type="DateTime"/> + </filter-def> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2009-08-04 12:49:38 UTC (rev 4679) @@ -0,0 +1,18 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1908 +{ + public class Category + { + public virtual int ID { get; private set; } + public virtual Category ParentCategory { get; set; } + public virtual DateTime ValidUntil { get; set; } + } + + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime Issued { get; set; } + public virtual Category Category { get; set; } + } +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-03 22:45:29 UTC (rev 4678) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:49:38 UTC (rev 4679) @@ -546,6 +546,8 @@ <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1956,6 +1958,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1908\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-08-03 22:45:45
|
Revision: 4678 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4678&view=rev Author: fabiomaulo Date: 2009-08-03 22:45:29 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Merge r4677 (Refactoring filter-def check first step) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs trunk/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml trunk/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-08-03 22:25:32 UTC (rev 4677) +++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-08-03 22:45:29 UTC (rev 4678) @@ -5,6 +5,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; +using System.Text; using System.Xml; using System.Xml.Schema; using Iesi.Collections; @@ -61,6 +62,7 @@ protected IDictionary<string, NHibernate.Mapping.Collection> collections; protected IDictionary<string, Table> tables; protected IList<SecondPassCommand> secondPasses; + protected Queue<FilterSecondPassArgs> filtersSecondPasses; protected IList<Mappings.PropertyReference> propertyReferences; private IInterceptor interceptor; private IDictionary<string, string> properties; @@ -113,6 +115,7 @@ tableNameBinding = GetSerialedObject<IDictionary<string, Mappings.TableDescription>>(info, "tableNameBinding"); tables = GetSerialedObject<IDictionary<string, Table>>(info, "tables"); typeDefs = GetSerialedObject<IDictionary<string, TypeDef>>(info, "typeDefs"); + filtersSecondPasses = GetSerialedObject<Queue<FilterSecondPassArgs>>(info, "filtersSecondPasses"); } private T GetSerialedObject<T>(SerializationInfo info, string name) @@ -151,6 +154,7 @@ info.AddValue("tableNameBinding", tableNameBinding); info.AddValue("tables", tables); info.AddValue("typeDefs", typeDefs); + info.AddValue("filtersSecondPasses", filtersSecondPasses); } #endregion @@ -179,7 +183,7 @@ extendsQueue = new HashedSet<ExtendsQueueEntry>(); tableNameBinding = new Dictionary<string, Mappings.TableDescription>(); columnNameBindingPerTable = new Dictionary<Table, Mappings.ColumnNames>(); - + filtersSecondPasses = new Queue<FilterSecondPassArgs>(); } [Serializable] private class Mapping : IMapping @@ -520,7 +524,7 @@ { ProcessPreMappingBuildProperties(); return new Mappings(classes, collections, tables, NamedQueries, NamedSQLQueries, SqlResultSetMappings, Imports, - secondPasses, propertyReferences, namingStrategy, typeDefs, FilterDefinitions, extendsQueue, + secondPasses, filtersSecondPasses, propertyReferences, namingStrategy, typeDefs, FilterDefinitions, extendsQueue, auxiliaryDatabaseObjects, tableNameBinding, columnNameBindingPerTable, defaultAssembly, defaultNamespace, dialect); } @@ -904,6 +908,69 @@ private void Validate() { + ValidateEntities(); + + ValidateCollections(); + + ValidateFilterDefs(); + } + + private void ValidateFilterDefs() + { + var filterNames = new HashedSet<string>(); + foreach (var filterDefinition in FilterDefinitions) + { + if(filterDefinition.Value == null) + { + // a class/collection has a filter but the filter-def was not added. + filterNames.Add(filterDefinition.Key); + } + } + if(filterNames.Count > 0) + { + var message = new StringBuilder(); + message.Append("filter-def for filter named "); + foreach (var filterName in filterNames) + { + message.AppendLine(filterName); + } + message.AppendLine("was not found."); + throw new MappingException(message.ToString()); + } + + // check filter-def without reference + if (FilterDefinitions.Count > 0) + { + filterNames.Clear(); + var filterables = new JoinedEnumerable(ClassMappings, CollectionMappings); + foreach (IFilterable filterable in filterables) + { + filterNames.AddAll(filterable.FilterMap.Keys); + } + foreach (var filterName in FilterDefinitions.Keys) + { + if (!filterNames.Contains(filterName)) + { + // if you are going to remove this exception at least add a log.Error + // because the usage of filter-def, outside its scope, may cause unexpected behaviour + // during queries. + throw new MappingException("filter-def for filter named '" + filterName + + "' was never used to filter classes nor collections."); + } + } + } + } + + private void ValidateCollections() + { + foreach (var col in collections.Values) + { + col.Validate(mapping); + } + } + + private void ValidateEntities() + { bool validateProxy = PropertiesHelper.GetBoolean(Environment.UseProxyValidator, properties, true); HashedSet<string> allProxyErrors = null; IProxyValidator pvalidator = Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator; @@ -933,11 +1000,6 @@ { throw new InvalidProxyTypeException(allProxyErrors); } - - foreach (var col in collections.Values) - { - col.Validate(mapping); - } } private static ICollection<string> ValidateProxyInterface(PersistentClass persistentClass, IProxyValidator validator) @@ -1007,6 +1069,23 @@ { SecondPassCompileForeignKeys(table, done); } + + log.Info("processing filters (second pass)"); + foreach (var filterSecondPassArgs in filtersSecondPasses) + { + FilterDefinition filterDef; + var filterName = filterSecondPassArgs.FilterName; + FilterDefinitions.TryGetValue(filterName, out filterDef); + if(filterDef == null) + { + throw new MappingException("filter-def for filter named " + filterName + " was not found."); + } + if(string.IsNullOrEmpty(filterDef.DefaultFilterCondition)) + { + throw new MappingException("no filter condition found for filter: " + filterName); + } + filterSecondPassArgs.Filterable.FilterMap[filterName] = filterDef.DefaultFilterCondition; + } } private void SecondPassCompileForeignKeys(Table table, ISet done) @@ -2189,4 +2268,4 @@ } -} \ No newline at end of file +} Added: trunk/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs 2009-08-03 22:45:29 UTC (rev 4678) @@ -0,0 +1,28 @@ +using System; +using NHibernate.Mapping; + +namespace NHibernate.Cfg +{ + [Serializable] + public class FilterSecondPassArgs + { + // this class is NH specific to solve problems generated by 'order of mapping-doc' + // to assign the condition of a filter. + public FilterSecondPassArgs(IFilterable filterable, string filterName) + { + if (filterable == null) + { + throw new ArgumentNullException("filterable"); + } + if (string.IsNullOrEmpty(filterName)) + { + throw new ArgumentNullException("filterName"); + } + Filterable = filterable; + FilterName = filterName; + } + + public IFilterable Filterable{ get; private set;} + public string FilterName { get; private set; } + } +} Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2009-08-03 22:25:32 UTC (rev 4677) +++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2009-08-03 22:45:29 UTC (rev 4678) @@ -69,6 +69,7 @@ private readonly IList<PropertyReference> propertyReferences; private readonly IDictionary<string, FilterDefinition> filterDefinitions; private readonly IList<IAuxiliaryDatabaseObject> auxiliaryDatabaseObjects; + private readonly Queue<FilterSecondPassArgs> filtersSecondPasses; private readonly INamingStrategy namingStrategy; @@ -98,6 +99,7 @@ IDictionary<string, ResultSetMappingDefinition> resultSetMappings, IDictionary<string, string> imports, IList<SecondPassCommand> secondPasses, + Queue<FilterSecondPassArgs> filtersSecondPasses, IList<PropertyReference> propertyReferences, INamingStrategy namingStrategy, IDictionary<string, TypeDef> typeDefs, @@ -108,7 +110,7 @@ IDictionary<Table, ColumnNames> columnNameBindingPerTable, string defaultAssembly, string defaultNamespace, - Dialect.Dialect dialect) + Dialect.Dialect dialect) { this.classes = classes; this.collections = collections; @@ -129,6 +131,7 @@ this.defaultAssembly = defaultAssembly; this.defaultNamespace = defaultNamespace; this.dialect = dialect; + this.filtersSecondPasses = filtersSecondPasses; } /// <summary> @@ -454,12 +457,22 @@ public void AddFilterDefinition(FilterDefinition definition) { - filterDefinitions.Add(definition.FilterName, definition); + FilterDefinition fd; + if (filterDefinitions.TryGetValue(definition.FilterName, out fd)) + { + if(fd!=null) + { + throw new MappingException("Duplicated filter-def named: " + definition.FilterName); + } + } + filterDefinitions[definition.FilterName] = definition; } public FilterDefinition GetFilterDefinition(string name) { - return filterDefinitions[name]; + FilterDefinition result; + filterDefinitions.TryGetValue(name, out result); + return result; } public void AddAuxiliaryDatabaseObject(IAuxiliaryDatabaseObject auxiliaryDatabaseObject) @@ -638,6 +651,34 @@ return persistentClass; } + public void ExpectedFilterDefinition(IFilterable filterable, string filterName, string condition) + { + var fdef = GetFilterDefinition(filterName); + if (string.IsNullOrEmpty(condition)) + { + if (fdef != null) + { + // where immediately available, apply the condition + condition = fdef.DefaultFilterCondition; + } + } + if (string.IsNullOrEmpty(condition) && fdef == null) + { + log.Debug(string.Format("Adding filter second pass [{0}]", filterName)); + filtersSecondPasses.Enqueue(new FilterSecondPassArgs(filterable, filterName)); + } + else if (string.IsNullOrEmpty(condition) && fdef != null) + { + // Both sides does not have condition + throw new MappingException("no filter condition found for filter: " + filterName); + } + + if (fdef == null) + { + // if not available add an expected filter definition + FilterDefinitions[filterName] = null; + } + } } public delegate void SecondPassCommand(IDictionary<string, PersistentClass> persistentClasses); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-08-03 22:25:32 UTC (rev 4677) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-08-03 22:45:29 UTC (rev 4678) @@ -1017,17 +1017,19 @@ condition = (propertyNameNode == null) ? null : propertyNameNode.Value; } - //TODO: bad implementation, cos it depends upon ordering of mapping doc - // fixing this requires that Collection/PersistentClass gain access - // to the Mappings reference from Configuration (or the filterDefinitions - // map directly) sometime during Configuration.buildSessionFactory - // (after all the types/filter-defs are known and before building - // persisters). if (StringHelper.IsEmpty(condition)) - condition = mappings.GetFilterDefinition(name).DefaultFilterCondition; - if (condition == null) - throw new MappingException("no filter condition found for filter: " + name); - log.Debug("Applying filter [" + name + "] as [" + condition + "]"); + { + var fdef = mappings.GetFilterDefinition(name); + if (fdef != null) + { + // where immediately available, apply the condition + condition = fdef.DefaultFilterCondition; + } + } + + mappings.ExpectedFilterDefinition(filterable, name, condition); + + log.Debug(string.Format("Applying filter [{0}] as [{1}]", name, condition)); filterable.AddFilter(name, condition); } Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-03 22:25:32 UTC (rev 4677) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-03 22:45:29 UTC (rev 4678) @@ -460,6 +460,7 @@ <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> <Compile Include="Cfg\EntityCacheUsage.cs" /> + <Compile Include="Cfg\FilterSecondPassArgs.cs" /> <Compile Include="Cfg\Hbm2ddlKeyWords.cs" /> <Compile Include="Cfg\Loquacious\CacheConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ConfigurationExtensions.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs 2009-08-03 22:45:29 UTC (rev 4678) @@ -0,0 +1,244 @@ +using System.Collections.Generic; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.FilterTest +{ + [TestFixture] + public class ConfigFixture + { + private class ConfigurationStub: Configuration + { + public Queue<FilterSecondPassArgs> FiltersSecondPasses { get { return filtersSecondPasses; } } + } + + private static ConfigurationStub GetConfiguration() + { + var result = new ConfigurationStub(); + if (TestConfigurationHelper.hibernateConfigFile != null) + result.Configure(TestConfigurationHelper.hibernateConfigFile); + return result; + } + + [Test] + [Description("Add a class with filters without condition should not Throw exceptions and add secondpass tasks.")] + public void AddClassWithFilters() + { + var cfg = GetConfiguration(); + Assert.DoesNotThrow(() => cfg.AddResource("NHibernate.Test.FilterTest.SimpleFiltered.hbm.xml", GetType().Assembly)); + Assert.That(cfg.FiltersSecondPasses.Count, Is.EqualTo(2)); + } + + [Test] + [Description("Add filters-def should change conditions of class filters")] + public void AddFilterDefToClassWithFilters() + { + var cfg = GetConfiguration(); + cfg.AddResource("NHibernate.Test.FilterTest.SimpleFiltered.hbm.xml", GetType().Assembly); + cfg.AddResource("NHibernate.Test.FilterTest.SimpleFilteredFiltersDefsOk.hbm.xml", GetType().Assembly); + Assert.That(cfg.FilterDefinitions, Is.Not.Empty); + cfg.BuildMappings(); + var pc = cfg.GetClassMapping(typeof (TestClass)); + foreach (var filterMap in pc.FilterMap) + { + Assert.That(filterMap.Value, Is.Not.Null & Is.Not.Empty, "filtername:" + filterMap.Key); + } + } + + [Test] + [Description("Filter def without condition in both sides should throw exception")] + public void WrongFilterDefInClass() + { + var cfg = GetConfiguration(); + var e = Assert.Throws<MappingException>(() => cfg.AddResource("NHibernate.Test.FilterTest.WrongFilterDefInClass.hbm.xml", GetType().Assembly)); + Assert.That(e.InnerException, Is.Not.Null); + Assert.That(e.InnerException.Message, Text.StartsWith("no filter condition").IgnoreCase); + } + + [Test] + [Description("Filter def without condition in both sides should throw exception even in secondpass")] + public void WrongFilterDefInClassSeconPass() + { + const string wrongClassMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter'/> + </class> + +</hibernate-mapping>"; + + const string wrongFilterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(wrongClassMap); + cfg.AddXmlString(wrongFilterDef); + var e = Assert.Throws<MappingException>(cfg.BuildMappings); + Assert.That(e.Message, Text.StartsWith("no filter condition").IgnoreCase); + } + + [Test] + [Description("Add a class with filters without condition should Throw exceptions at secondpass.")] + public void AddClassWithFiltersWithoutFilterDef() + { + var cfg = GetConfiguration(); + cfg.AddResource("NHibernate.Test.FilterTest.SimpleFiltered.hbm.xml", GetType().Assembly); + var e = Assert.Throws<MappingException>(cfg.BuildMappings); + Assert.That(e.Message, Text.StartsWith("filter-def for filter named")); + Assert.That(e.Message, Text.Contains("was not found")); + } + + [Test] + [Description("Class filter with condition does not add secondpass and add an invalid filter-def")] + public void ClassNoSecondPass() + { + const string classMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter' condition=':LiveParam = Live'/> + </class> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(classMap); + Assert.That(cfg.FiltersSecondPasses.Count, Is.EqualTo(0)); + Assert.That(cfg.FilterDefinitions.Keys, Has.Member("LiveFilter")); + Assert.That(cfg.FilterDefinitions["LiveFilter"], Is.Null); + } + + [Test] + [Description("Writing the condition in both sides should not change the condition defined in the class.")] + public void ClassConditionInBothSides() + { + const string classMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter' condition='Live = 1'/> + </class> + +</hibernate-mapping>"; + + const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter' condition=':LiveParam = Live'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(classMap); + cfg.AddXmlString(filterDef); + Assert.That(cfg.FiltersSecondPasses.Count, Is.EqualTo(0)); + Assert.That(cfg.FilterDefinitions.Keys, Has.Member("LiveFilter")); + Assert.That(cfg.FilterDefinitions["LiveFilter"], Is.Not.Null); + + cfg.BuildMappings(); + Assert.That(cfg.FilterDefinitions.Count, Is.EqualTo(1)); + + var pc = cfg.GetClassMapping(typeof(TestClass)); + Assert.That(pc.FilterMap["LiveFilter"], Is.EqualTo("Live = 1")); + } + + [Test] + [Description("Filter-def duplication should Throw exception")] + public void DuplicatedFilterDef() + { + const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + var e = Assert.Throws<MappingException>(() => cfg.AddXmlString(filterDef)); + Assert.That(e.InnerException, Is.Not.Null); + Assert.That(e.InnerException.Message, Text.Contains("Duplicated filter-def")); + } + + [Test] + [Description("Add a filtered class with condition but without a filter-def should Throw exception")] + public void MissedFilterDef() + { + const string classMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter' condition='Live = 1'/> + </class> + +</hibernate-mapping>"; + var cfg = GetConfiguration(); + cfg.AddXmlString(classMap); + var e = Assert.Throws<MappingException>(()=>cfg.BuildSessionFactory()); + Assert.That(e.Message, Text.StartsWith("filter-def for filter named")); + Assert.That(e.Message, Text.Contains("was not found")); + } + + [Test] + [Description("Filter-def without reference to it should Throw exception")] + public void FilterDefWithoutReference() + { + const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(filterDef); + var e = Assert.Throws<MappingException>(() => cfg.BuildSessionFactory()); + Assert.That(e.Message, Text.StartsWith("filter-def for filter named")); + Assert.That(e.Message, Text.Contains("was never used to filter classes nor collections.")); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs 2009-08-03 22:45:29 UTC (rev 4678) @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using NHibernate.Mapping; +using NUnit.Framework; +using NHibernate.Cfg; + +namespace NHibernate.Test.FilterTest +{ + [TestFixture] + public class FilterSecondPassArgsFixture + { + public class FakeFilterable: IFilterable + { + public void AddFilter(string name, string condition) + { + throw new NotImplementedException(); + } + + public IDictionary<string, string> FilterMap + { + get { throw new NotImplementedException(); } + } + } + [Test] + public void CtorProtection() + { + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(null, "")); + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(null, "a>1")); + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(new FakeFilterable(), null)); + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(new FakeFilterable(), "")); + Assert.DoesNotThrow(() => new FilterSecondPassArgs(new FakeFilterable(), "a>1")); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml 2009-08-03 22:45:29 UTC (rev 4678) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + default-lazy="false" + assembly="NHibernate.Test" + namespace="NHibernate.Test.FilterTest" > + + <class name="TestClass"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + <property name="Name"/> + <property name="Live" type="Boolean" /> + <filter name="LiveFilter" /> + <filter name="LiveFilter2" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml 2009-08-03 22:45:29 UTC (rev 4678) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> + + <filter-def name="LiveFilter" condition=":LiveParam = Live"> + <filter-param name="LiveParam" type="boolean"/> + </filter-def> + + <filter-def name="LiveFilter2"> + <![CDATA[Name = :LiveParam2]]> + <filter-param name="LiveParam2" type="string"/> + </filter-def> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml 2009-08-03 22:45:29 UTC (rev 4678) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + default-lazy="false" + assembly="NHibernate.Test" + namespace="NHibernate.Test.FilterTest" > + + <class name="TestClass"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + <property name="Name" type="StringClob" length="100000" /> + + <property name="Live" type="Boolean" /> + <filter name="LiveFilter"/> + </class> + + <filter-def name="LiveFilter"> + <filter-param name="LiveParam" type="boolean"/> + </filter-def> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml 2009-08-03 22:25:32 UTC (rev 4677) +++ trunk/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml 2009-08-03 22:45:29 UTC (rev 4678) @@ -19,8 +19,4 @@ <filter-def name="seniorSalespersons"> <filter-param name="asOfDate" type="DateTime"/> </filter-def> - - <filter-def name="cat"> - <filter-param name="catId" type="long"/> - </filter-def> </hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-03 22:25:32 UTC (rev 4677) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-03 22:45:29 UTC (rev 4678) @@ -271,10 +271,12 @@ <Compile Include="Extralazy\User.cs" /> <Compile Include="FilterTest\BinaryFiltered.cs" /> <Compile Include="FilterTest\Category.cs" /> + <Compile Include="FilterTest\ConfigFixture.cs" /> <Compile Include="FilterTest\Department.cs" /> <Compile Include="FilterTest\DynamicFilterTest.cs" /> <Compile Include="FilterTest\FilterBinaryParameterTest.cs" /> <Compile Include="FilterTest\FilterConfig.cs" /> + <Compile Include="FilterTest\FilterSecondPassArgsFixture.cs" /> <Compile Include="FilterTest\LineItem.cs" /> <Compile Include="FilterTest\Order.cs" /> <Compile Include="FilterTest\Product.cs" /> @@ -1969,6 +1971,9 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> + <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> + <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1898\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-08-03 22:25:40
|
Revision: 4677 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4677&view=rev Author: fabiomaulo Date: 2009-08-03 22:25:32 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Refactoring filter-def check first step (removed a very old TODO and removed the problem of filter-def mappings inspection order) Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Cfg/Configuration.cs branches/2.1.x/nhibernate/src/NHibernate/Cfg/Mappings.cs branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-08-02 22:35:41 UTC (rev 4676) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-08-03 22:25:32 UTC (rev 4677) @@ -5,6 +5,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; +using System.Text; using System.Xml; using System.Xml.Schema; using Iesi.Collections; @@ -61,6 +62,7 @@ protected IDictionary<string, NHibernate.Mapping.Collection> collections; protected IDictionary<string, Table> tables; protected IList<SecondPassCommand> secondPasses; + protected Queue<FilterSecondPassArgs> filtersSecondPasses; protected IList<Mappings.PropertyReference> propertyReferences; private IInterceptor interceptor; private IDictionary<string, string> properties; @@ -113,12 +115,7 @@ this.tableNameBinding = GetSerialedObject<IDictionary<string, Mappings.TableDescription>>(info, "tableNameBinding"); this.tables = GetSerialedObject<IDictionary<string, Table>>(info, "tables"); this.typeDefs = GetSerialedObject<IDictionary<string, TypeDef>>(info, "typeDefs"); - - - - - - + filtersSecondPasses = GetSerialedObject<Queue<FilterSecondPassArgs>>(info, "filtersSecondPasses"); } private T GetSerialedObject<T>(SerializationInfo info, string name) { @@ -157,6 +154,7 @@ info.AddValue("tableNameBinding", this.tableNameBinding); info.AddValue("tables", this.tables); info.AddValue("typeDefs", this.typeDefs); + info.AddValue("filtersSecondPasses", filtersSecondPasses); } #endregion @@ -185,8 +183,9 @@ extendsQueue = new HashedSet<ExtendsQueueEntry>(); tableNameBinding = new Dictionary<string, Mappings.TableDescription>(); columnNameBindingPerTable = new Dictionary<Table, Mappings.ColumnNames>(); + filtersSecondPasses = new Queue<FilterSecondPassArgs>(); + } - } [Serializable] private class Mapping : IMapping { @@ -526,7 +525,7 @@ { ProcessPreMappingBuildProperties(); return new Mappings(classes, collections, tables, NamedQueries, NamedSQLQueries, SqlResultSetMappings, Imports, - secondPasses, propertyReferences, namingStrategy, typeDefs, FilterDefinitions, extendsQueue, + secondPasses, filtersSecondPasses, propertyReferences, namingStrategy, typeDefs, FilterDefinitions, extendsQueue, auxiliaryDatabaseObjects, tableNameBinding, columnNameBindingPerTable, defaultAssembly, defaultNamespace, dialect); } @@ -910,6 +909,69 @@ private void Validate() { + ValidateEntities(); + + ValidateCollections(); + + ValidateFilterDefs(); + } + + private void ValidateFilterDefs() + { + var filterNames = new HashedSet<string>(); + foreach (var filterDefinition in FilterDefinitions) + { + if(filterDefinition.Value == null) + { + // a class/collection has a filter but the filter-def was not added. + filterNames.Add(filterDefinition.Key); + } + } + if(filterNames.Count > 0) + { + var message = new StringBuilder(); + message.Append("filter-def for filter named "); + foreach (var filterName in filterNames) + { + message.AppendLine(filterName); + } + message.AppendLine("was not found."); + throw new MappingException(message.ToString()); + } + + // check filter-def without reference + if (FilterDefinitions.Count > 0) + { + filterNames.Clear(); + var filterables = new JoinedEnumerable(ClassMappings, CollectionMappings); + foreach (IFilterable filterable in filterables) + { + filterNames.AddAll(filterable.FilterMap.Keys); + } + foreach (var filterName in FilterDefinitions.Keys) + { + if (!filterNames.Contains(filterName)) + { + // if you are going to remove this exception at least add a log.Error + // because the usage of filter-def, outside its scope, may cause unexpected behaviour + // during queries. + throw new MappingException("filter-def for filter named '" + filterName + + "' was never used to filter classes nor collections."); + } + } + } + } + + private void ValidateCollections() + { + foreach (var col in collections.Values) + { + col.Validate(mapping); + } + } + + private void ValidateEntities() + { bool validateProxy = PropertiesHelper.GetBoolean(Environment.UseProxyValidator, properties, true); HashedSet<string> allProxyErrors = null; IProxyValidator pvalidator = Environment.BytecodeProvider.ProxyFactoryFactory.ProxyValidator; @@ -917,7 +979,7 @@ foreach (var clazz in classes.Values) { clazz.Validate(mapping); - + if (validateProxy) { ICollection<string> errors = ValidateProxyInterface(clazz, pvalidator); @@ -939,11 +1001,6 @@ { throw new InvalidProxyTypeException(allProxyErrors); } - - foreach (var col in collections.Values) - { - col.Validate(mapping); - } } private static ICollection<string> ValidateProxyInterface(PersistentClass persistentClass, IProxyValidator validator) @@ -1013,6 +1070,23 @@ { SecondPassCompileForeignKeys(table, done); } + + log.Info("processing filters (second pass)"); + foreach (var filterSecondPassArgs in filtersSecondPasses) + { + FilterDefinition filterDef; + var filterName = filterSecondPassArgs.FilterName; + FilterDefinitions.TryGetValue(filterName, out filterDef); + if(filterDef == null) + { + throw new MappingException("filter-def for filter named " + filterName + " was not found."); + } + if(string.IsNullOrEmpty(filterDef.DefaultFilterCondition)) + { + throw new MappingException("no filter condition found for filter: " + filterName); + } + filterSecondPassArgs.Filterable.FilterMap[filterName] = filterDef.DefaultFilterCondition; + } } private void SecondPassCompileForeignKeys(Table table, ISet done) Added: branches/2.1.x/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/FilterSecondPassArgs.cs 2009-08-03 22:25:32 UTC (rev 4677) @@ -0,0 +1,28 @@ +using System; +using NHibernate.Mapping; + +namespace NHibernate.Cfg +{ + [Serializable] + public class FilterSecondPassArgs + { + // this class is NH specific to solve problems generated by 'order of mapping-doc' + // to assign the condition of a filter. + public FilterSecondPassArgs(IFilterable filterable, string filterName) + { + if (filterable == null) + { + throw new ArgumentNullException("filterable"); + } + if (string.IsNullOrEmpty(filterName)) + { + throw new ArgumentNullException("filterName"); + } + Filterable = filterable; + FilterName = filterName; + } + + public IFilterable Filterable{ get; private set;} + public string FilterName { get; private set; } + } +} \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/Mappings.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/Mappings.cs 2009-08-02 22:35:41 UTC (rev 4676) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/Mappings.cs 2009-08-03 22:25:32 UTC (rev 4677) @@ -69,6 +69,7 @@ private readonly IList<PropertyReference> propertyReferences; private readonly IDictionary<string, FilterDefinition> filterDefinitions; private readonly IList<IAuxiliaryDatabaseObject> auxiliaryDatabaseObjects; + private readonly Queue<FilterSecondPassArgs> filtersSecondPasses; private readonly INamingStrategy namingStrategy; @@ -98,6 +99,7 @@ IDictionary<string, ResultSetMappingDefinition> resultSetMappings, IDictionary<string, string> imports, IList<SecondPassCommand> secondPasses, + Queue<FilterSecondPassArgs> filtersSecondPasses, IList<PropertyReference> propertyReferences, INamingStrategy namingStrategy, IDictionary<string, TypeDef> typeDefs, @@ -108,7 +110,7 @@ IDictionary<Table, ColumnNames> columnNameBindingPerTable, string defaultAssembly, string defaultNamespace, - Dialect.Dialect dialect) + Dialect.Dialect dialect) { this.classes = classes; this.collections = collections; @@ -129,6 +131,7 @@ this.defaultAssembly = defaultAssembly; this.defaultNamespace = defaultNamespace; this.dialect = dialect; + this.filtersSecondPasses = filtersSecondPasses; } /// <summary> @@ -454,12 +457,22 @@ public void AddFilterDefinition(FilterDefinition definition) { - filterDefinitions.Add(definition.FilterName, definition); + FilterDefinition fd; + if (filterDefinitions.TryGetValue(definition.FilterName, out fd)) + { + if(fd!=null) + { + throw new MappingException("Duplicated filter-def named: " + definition.FilterName); + } + } + filterDefinitions[definition.FilterName] = definition; } public FilterDefinition GetFilterDefinition(string name) { - return filterDefinitions[name]; + FilterDefinition result; + filterDefinitions.TryGetValue(name, out result); + return result; } public void AddAuxiliaryDatabaseObject(IAuxiliaryDatabaseObject auxiliaryDatabaseObject) @@ -638,6 +651,34 @@ return persistentClass; } + public void ExpectedFilterDefinition(IFilterable filterable, string filterName, string condition) + { + var fdef = GetFilterDefinition(filterName); + if (string.IsNullOrEmpty(condition)) + { + if (fdef != null) + { + // where immediately available, apply the condition + condition = fdef.DefaultFilterCondition; + } + } + if (string.IsNullOrEmpty(condition) && fdef == null) + { + log.Debug(string.Format("Adding filter second pass [{0}]", filterName)); + filtersSecondPasses.Enqueue(new FilterSecondPassArgs(filterable, filterName)); + } + else if (string.IsNullOrEmpty(condition) && fdef != null) + { + // Both sides does not have condition + throw new MappingException("no filter condition found for filter: " + filterName); + } + + if (fdef == null) + { + // if not available add an expected filter definition + FilterDefinitions[filterName] = null; + } + } } public delegate void SecondPassCommand(IDictionary<string, PersistentClass> persistentClasses); Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-08-02 22:35:41 UTC (rev 4676) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-08-03 22:25:32 UTC (rev 4677) @@ -1017,17 +1017,19 @@ condition = (propertyNameNode == null) ? null : propertyNameNode.Value; } - //TODO: bad implementation, cos it depends upon ordering of mapping doc - // fixing this requires that Collection/PersistentClass gain access - // to the Mappings reference from Configuration (or the filterDefinitions - // map directly) sometime during Configuration.buildSessionFactory - // (after all the types/filter-defs are known and before building - // persisters). if (StringHelper.IsEmpty(condition)) - condition = mappings.GetFilterDefinition(name).DefaultFilterCondition; - if (condition == null) - throw new MappingException("no filter condition found for filter: " + name); - log.Debug("Applying filter [" + name + "] as [" + condition + "]"); + { + var fdef = mappings.GetFilterDefinition(name); + if (fdef != null) + { + // where immediately available, apply the condition + condition = fdef.DefaultFilterCondition; + } + } + + mappings.ExpectedFilterDefinition(filterable, name, condition); + + log.Debug(string.Format("Applying filter [{0}] as [{1}]", name, condition)); filterable.AddFilter(name, condition); } Modified: branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-02 22:35:41 UTC (rev 4676) +++ branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-03 22:25:32 UTC (rev 4677) @@ -456,6 +456,7 @@ <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> <Compile Include="Cache\FakeCache.cs" /> + <Compile Include="Cfg\FilterSecondPassArgs.cs" /> <Compile Include="Cfg\MappingSchema\AbstractDecoratable.cs" /> <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/ConfigFixture.cs 2009-08-03 22:25:32 UTC (rev 4677) @@ -0,0 +1,244 @@ +using System.Collections.Generic; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.FilterTest +{ + [TestFixture] + public class ConfigFixture + { + private class ConfigurationStub: Configuration + { + public Queue<FilterSecondPassArgs> FiltersSecondPasses { get { return filtersSecondPasses; } } + } + + private static ConfigurationStub GetConfiguration() + { + var result = new ConfigurationStub(); + if (TestConfigurationHelper.hibernateConfigFile != null) + result.Configure(TestConfigurationHelper.hibernateConfigFile); + return result; + } + + [Test] + [Description("Add a class with filters without condition should not Throw exceptions and add secondpass tasks.")] + public void AddClassWithFilters() + { + var cfg = GetConfiguration(); + Assert.DoesNotThrow(() => cfg.AddResource("NHibernate.Test.FilterTest.SimpleFiltered.hbm.xml", GetType().Assembly)); + Assert.That(cfg.FiltersSecondPasses.Count, Is.EqualTo(2)); + } + + [Test] + [Description("Add filters-def should change conditions of class filters")] + public void AddFilterDefToClassWithFilters() + { + var cfg = GetConfiguration(); + cfg.AddResource("NHibernate.Test.FilterTest.SimpleFiltered.hbm.xml", GetType().Assembly); + cfg.AddResource("NHibernate.Test.FilterTest.SimpleFilteredFiltersDefsOk.hbm.xml", GetType().Assembly); + Assert.That(cfg.FilterDefinitions, Is.Not.Empty); + cfg.BuildMappings(); + var pc = cfg.GetClassMapping(typeof (TestClass)); + foreach (var filterMap in pc.FilterMap) + { + Assert.That(filterMap.Value, Is.Not.Null & Is.Not.Empty, "filtername:" + filterMap.Key); + } + } + + [Test] + [Description("Filter def without condition in both sides should throw exception")] + public void WrongFilterDefInClass() + { + var cfg = GetConfiguration(); + var e = Assert.Throws<MappingException>(() => cfg.AddResource("NHibernate.Test.FilterTest.WrongFilterDefInClass.hbm.xml", GetType().Assembly)); + Assert.That(e.InnerException, Is.Not.Null); + Assert.That(e.InnerException.Message, Text.StartsWith("no filter condition").IgnoreCase); + } + + [Test] + [Description("Filter def without condition in both sides should throw exception even in secondpass")] + public void WrongFilterDefInClassSeconPass() + { + const string wrongClassMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter'/> + </class> + +</hibernate-mapping>"; + + const string wrongFilterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(wrongClassMap); + cfg.AddXmlString(wrongFilterDef); + var e = Assert.Throws<MappingException>(cfg.BuildMappings); + Assert.That(e.Message, Text.StartsWith("no filter condition").IgnoreCase); + } + + [Test] + [Description("Add a class with filters without condition should Throw exceptions at secondpass.")] + public void AddClassWithFiltersWithoutFilterDef() + { + var cfg = GetConfiguration(); + cfg.AddResource("NHibernate.Test.FilterTest.SimpleFiltered.hbm.xml", GetType().Assembly); + var e = Assert.Throws<MappingException>(cfg.BuildMappings); + Assert.That(e.Message, Text.StartsWith("filter-def for filter named")); + Assert.That(e.Message, Text.Contains("was not found")); + } + + [Test] + [Description("Class filter with condition does not add secondpass and add an invalid filter-def")] + public void ClassNoSecondPass() + { + const string classMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter' condition=':LiveParam = Live'/> + </class> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(classMap); + Assert.That(cfg.FiltersSecondPasses.Count, Is.EqualTo(0)); + Assert.That(cfg.FilterDefinitions.Keys, Has.Member("LiveFilter")); + Assert.That(cfg.FilterDefinitions["LiveFilter"], Is.Null); + } + + [Test] + [Description("Writing the condition in both sides should not change the condition defined in the class.")] + public void ClassConditionInBothSides() + { + const string classMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter' condition='Live = 1'/> + </class> + +</hibernate-mapping>"; + + const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter' condition=':LiveParam = Live'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(classMap); + cfg.AddXmlString(filterDef); + Assert.That(cfg.FiltersSecondPasses.Count, Is.EqualTo(0)); + Assert.That(cfg.FilterDefinitions.Keys, Has.Member("LiveFilter")); + Assert.That(cfg.FilterDefinitions["LiveFilter"], Is.Not.Null); + + cfg.BuildMappings(); + Assert.That(cfg.FilterDefinitions.Count, Is.EqualTo(1)); + + var pc = cfg.GetClassMapping(typeof(TestClass)); + Assert.That(pc.FilterMap["LiveFilter"], Is.EqualTo("Live = 1")); + } + + [Test] + [Description("Filter-def duplication should Throw exception")] + public void DuplicatedFilterDef() + { + const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + var e = Assert.Throws<MappingException>(() => cfg.AddXmlString(filterDef)); + Assert.That(e.InnerException, Is.Not.Null); + Assert.That(e.InnerException.Message, Text.Contains("Duplicated filter-def")); + } + + [Test] + [Description("Add a filtered class with condition but without a filter-def should Throw exception")] + public void MissedFilterDef() + { + const string classMap = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' + default-lazy='false' + assembly='NHibernate.Test' + namespace='NHibernate.Test.FilterTest' > + + <class name='TestClass'> + <id name='Id' column='id'> + <generator class='assigned' /> + </id> + <property name='Name'/> + + <property name='Live'/> + <filter name='LiveFilter' condition='Live = 1'/> + </class> + +</hibernate-mapping>"; + var cfg = GetConfiguration(); + cfg.AddXmlString(classMap); + var e = Assert.Throws<MappingException>(()=>cfg.BuildSessionFactory()); + Assert.That(e.Message, Text.StartsWith("filter-def for filter named")); + Assert.That(e.Message, Text.Contains("was not found")); + } + + [Test] + [Description("Filter-def without reference to it should Throw exception")] + public void FilterDefWithoutReference() + { + const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' > + + <filter-def name='LiveFilter'> + <filter-param name='LiveParam' type='boolean'/> + </filter-def> + +</hibernate-mapping>"; + + var cfg = GetConfiguration(); + cfg.AddXmlString(filterDef); + var e = Assert.Throws<MappingException>(() => cfg.BuildSessionFactory()); + Assert.That(e.Message, Text.StartsWith("filter-def for filter named")); + Assert.That(e.Message, Text.Contains("was never used to filter classes nor collections.")); + } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/FilterSecondPassArgsFixture.cs 2009-08-03 22:25:32 UTC (rev 4677) @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using NHibernate.Mapping; +using NUnit.Framework; +using NHibernate.Cfg; + +namespace NHibernate.Test.FilterTest +{ + [TestFixture] + public class FilterSecondPassArgsFixture + { + public class FakeFilterable: IFilterable + { + public void AddFilter(string name, string condition) + { + throw new NotImplementedException(); + } + + public IDictionary<string, string> FilterMap + { + get { throw new NotImplementedException(); } + } + } + [Test] + public void CtorProtection() + { + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(null, "")); + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(null, "a>1")); + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(new FakeFilterable(), null)); + Assert.Throws<ArgumentNullException>(() => new FilterSecondPassArgs(new FakeFilterable(), "")); + Assert.DoesNotThrow(() => new FilterSecondPassArgs(new FakeFilterable(), "a>1")); + } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFiltered.hbm.xml 2009-08-03 22:25:32 UTC (rev 4677) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + default-lazy="false" + assembly="NHibernate.Test" + namespace="NHibernate.Test.FilterTest" > + + <class name="TestClass"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + <property name="Name"/> + <property name="Live" type="Boolean" /> + <filter name="LiveFilter" /> + <filter name="LiveFilter2" /> + </class> + +</hibernate-mapping> \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/SimpleFilteredFiltersDefsOk.hbm.xml 2009-08-03 22:25:32 UTC (rev 4677) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> + + <filter-def name="LiveFilter" condition=":LiveParam = Live"> + <filter-param name="LiveParam" type="boolean"/> + </filter-def> + + <filter-def name="LiveFilter2"> + <![CDATA[Name = :LiveParam2]]> + <filter-param name="LiveParam2" type="string"/> + </filter-def> +</hibernate-mapping> \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/WrongFilterDefInClass.hbm.xml 2009-08-03 22:25:32 UTC (rev 4677) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + default-lazy="false" + assembly="NHibernate.Test" + namespace="NHibernate.Test.FilterTest" > + + <class name="TestClass"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + <property name="Name" type="StringClob" length="100000" /> + + <property name="Live" type="Boolean" /> + <filter name="LiveFilter"/> + </class> + + <filter-def name="LiveFilter"> + <filter-param name="LiveParam" type="boolean"/> + </filter-def> + +</hibernate-mapping> \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml 2009-08-02 22:35:41 UTC (rev 4676) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/FilterTest/defs.hbm.xml 2009-08-03 22:25:32 UTC (rev 4677) @@ -19,8 +19,4 @@ <filter-def name="seniorSalespersons"> <filter-param name="asOfDate" type="DateTime"/> </filter-def> - - <filter-def name="cat"> - <filter-param name="catId" type="long"/> - </filter-def> </hibernate-mapping> \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 22:35:41 UTC (rev 4676) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-03 22:25:32 UTC (rev 4677) @@ -105,6 +105,8 @@ <Compile Include="CfgTest\ConfigurationSchemaFixture.cs" /> <Compile Include="CfgTest\ConfigurationSerializationTests.cs" /> <Compile Include="CfgTest\DefaultNsAssmFixture.cs" /> + <Compile Include="FilterTest\ConfigFixture.cs" /> + <Compile Include="FilterTest\FilterSecondPassArgsFixture.cs" /> <Compile Include="CfgTest\HbmBinderFixture.cs" /> <Compile Include="CfgTest\HbmOrderingFixture.cs" /> <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> @@ -1954,6 +1956,9 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> + <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> + <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1898\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-08-02 22:35:50
|
Revision: 4676 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4676&view=rev Author: fabiomaulo Date: 2009-08-02 22:35:41 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Merge r4675 (fix NH-1898) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-08-02 22:31:07 UTC (rev 4675) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-08-02 22:35:41 UTC (rev 4676) @@ -126,6 +126,7 @@ RegisterFunction("trim", new AnsiTrimEmulationFunction()); RegisterFunction("iif", new SQLFunctionTemplate(null, "case when ?1 then ?2 else ?3 end")); + RegisterFunction("replace", new StandardSafeSQLFunction("replace",NHibernateUtil.String, 3)); RegisterKeyword("top"); RegisterKeyword("integer"); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-08-02 22:31:07 UTC (rev 4675) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-08-02 22:35:41 UTC (rev 4676) @@ -58,6 +58,7 @@ { try { + CheckParametersExpectedType(parameters); // NH Different behavior (NH-1898) var parameterTypes = new List<SqlType>(Parameters.Count); foreach (var parameterSpecification in Parameters) { @@ -100,6 +101,33 @@ } } + private void CheckParametersExpectedType(QueryParameters parameters) + { + foreach (var specification in Parameters) + { + if (specification.ExpectedType == null) + { + var namedSpec = specification as NamedParameterSpecification; + if (namedSpec != null) + { + TypedValue tv; + if(parameters.NamedParameters.TryGetValue(namedSpec.Name, out tv)) + { + specification.ExpectedType = tv.Type; + } + } + else + { + var posSpec = specification as PositionalParameterSpecification; + if (posSpec != null) + { + specification.ExpectedType = parameters.PositionalParameterTypes[posSpec.HqlPosition]; + } + } + } + } + } + protected override IQueryable[] AffectedQueryables { get { return new[] { persister }; } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs 2009-08-02 22:35:41 UTC (rev 4676) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH1898 +{ + public class DomainClass + { + public int Id { get; set; } + + public string Data { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml 2009-08-02 22:35:41 UTC (rev 4676) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1898" + default-lazy="false"> + <class name="DomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="Data" /> + </class> + <query name='replaceQuery'> + <query-param name='old' type='String'/> + <query-param name='new' type='String'/> + <![CDATA[ + update DomainClass set + Data = replace(Data,:old, :new) + ]]> + </query> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs 2009-08-02 22:35:41 UTC (rev 4676) @@ -0,0 +1,44 @@ +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1898 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect as MsSql2005Dialect != null; + } + + [Test] + public void TypeOfParametersShouldBeSetCorrectly() + { + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + var entity = new DomainClass {Id = 1, Data = "some oldValue data"}; + session.Save(entity); + tx.Commit(); + } + } + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + session.GetNamedQuery("replaceQuery").SetString("old", "oldValue").SetString("new", "newValue").ExecuteUpdate(); + tx.Commit(); + } + using (ITransaction tx = session.BeginTransaction()) + { + var entity = session.Get<DomainClass>(1); + + Assert.AreEqual("some newValue data", entity.Data); + session.Delete(entity); + tx.Commit(); + } + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 22:31:07 UTC (rev 4675) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 22:35:41 UTC (rev 4676) @@ -550,6 +550,8 @@ <Compile Include="NHSpecificTest\NH1868\Model.cs" /> <Compile Include="NHSpecificTest\NH1877\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1877\Person.cs" /> + <Compile Include="NHSpecificTest\NH1898\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1898\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> @@ -1967,6 +1969,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1898\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-08-02 22:31:07 UTC (rev 4675) +++ trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-08-02 22:35:41 UTC (rev 4676) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Threading; -using NHibernate.Hql.Ast.ANTLR; using NUnit.Framework; namespace NHibernate.Test.Stateless @@ -119,27 +118,6 @@ } [Test] - public void HqlBulkWithErrorInPropertyName() - { - using (IStatelessSession ss = sessions.OpenStatelessSession()) - { - ITransaction tx = ss.BeginTransaction(); - var doc = new Document("blah blah blah", "Blahs"); - ss.Insert(doc); - var paper = new Paper {Color = "White"}; - ss.Insert(paper); - tx.Commit(); - - Assert.Throws<QuerySyntaxException>(()=> - ss.CreateQuery("update Document set name = :newName where name = :oldName").SetString("newName", "Foos").SetString - ("oldName", "Blahs").ExecuteUpdate()); - tx = ss.BeginTransaction(); - ss.CreateQuery("delete Document").ExecuteUpdate(); - ss.CreateQuery("delete Paper").ExecuteUpdate(); - tx.Commit(); - } - } - [Test] public void InitId() { Paper paper; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-08-02 22:31:20
|
Revision: 4675 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4675&view=rev Author: fabiomaulo Date: 2009-08-02 22:31:07 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Fix NH-1898 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj branches/2.1.x/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-08-02 19:55:57 UTC (rev 4674) +++ branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-08-02 22:31:07 UTC (rev 4675) @@ -126,6 +126,7 @@ RegisterFunction("trim", new AnsiTrimEmulationFunction()); RegisterFunction("iif", new SQLFunctionTemplate(null, "case when ?1 then ?2 else ?3 end")); + RegisterFunction("replace", new StandardSafeSQLFunction("replace",NHibernateUtil.String, 3)); RegisterKeyword("top"); RegisterKeyword("integer"); Modified: branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-08-02 19:55:57 UTC (rev 4674) +++ branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-08-02 22:31:07 UTC (rev 4675) @@ -58,6 +58,7 @@ { try { + CheckParametersExpectedType(parameters); // NH Different behavior (NH-1898) var parameterTypes = new List<SqlType>(Parameters.Count); foreach (var parameterSpecification in Parameters) { @@ -100,6 +101,33 @@ } } + private void CheckParametersExpectedType(QueryParameters parameters) + { + foreach (var specification in Parameters) + { + if (specification.ExpectedType == null) + { + var namedSpec = specification as NamedParameterSpecification; + if (namedSpec != null) + { + TypedValue tv; + if(parameters.NamedParameters.TryGetValue(namedSpec.Name, out tv)) + { + specification.ExpectedType = tv.Type; + } + } + else + { + var posSpec = specification as PositionalParameterSpecification; + if (posSpec != null) + { + specification.ExpectedType = parameters.PositionalParameterTypes[posSpec.HqlPosition]; + } + } + } + } + } + protected override IQueryable[] AffectedQueryables { get { return new[] { persister }; } Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/DomainClass.cs 2009-08-02 22:31:07 UTC (rev 4675) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH1898 +{ + public class DomainClass + { + public int Id { get; set; } + + public string Data { get; set; } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/Mappings.hbm.xml 2009-08-02 22:31:07 UTC (rev 4675) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1898" + default-lazy="false"> + <class name="DomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="Data" /> + </class> + <query name='replaceQuery'> + <query-param name='old' type='String'/> + <query-param name='new' type='String'/> + <![CDATA[ + update DomainClass set + Data = replace(Data,:old, :new) + ]]> + </query> +</hibernate-mapping> \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1898/SampleTest.cs 2009-08-02 22:31:07 UTC (rev 4675) @@ -0,0 +1,44 @@ +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1898 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect as MsSql2005Dialect != null; + } + + [Test] + public void TypeOfParametersShouldBeSetCorrectly() + { + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + var entity = new DomainClass {Id = 1, Data = "some oldValue data"}; + session.Save(entity); + tx.Commit(); + } + } + using (ISession session = OpenSession()) + { + using (ITransaction tx = session.BeginTransaction()) + { + session.GetNamedQuery("replaceQuery").SetString("old", "oldValue").SetString("new", "newValue").ExecuteUpdate(); + tx.Commit(); + } + using (ITransaction tx = session.BeginTransaction()) + { + var entity = session.Get<DomainClass>(1); + + Assert.AreEqual("some newValue data", entity.Data); + session.Delete(entity); + tx.Commit(); + } + } + } + } +} \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 19:55:57 UTC (rev 4674) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-02 22:31:07 UTC (rev 4675) @@ -538,6 +538,8 @@ <Compile Include="NHSpecificTest\NH1868\Model.cs" /> <Compile Include="NHSpecificTest\NH1877\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1877\Person.cs" /> + <Compile Include="NHSpecificTest\NH1898\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1898\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1899\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> @@ -1952,6 +1954,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1898\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" /> Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-08-02 19:55:57 UTC (rev 4674) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-08-02 22:31:07 UTC (rev 4675) @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Threading; -using NHibernate.Hql.Ast.ANTLR; using NUnit.Framework; namespace NHibernate.Test.Stateless @@ -119,27 +118,6 @@ } [Test] - public void HqlBulkWithErrorInPropertyName() - { - using (IStatelessSession ss = sessions.OpenStatelessSession()) - { - ITransaction tx = ss.BeginTransaction(); - var doc = new Document("blah blah blah", "Blahs"); - ss.Insert(doc); - var paper = new Paper {Color = "White"}; - ss.Insert(paper); - tx.Commit(); - - Assert.Throws<QuerySyntaxException>(()=> - ss.CreateQuery("update Document set name = :newName where name = :oldName").SetString("newName", "Foos").SetString - ("oldName", "Blahs").ExecuteUpdate()); - tx = ss.BeginTransaction(); - ss.CreateQuery("delete Document").ExecuteUpdate(); - ss.CreateQuery("delete Paper").ExecuteUpdate(); - tx.Commit(); - } - } - [Test] public void InitId() { Paper paper; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |