From: <fab...@us...> - 2009-05-31 16:39:13
|
Revision: 4392 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4392&view=rev Author: fabiomaulo Date: 2009-05-31 16:39:08 +0000 (Sun, 31 May 2009) Log Message: ----------- Fix NH-1802 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-30 03:49:14 UTC (rev 4391) +++ trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -48,7 +48,7 @@ public override string ToString() { - return "FilterKey[" + filterName + filterParameters + ']'; + return string.Format("FilterKey[{0}{1}]", filterName, CollectionPrinter.ToString(filterParameters)); } public static ISet CreateFilterKeys(IDictionary<string, IFilter> enabledFilters, EntityMode entityMode) Modified: trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs 2009-05-30 03:49:14 UTC (rev 4391) +++ trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -122,12 +122,12 @@ } } - if (!CollectionHelper.DictionaryEquals(namedParameters, that.namedParameters)) + if (!CollectionHelper.SetEquals(filters, that.filters)) { return false; } - if (!CollectionHelper.SetEquals(filters, that.filters)) + if (!CollectionHelper.DictionaryEquals(namedParameters, that.namedParameters)) { return false; } @@ -217,6 +217,10 @@ .Append("; named parameters: ") .Append(print.ToString(namedParameters)); } + if (filters != null) + { + buf.Append("; filters: ").Append(CollectionPrinter.ToString(filters)); + } if (firstRow != RowSelection.NoValue) { buf.Append("; first row: ").Append(firstRow); Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.CacheTest +{ + public class EntityWithFilters + { + public virtual int Id { get; set; } + public virtual string Description { get; set; } + public virtual int Value { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.CacheTest"> + <class name="EntityWithFilters"> + <id type="int"/> + <property name="Description"/> + <property name="Value"/> + + <filter name="DescriptionLike" /> + <filter name="DescriptionEqualAndValueGT" /> + </class> + <query name="EntityWithFilters.All" cache-region="aRegion" cacheable="true"> + from EntityWithFilters + </query> + <filter-def name="DescriptionLike" condition="Description like :pLike"> + <filter-param name="pLike" type="string"/> + </filter-def> + <filter-def name="DescriptionEqualAndValueGT" condition="Description = :pDesc and Value > :pValue"> + <filter-param name="pDesc" type="string"/> + <filter-param name="pValue" type="int"/> + </filter-def> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,112 @@ +using System.Collections; +using NHibernate.Cache; +using NHibernate.Impl; +using NUnit.Framework; + +namespace NHibernate.Test.CacheTest +{ + [TestFixture] + public class FilterKeyFixture: TestCase + { + protected override string MappingsAssembly + { + get{return "NHibernate.Test";} + } + + protected override IList Mappings + { + get { return new[] { "CacheTest.EntityWithFilters.xml" }; } + } + + [Test] + public void ToStringIncludeAll() + { + string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionLike{'pLike'='so%'}]")); + + filterName = "DescriptionEqualAndValueGT"; + f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionEqualAndValueGT{'pDesc'='something', 'pValue'='10'}]")); + } + + [Test] + public void Equality() + { + // Equality is aware only by parameters names not values + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + Assert.That(fk, Is.EqualTo(fk1)); + + FilterDescValueToCompare(out fk, out fk1); + Assert.That(fk, Is.EqualTo(fk1)); + } + + private void FilterDescLikeToCompare(out FilterKey fk, out FilterKey fk1) + { + const string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pLike", "%ing"); + fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + } + + private void FilterDescValueToCompare(out FilterKey fk, out FilterKey fk1) + { + const string filterName = "DescriptionEqualAndValueGT"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); + fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + } + + [Test] + public void NotEquality() + { + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + + FilterKey fvk, fvk1; + FilterDescValueToCompare(out fvk, out fvk1); + + Assert.That(fk, Is.Not.EqualTo(fvk)); + Assert.That(fk1, Is.Not.EqualTo(fvk1)); + } + + [Test] + public void HashCode() + { + // HashCode is aware only by parameters names not values (should work as Equal) + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + Assert.That(fk.GetHashCode(), Is.EqualTo(fk1.GetHashCode())); + + FilterDescValueToCompare(out fk, out fk1); + Assert.That(fk.GetHashCode(), Is.EqualTo(fk1.GetHashCode())); + + } + + [Test] + public void NotEqualHashCode() + { + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + + FilterKey fvk, fvk1; + FilterDescValueToCompare(out fvk, out fvk1); + + Assert.That(fk.GetHashCode(), Is.Not.EqualTo(fvk.GetHashCode())); + Assert.That(fk1.GetHashCode(), Is.Not.EqualTo(fvk1.GetHashCode())); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,147 @@ +using System.Collections; +using Iesi.Collections.Generic; +using NHibernate.Cache; +using NHibernate.Engine; +using NHibernate.Impl; +using NHibernate.SqlCommand; +using NUnit.Framework; +using Iesi.Collections; + +namespace NHibernate.Test.CacheTest +{ + [TestFixture] + public class QueryKeyFixture : TestCase + { + private readonly SqlString SqlAll = + new SqlString("select entitywith0_.id as id0_, entitywith0_.Description as Descript2_0_, entitywith0_.Value as Value0_ from EntityWithFilters entitywith0_"); + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "CacheTest.EntityWithFilters.xml" }; } + } + + [Test] + public void EqualityWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + Assert.That(qk, Is.EqualTo(qk1)); + + QueryKeyFilterDescValueToCompare(out qk, out qk1); + Assert.That(qk, Is.EqualTo(qk1)); + } + + private void QueryKeyFilterDescLikeToCompare(out QueryKey qk, out QueryKey qk1) + { + const string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk }; + qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pLike", "%ing"); + var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fks = new HashedSet<FilterKey> { fk1 }; + qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + } + + private void QueryKeyFilterDescValueToCompare(out QueryKey qk, out QueryKey qk1) + { + const string filterName = "DescriptionEqualAndValueGT"; + + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk }; + qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); + var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fks = new HashedSet<FilterKey> { fk1 }; + qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + } + + [Test] + public void NotEqualityWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + + QueryKey qvk, qvk1; + QueryKeyFilterDescValueToCompare(out qvk, out qvk1); + + Assert.That(qk, Is.Not.EqualTo(qvk)); + Assert.That(qk1, Is.Not.EqualTo(qvk1)); + } + + [Test] + public void HashCodeWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + Assert.That(qk.GetHashCode(), Is.EqualTo(qk1.GetHashCode())); + + QueryKeyFilterDescValueToCompare(out qk, out qk1); + Assert.That(qk.GetHashCode(), Is.EqualTo(qk1.GetHashCode())); + } + + [Test] + public void NotEqualHashCodeWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + + QueryKey qvk, qvk1; + QueryKeyFilterDescValueToCompare(out qvk, out qvk1); + + Assert.That(qk.GetHashCode(), Is.Not.EqualTo(qvk.GetHashCode())); + Assert.That(qk1.GetHashCode(), Is.Not.EqualTo(qvk1.GetHashCode())); + } + + [Test] + public void ToStringWithFilters() + { + string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk }; + var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + Assert.That(qk.ToString(), Text.Contains(string.Format("filters: ['{0}']",fk))); + + filterName = "DescriptionEqualAndValueGT"; + f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fks = new HashedSet<FilterKey> { fk }; + qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + Assert.That(qk.ToString(), Text.Contains(string.Format("filters: ['{0}']", fk))); + } + + [Test] + public void ToStringWithMoreFilters() + { + string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + filterName = "DescriptionEqualAndValueGT"; + var fv = new FilterImpl(sessions.GetFilterDefinition(filterName)); + fv.SetParameter("pDesc", "something").SetParameter("pValue", 10); + var fvk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk, fvk }; + var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + Assert.That(qk.ToString(), Text.Contains(string.Format("filters: ['{0}', '{1}']", fk, fvk))); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-30 03:49:14 UTC (rev 4391) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 16:39:08 UTC (rev 4392) @@ -93,7 +93,10 @@ <Compile Include="Bytecode\Lightweight\BytecodeProviderFixture.cs" /> <Compile Include="Bytecode\WrongProxyFactoryFactory.cs" /> <Compile Include="CacheTest\CacheFixture.cs" /> + <Compile Include="CacheTest\EntityWithFilters.cs" /> + <Compile Include="CacheTest\FilterKeyFixture.cs" /> <Compile Include="CacheTest\QueryCacheFixture.cs" /> + <Compile Include="CacheTest\QueryKeyFixture.cs" /> <Compile Include="CacheTest\TimestamperFixture.cs" /> <Compile Include="Cascade\Job.cs" /> <Compile Include="Cascade\JobBatch.cs" /> @@ -1833,6 +1836,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> + <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1788\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-05-31 18:39:02
|
Revision: 4393 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4393&view=rev Author: fabiomaulo Date: 2009-05-31 18:38:56 +0000 (Sun, 31 May 2009) Log Message: ----------- Fix NH-1805 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-31 16:39:08 UTC (rev 4392) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-31 18:38:56 UTC (rev 4393) @@ -201,7 +201,9 @@ model.OptimisticLockMode = GetOptimisticLockMode(olNode); // META ATTRIBUTES - model.MetaAttributes = GetMetas(classMapping, inheritedMetas); + model.MetaAttributes = classMapping != null + ? GetMetas(classMapping, inheritedMetas) + : GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); // PERSISTER XmlAttribute persisterNode = node.Attributes["persister"]; Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-31 16:39:08 UTC (rev 4392) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-31 18:38:56 UTC (rev 4393) @@ -165,12 +165,20 @@ Assert.That(col.ComparerClassName, Text.StartsWith("NHibernate.Test.MappingTest.NonExistingComparator")); } - [Test, Ignore("Not fixed yet.")] + [Test] public void ReadSubClasses() { PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.DomesticAnimal"); MetaAttribute metaAttribute = cm.GetMetaAttribute("Auditable"); Assert.That(metaAttribute, Is.Not.Null); + + cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Cat"); + metaAttribute = cm.GetMetaAttribute("Auditable"); + Assert.That(metaAttribute, Is.Not.Null); + + cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Dog"); + metaAttribute = cm.GetMetaAttribute("Auditable"); + Assert.That(metaAttribute, Is.Not.Null); } } } \ 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: <fab...@us...> - 2009-05-31 22:33:08
|
Revision: 4395 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4395&view=rev Author: fabiomaulo Date: 2009-05-31 22:33:06 +0000 (Sun, 31 May 2009) Log Message: ----------- Fix NH-1801 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-31 20:53:09 UTC (rev 4394) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-31 22:33:06 UTC (rev 4395) @@ -70,35 +70,45 @@ MutateRowValueConstructorSyntaxesIfNecessary( lhsType, rhsType ); } - protected void MutateRowValueConstructorSyntaxesIfNecessary(IType lhsType, IType rhsType) + protected void MutateRowValueConstructorSyntaxesIfNecessary(IType lhsType, IType rhsType) { // TODO : this really needs to be delayed unitl after we definitively know all node types // where this is currently a problem is parameters for which where we cannot unequivocally // resolve an expected type ISessionFactoryImplementor sessionFactory = SessionFactoryHelper.Factory; - if ( lhsType != null && rhsType != null ) + if (lhsType != null && rhsType != null) { - int lhsColumnSpan = lhsType.GetColumnSpan( sessionFactory ); - if ( lhsColumnSpan != rhsType.GetColumnSpan( sessionFactory ) ) + int lhsColumnSpan = lhsType.GetColumnSpan(sessionFactory); + var rhsColumnSpan = rhsType.GetColumnSpan(sessionFactory); + // NH different behavior NH-1801 + if (lhsColumnSpan != rhsColumnSpan && !AreCompatibleEntityTypes(lhsType, rhsType)) { - throw new TypeMismatchException( - "left and right hand sides of a binary logic operator were incompatibile [" + - lhsType.Name + " : "+ rhsType.Name + "]" - ); + throw new TypeMismatchException("left and right hand sides of a binary logic operator were incompatibile [" + + lhsType.Name + " : " + rhsType.Name + "]"); } - if ( lhsColumnSpan > 1 ) + if (lhsColumnSpan > 1) { // for dialects which are known to not support ANSI-SQL row-value-constructor syntax, // we should mutate the tree. - if ( !sessionFactory.Dialect.SupportsRowValueConstructorSyntax) + if (!sessionFactory.Dialect.SupportsRowValueConstructorSyntax) { - MutateRowValueConstructorSyntax( lhsColumnSpan ); + MutateRowValueConstructorSyntax(lhsColumnSpan); } } } } + private static bool AreCompatibleEntityTypes(IType lhsType, IType rhsType) + { + if(lhsType.IsEntityType && rhsType.IsEntityType) + { + return lhsType.ReturnedClass.IsAssignableFrom(rhsType.ReturnedClass) || + rhsType.ReturnedClass.IsAssignableFrom(lhsType.ReturnedClass); + } + return false; + } + /** * Mutate the subtree relating to a row-value-constructor to instead use * a series of ANDed predicates. This allows multi-column type comparisons Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs 2009-05-31 22:33:06 UTC (rev 4395) @@ -0,0 +1,24 @@ +namespace NHibernate.Test.NHSpecificTest.NH1801 +{ + public class A + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + + public class B + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual A A { get; set; } + } + + public class C + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual A A { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs 2009-05-31 22:33:06 UTC (rev 4395) @@ -0,0 +1,57 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1801 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Test() + { + try + { + using (ISession s = OpenSession()) + { + var a1 = new A {Id = 1, Name = "A1"}; + var a2 = new A {Id = 2, Name = "A2"}; + + var b1 = new B {Id = 1, Name = "B1", A = a1}; + var b2 = new B {Id = 2, Name = "B2", A = a2}; + + var c1 = new C {Name = "C1", A = a1}; + var c2 = new C {Name = "C2", A = a2}; + + s.Save(a1); + s.Save(a2); + s.Save(b1); + s.Save(b2); + s.Save(c1); + s.Save(c2); + + s.Flush(); + } + + using (ISession s = OpenSession()) + { + IList res = s.CreateQuery("from B b, C c where b.A = c.A and b.Id = :id").SetInt32("id", 1).List(); + + Assert.That(res, Has.Count.EqualTo(1)); + + s.Flush(); + } + } + finally + { + using (ISession s = OpenSession()) + { + s.Delete("from B"); + s.Delete("from C"); + s.Delete("from A"); + + s.Flush(); + } + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml 2009-05-31 22:33:06 UTC (rev 4395) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1801" + assembly="NHibernate.Test"> + + <class name="A"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + </class> + + <class name="B"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <many-to-one name="A"/> + </class> + + <class name="C"> + <id name="Id"> + <generator class="foreign"> + <param name="property">A</param> + </generator> + </id> + <property name="Name" /> + + <one-to-one name="A" class="A" constrained="true"/> + + <!--using a many-to-one assosciation instead makes the test succeed --> + + <!--<many-to-one name="A"></many-to-one>--> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 20:53:09 UTC (rev 4394) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 22:33:06 UTC (rev 4395) @@ -446,6 +446,8 @@ <Compile Include="NHSpecificTest\NH1794\Person.cs" /> <Compile Include="NHSpecificTest\NH1796\Entity.cs" /> <Compile Include="NHSpecificTest\NH1796\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1801\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1801\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1840,6 +1842,7 @@ <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1801\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1796\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1788\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-06-01 01:14:27
|
Revision: 4396 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4396&view=rev Author: fabiomaulo Date: 2009-06-01 00:16:33 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Fix NH-1735 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/TicksType.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs Modified: trunk/nhibernate/src/NHibernate/Type/TicksType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TicksType.cs 2009-05-31 22:33:06 UTC (rev 4395) +++ trunk/nhibernate/src/NHibernate/Type/TicksType.cs 2009-06-01 00:16:33 UTC (rev 4396) @@ -96,7 +96,7 @@ public IComparer Comparator { - get { return Comparer<Int64>.Default; } + get { return Comparer<DateTime>.Default; } } #endregion Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs 2009-05-31 22:33:06 UTC (rev 4395) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs 2009-06-01 00:16:33 UTC (rev 4396) @@ -28,5 +28,14 @@ TicksType type = (TicksType) NHibernateUtil.Ticks; Assert.IsTrue(type.Seed(null) is DateTime, "seed should be DateTime"); } + + [Test] + public void Comparer() + { + var type = (IVersionType)NHibernateUtil.Ticks; + object v1 = type.Seed(null); + var v2 = v1; + Assert.DoesNotThrow(() => type.Comparator.Compare(v1, v2)); + } } } \ 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: <fab...@us...> - 2009-06-01 18:19:17
|
Revision: 4399 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4399&view=rev Author: fabiomaulo Date: 2009-06-01 18:18:23 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Fix NH-1789 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 16:46:16 UTC (rev 4398) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -39,7 +39,9 @@ { try { - MethodInfo method = clazz.GetMethod(methodName, parametersTypes); + MethodInfo method = !clazz.IsInterface + ? clazz.GetMethod(methodName, parametersTypes) + : GetMethodFromInterface(clazz, methodName, parametersTypes); if (method == null) { return false; @@ -59,6 +61,29 @@ } } + private static MethodInfo GetMethodFromInterface(System.Type type, string methodName, System.Type[] parametersTypes) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly; + if(type == null) + { + return null; + } + MethodInfo method = type.GetMethod(methodName, flags, null, parametersTypes, null); + if (method == null) + { + System.Type[] interfaces = type.GetInterfaces(); + foreach (var @interface in interfaces) + { + method = GetMethodFromInterface(@interface, methodName, parametersTypes); + if(method != null) + { + return method; + } + } + } + return method; + } + /// <summary> /// Determine if the specified <see cref="System.Type"/> overrides the /// implementation of GetHashCode from <see cref="Object"/> @@ -67,7 +92,7 @@ /// <returns><see langword="true" /> if any type in the hierarchy overrides GetHashCode().</returns> public static bool OverridesGetHashCode(System.Type clazz) { - return OverrideMethod(clazz, "Equals", System.Type.EmptyTypes); + return OverrideMethod(clazz, "GetHashCode", System.Type.EmptyTypes); } /// <summary> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,34 @@ +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + public class Cat : DomainObject, ICat + { + public Cat(string name, long id) + { + Name = name; + _id = id; + } + + /// <summary> + /// NHibernate parameterless constructor + /// </summary> + protected Cat() {} + + #region ICat Members + + ///<summary> + /// This is a string which uniquely identifies an instance in the case that the ids + /// are both transient + ///</summary> + public override string BusinessKey + { + get { return Name; } + } + + /// <summary> + /// Name of the cat + /// </summary> + public virtual string Name { get; set; } + + #endregion + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,133 @@ +using System; +using NHibernate.Proxy; + +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + ///<summary> + /// The base for all objects in the model + ///</summary> + [Serializable] + public abstract class DomainObject : IDomainObject + { + protected long _id; + + #region IDomainObject Members + + /// <summary> + /// Database ID. This ID doesn't have any business meaning. + /// </summary> + public virtual long ID + { + get { return _id; } + set { _id = value; } + } + + /// <summary> + /// Transient objects are not associated with an + /// item already in storage. For instance, a + /// Customer is transient if its ID is 0. + /// </summary> + public virtual bool IsTransient() + { + return ID.Equals(0); + } + + ///<summary> + /// This is a string which uniquely identifies an instance in the case that the ids + /// are both transient + ///</summary> + public abstract string BusinessKey { get; } + + /// <summary> + /// Returns the concrete type of the object, not the proxy one. + /// </summary> + /// <returns></returns> + public virtual System.Type GetConcreteType() + { + return NHibernateProxyHelper.GuessClass(this); + } + + #endregion + + ///<summary> + /// The equals method works with the persistence framework too + ///</summary> + ///<param name="obj"></param> + ///<returns></returns> + public override bool Equals(object obj) + { + Console.Out.WriteLine("Calling Equals"); + + var compareTo = obj as IDomainObject; + + if (compareTo == null) + { + return false; + } + + if (compareTo.GetConcreteType() != GetConcreteType()) + { + return false; + } + + if (BothNonDefaultIds(compareTo)) + { + return ID.CompareTo(compareTo.ID).Equals(0); + } + + if ((IsTransient() || compareTo.IsTransient()) && HasSameBusinessSignatureAs(compareTo)) + { + return true; + } + + return false; + } + + private bool HasSameBusinessSignatureAs(IDomainObject compareTo) + { + return BusinessKey.Equals(compareTo.BusinessKey); + } + + private bool BothNonDefaultIds(IDomainObject compareTo) + { + return !ID.Equals(0) && !compareTo.ID.Equals(0); + } + + /// <summary> + /// Must be implemented to compare two objects + /// </summary> + public override int GetHashCode() + { + return ID.GetHashCode(); + } + + /// <summary> + /// Turn a proxy object into a "real" object. If the <paramref name="proxy"/> you give in parameter is not a INHibernateProxy, it will returns the same object without any change. + /// </summary> + /// <typeparam name="T">Type in which the unproxied object should be returned</typeparam> + /// <param name="proxy">Proxy object</param> + /// <returns>Unproxied object</returns> + public static T UnProxy<T>(object proxy) + { + //If the object is not a proxy, just cast it and returns it + if (!(proxy is INHibernateProxy)) + { + return (T) proxy; + } + + //Otherwise, use the NHibernate methods to get the implementation, and cast it + var p = (INHibernateProxy) proxy; + return (T) p.HibernateLazyInitializer.GetImplementation(); + } + + /// <summary> + /// Turn a proxy object into a "real" object. If the <paramref name="proxy"/> you give in parameter is not a INHibernateProxy, it will returns the same object without any change. + /// </summary> + /// <param name="proxy">Proxy object</param> + /// <returns>Unproxied object</returns> + public static object UnProxy(object proxy) + { + return UnProxy<object>(proxy); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,13 @@ +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + /// <summary> + /// An interface + /// </summary> + public interface ICat : IDomainObject + { + /// <summary> + /// Name of the cat + /// </summary> + string Name { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,35 @@ +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + /// <summary> + /// Domain Object + /// </summary> + public interface IDomainObject + { + /// <summary> + /// Database unique ID for this object. This ID shouldn't have any business meaning. + /// </summary> + long ID { get; set; } + + ///<summary> + /// This is a string which uniquely identifies an instance in the case that the ids + /// are both transient + ///</summary> + string BusinessKey { get; } + + /// <summary> + /// Transient objects are not associated with an + /// item already in storage. For instance, a + /// Customer is transient if its ID is 0. + /// </summary> + bool IsTransient(); + + /// <summary> + /// Returns the concrete type of the object, not the proxy one. + /// </summary> + /// <returns></returns> + System.Type GetConcreteType(); + + bool Equals(object that); + int GetHashCode(); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1789"> + <class name="ICat"> + <id name="ID"> + <generator class="assigned" /> + </id> + + <discriminator column="Type"></discriminator> + + <property name="Name" /> + + <subclass name="Cat" discriminator-value="cat"></subclass> + + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,124 @@ +using System.Collections; +using NHibernate.Proxy; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + [TestFixture] + public class ProxyEqualityProblemTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + ICat cat1 = new Cat("Marcel", 1); + ICat cat2 = new Cat("Maurice", 2); + + session.Save(cat1); + session.Save(cat2); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + string hql = "from System.Object"; + session.Delete(hql); + session.Flush(); + } + } + + /// <summary> + /// This test fails: when compariing a proxy with a non-proxy, I want the proxy to use the Equals() method on DomainObject to check for equality. + /// It doesn't do it, so the equality fails. + /// </summary> + [Test] + public void TestProxyEqualityProblem() + { + using (ISession session = OpenSession()) + { + //We load a proxy version of Maurice + var mauriceProxy = session.Load<ICat>((long) 2); + + Assert.IsTrue(mauriceProxy is INHibernateProxy, "The proxy should be of type INHibernateProxy"); + + //From it's proxy, we get a non-proxied (concrete?) version + var mauriceNonProxy = DomainObject.UnProxy<ICat>(mauriceProxy); + + Assert.IsTrue(!(mauriceNonProxy is INHibernateProxy), "The non-proxy shouldn't be of type INHibernateProxy"); + + //We check if the name and ID matches (as they should be because they are the same entity!) + Assert.AreEqual(mauriceProxy.Name, mauriceNonProxy.Name, "The two objects should have the same name"); + Assert.AreEqual(mauriceProxy.ID, mauriceNonProxy.ID, "The two objects should have the same ID"); + + //Now here's the problem: + //When calling Equals() on the non-proxy, everything works (calling the overriden Equals() method on DomainObject as it should be) + Assert.IsTrue(mauriceNonProxy.Equals(mauriceProxy), "The two instances should be declared equal"); + + //But when calling it on the proxy, it doesn't, and they return a false for the equality, and that's a bug IMHO + bool condition = mauriceProxy.Equals(mauriceNonProxy); + Assert.IsTrue(condition, "The two instances should be declared equal"); + } + } + + /// <summary> + /// Here, instead of querying an ICat, we query a Cat directly: everything works, and DomainObject.Equals() is properly called on the proxy. + /// </summary> + [Test] + public void TestProxyEqualityWhereItDoesWork() + { + using (ISession session = OpenSession()) + { + //We load a proxy version of Maurice + var mauriceProxy = session.Load<Cat>((long) 2); + + Assert.IsTrue(mauriceProxy is INHibernateProxy, "The proxy should be of type INHibernateProxy"); + + //From it's proxy, we get a non-proxied (concrete?) version + var mauriceNonProxy = DomainObject.UnProxy<Cat>(mauriceProxy); + + Assert.IsTrue(!(mauriceNonProxy is INHibernateProxy), "The non-proxy shouldn't be of type INHibernateProxy"); + + //We check if the name and ID matches (as they should be because they are the same entity!) + Assert.AreEqual(mauriceProxy.Name, mauriceNonProxy.Name, "The two objects should have the same name"); + Assert.AreEqual(mauriceProxy.ID, mauriceNonProxy.ID, "The two objects should have the same ID"); + + //Because we queried a concrete class (Cat instead of ICat), here it works both ways: + Assert.IsTrue(mauriceNonProxy.Equals(mauriceProxy), "The two instances should be declared equal"); + Assert.IsTrue(mauriceProxy.Equals(mauriceNonProxy), "The two instances should be declared equal"); + } + } + + /// <summary> + /// That's how I discovered something was wrong: here my object is not found in the collection, even if it's there. + /// </summary> + [Test] + public void TestTheProblemWithCollection() + { + using (ISession session = OpenSession()) + { + //As before, we load a proxy, a non-proxy of the same entity, and checks everything is correct: + var mauriceProxy = session.Load<ICat>((long) 2); + Assert.IsTrue(mauriceProxy is INHibernateProxy, "The proxy should be of type INHibernateProxy"); + var mauriceNonProxy = DomainObject.UnProxy<ICat>(mauriceProxy); + Assert.IsTrue(!(mauriceNonProxy is INHibernateProxy), "The non-proxy shouldn't be of type INHibernateProxy"); + Assert.AreEqual(mauriceProxy.Name, mauriceNonProxy.Name, "The two objects should have the same name"); + Assert.AreEqual(mauriceProxy.ID, mauriceNonProxy.ID, "The two objects should have the same ID"); + + //Ok now we add the proxy version into a collection: + var collection = new ArrayList(); + collection.Add(mauriceProxy); + + //The proxy should be able to find itself: + Assert.IsTrue(collection.Contains(mauriceProxy), "The proxy should be present in the collection"); + + //Now, the non-proxy should also be able to find itself in the collection, using the Equals() on DomainObject... + Assert.IsTrue(collection.Contains(mauriceNonProxy), "The proxy should be present in the collection"); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 16:46:16 UTC (rev 4398) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 18:18:23 UTC (rev 4399) @@ -440,6 +440,11 @@ <Compile Include="NHSpecificTest\NH1783\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1788\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1788\Person.cs" /> + <Compile Include="NHSpecificTest\NH1789\Cat.cs" /> + <Compile Include="NHSpecificTest\NH1789\DomainObject.cs" /> + <Compile Include="NHSpecificTest\NH1789\ICat.cs" /> + <Compile Include="NHSpecificTest\NH1789\IDomainObject.cs" /> + <Compile Include="NHSpecificTest\NH1789\ProxyEqualityProblemTest.cs" /> <Compile Include="NHSpecificTest\NH1792\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1792\Product.cs" /> <Compile Include="NHSpecificTest\NH1794\Fixture.cs" /> @@ -1842,6 +1847,7 @@ <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1789\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1801\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1796\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2009-06-01 16:46:16 UTC (rev 4398) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -19,6 +19,26 @@ Assert.AreEqual(1, (int) result, "Should have found value of 1"); } + public interface IMyBaseWithEqual + { + bool Equals(object that); + int GetHashCode(); + } + + public interface IMyInheritedWithEqual : IMyBaseWithEqual + { + } + + public interface IEmpty + { + + } + + public interface IComplex: IEmpty, IMyInheritedWithEqual + { + + } + [Test] public void OverridesEquals() { @@ -26,9 +46,35 @@ Assert.IsTrue(ReflectHelper.OverridesEquals(typeof(string)), "String does override equals"); Assert.IsFalse(ReflectHelper.OverridesEquals(typeof(IDisposable)), "IDisposable does not override equals"); Assert.IsTrue(ReflectHelper.OverridesEquals(typeof(BRhf)), "Base class overrides equals"); + Assert.That(!ReflectHelper.OverridesEquals(typeof (object)), "System.Object does not override."); } [Test] + public void InheritedInterfaceOverridesEquals() + { + Assert.That(ReflectHelper.OverridesEquals(typeof(IMyBaseWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesEquals(typeof(IMyInheritedWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesEquals(typeof(IComplex)), "does override."); + } + + [Test] + public void OverridesGetHashCode() + { + Assert.IsFalse(ReflectHelper.OverridesGetHashCode(this.GetType()), "ReflectHelperFixture does not override GetHashCode"); + Assert.IsTrue(ReflectHelper.OverridesGetHashCode(typeof(string)), "String does override equals"); + Assert.IsFalse(ReflectHelper.OverridesGetHashCode(typeof(IDisposable)), "IDisposable does not override GetHashCode"); + Assert.IsTrue(ReflectHelper.OverridesGetHashCode(typeof(BRhf)), "Base class overrides GetHashCode"); + Assert.That(!ReflectHelper.OverridesGetHashCode(typeof(object)), "System.Object does not override."); + } + + [Test] + public void InheritedInterfaceOverridesGetHashCode() + { + Assert.That(ReflectHelper.OverridesGetHashCode(typeof(IMyBaseWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesGetHashCode(typeof(IMyInheritedWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesGetHashCode(typeof(IComplex)), "does override."); + } + [Test] public void NoTypeFoundReturnsNull() { System.Type noType = ReflectHelper.TypeFromAssembly("noclass", "noassembly", false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-02 23:09:15
|
Revision: 4402 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4402&view=rev Author: fabiomaulo Date: 2009-06-02 23:09:13 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Fix NH-1517 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs 2009-06-01 19:58:58 UTC (rev 4401) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs 2009-06-02 23:09:13 UTC (rev 4402) @@ -1,6 +1,7 @@ using System; using System.Collections; using log4net; +using NHibernate.Classic; using NHibernate.Engine; using NHibernate.Intercept; using NHibernate.Persister.Entity; @@ -230,6 +231,12 @@ } else { + // NH different behavior : NH-1517 + if (InvokeUpdateLifecycle(entity, persister, source)) + { + return; + } + copyCache[entity] = result; //before cascade! object target = source.PersistenceContext.Unproxy(result); @@ -263,6 +270,20 @@ } } + protected virtual bool InvokeUpdateLifecycle(object entity, IEntityPersister persister, IEventSource source) + { + if (persister.ImplementsLifecycle(source.EntityMode)) + { + log.Debug("calling onUpdate()"); + if (((ILifecycle)entity).OnUpdate(source) == LifecycleVeto.Veto) + { + log.Debug("update vetoed by onUpdate()"); + return true; + } + } + return false; + } + private void MarkInterceptorDirty(object entity, object target) { if (FieldInterceptionHelper.IsInstrumented(entity)) Added: trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs 2009-06-02 23:09:13 UTC (rev 4402) @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using NHibernate.Classic; + +namespace NHibernate.Test.Classic +{ + public class EntityWithLifecycle : ILifecycle + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual double Heigth { get; set; } + public virtual double Width { get; set; } + public EntityWithLifecycle() {} + public EntityWithLifecycle(string name, double heigth, double width) + { + Name = name; + Heigth = heigth; + Width = width; + } + + public virtual LifecycleVeto OnSave(ISession s) + { + return IsValid() ? LifecycleVeto.NoVeto : LifecycleVeto.Veto; + } + + public virtual LifecycleVeto OnUpdate(ISession s) + { + return IsValid() ? LifecycleVeto.NoVeto : LifecycleVeto.Veto; + } + + public virtual LifecycleVeto OnDelete(ISession s) + { + return IsValid() ? LifecycleVeto.NoVeto : LifecycleVeto.Veto; + } + + public virtual void OnLoad(ISession s, object id) + { + // nothing to do + } + + public virtual IList<string> GetBrokenRules() + { + IList<string> result = new List<string>(3); + if (string.IsNullOrEmpty(Name) || Name.Trim().Length < 2) + result.Add("The Name must have more than one char."); + if (Heigth <= 0) + result.Add("Heigth must be great than 0"); + if (Width <= 0) + result.Add("Width must be great than 0."); + return result; + } + + /// <summary> + /// Validate the state of the object before persisting it. If a violation occurs, + /// throw a <see cref="ValidationFailure" />. This method must not change the state of the object + /// by side-effect. + /// </summary> + private bool IsValid() + { + IList<string> br = GetBrokenRules(); + return br == null || br.Count == 0; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml 2009-06-02 23:09:13 UTC (rev 4402) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.Classic" + assembly="NHibernate.Test" > + <class name="EntityWithLifecycle"> + <id name="Id"> + <generator class="hilo" /> + </id> + <property name="Name" type="string" length="40"/> + <property name="Heigth" type="double"/> + <property name="Width" type="double"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs 2009-06-02 23:09:13 UTC (rev 4402) @@ -0,0 +1,134 @@ +using System.Collections; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.Classic +{ + [TestFixture] + public class LifecycleFixture : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "Classic.EntityWithLifecycle.hbm.xml" }; } + } + + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.GenerateStatistics, "true"); + } + + [Test] + public void Save() + { + sessions.Statistics.Clear(); + using (ISession s = OpenSession()) + { + s.Save(new EntityWithLifecycle()); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0)); + + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Delete(v); + s.Flush(); + } + } + + [Test] + public void Update() + { + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Flush(); + } + + // update detached + sessions.Statistics.Clear(); + v.Heigth = 0; + using (ISession s = OpenSession()) + { + s.Update(v); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + // cleanup + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test] + public void SaveOrUpdateCopy() + { + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Flush(); + } + v.Heigth = 0; + sessions.Statistics.Clear(); + using (ISession s = OpenSession()) + { + s.SaveOrUpdateCopy(v); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + var v1 = new EntityWithLifecycle("Shinobi", 0, 10); + using (ISession s = OpenSession()) + { + s.SaveOrUpdateCopy(v1); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0)); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + + // cleanup + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test] + public void Delete() + { + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Flush(); + sessions.Statistics.Clear(); + v.Heigth = 0; + s.Delete(v); + s.Flush(); + Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(0)); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate(); + tx.Commit(); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 19:58:58 UTC (rev 4401) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-02 23:09:13 UTC (rev 4402) @@ -110,6 +110,8 @@ <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> + <Compile Include="Classic\EntityWithLifecycle.cs" /> + <Compile Include="Classic\LifecycleFixture.cs" /> <Compile Include="Classic\ValidatableFixture.cs" /> <Compile Include="Classic\Video.cs" /> <Compile Include="CollectionTest\A.cs" /> @@ -1851,6 +1853,7 @@ <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> + <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1757\Mappings.hbm.xml" /> <EmbeddedResource Include="Events\PostEvents\SimpleEntity.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-03 06:15:31
|
Revision: 4404 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4404&view=rev Author: fabiomaulo Date: 2009-06-03 06:15:26 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fix NH-1487 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 04:22:51 UTC (rev 4403) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 06:15:26 UTC (rev 4404) @@ -1108,9 +1108,9 @@ { if (indexAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(indexAttribute.Value, ", "); + var tokens = new StringTokenizer(indexAttribute.Value, ",", false); foreach (string token in tokens) - table.GetOrCreateIndex(token).AddColumn(column); + table.GetOrCreateIndex(token.Trim()).AddColumn(column); } } @@ -1118,9 +1118,9 @@ { if (uniqueKeyAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(uniqueKeyAttribute.Value, ", "); + var tokens = new StringTokenizer(uniqueKeyAttribute.Value, ",", false); foreach (string token in tokens) - table.GetOrCreateUniqueKey(token).AddColumn(column); + table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column); } } @@ -1287,9 +1287,9 @@ { if (indexAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(indexAttribute, ", "); + var tokens = new StringTokenizer(indexAttribute, ",", false); foreach (string token in tokens) - table.GetOrCreateIndex(token).AddColumn(column); + table.GetOrCreateIndex(token.Trim()).AddColumn(column); } } @@ -1297,9 +1297,9 @@ { if (uniqueKeyAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(uniqueKeyAttribute, ", "); + var tokens = new StringTokenizer(uniqueKeyAttribute, ",", false); foreach (string token in tokens) - table.GetOrCreateUniqueKey(token).AddColumn(column); + table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column); } } Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-06-03 04:22:51 UTC (rev 4403) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-06-03 06:15:26 UTC (rev 4404) @@ -152,16 +152,16 @@ if (columnSchema.index != null && id.Table != null) { - StringTokenizer tokens = new StringTokenizer(columnSchema.index, ", "); + var tokens = new StringTokenizer(columnSchema.index, ",", false); foreach (string token in tokens) - id.Table.GetOrCreateIndex(token).AddColumn(column); + id.Table.GetOrCreateIndex(token.Trim()).AddColumn(column); } if (columnSchema.uniquekey != null && id.Table != null) { - StringTokenizer tokens = new StringTokenizer(columnSchema.uniquekey, ", "); + var tokens = new StringTokenizer(columnSchema.uniquekey, ",", false); foreach (string token in tokens) - id.Table.GetOrCreateUniqueKey(token).AddColumn(column); + id.Table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column); } } } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs 2009-06-03 06:15:26 UTC (rev 4404) @@ -0,0 +1,215 @@ +using System.Text; +using NHibernate.Cfg; +using NHibernate.Dialect; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1487 +{ + public class Entity + { + int field; + public int Id { get { return field; } set { field = value; } } + public int A { get { return field; } set { field = value; } } + public int B { get { return field; } set { field = value; } } + public int C { get { return field; } set { field = value; } } + } + + /// <summary> + /// Summary description for TestTestCase. + /// </summary> + [TestFixture] + public class Fixture + { + + public Configuration GetConf() + { + var cfg = new Configuration(); + if (TestConfigurationHelper.hibernateConfigFile != null) + cfg.Configure(TestConfigurationHelper.hibernateConfigFile); + return cfg; + } + + [Test] + public void GenerateSchemaMultipleUniqueKeys() + { + if(!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <generator class='assigned' /> + </id> + <property name='A' unique-key='AC'/> + <property name='B' unique-key='BC'/> + <property name='C' unique-key='AC, BC'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + + cfg.AddXmlString(hbm); + + // Can create the schema + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("unique (A, C)")); + Assert.That(script, Text.Contains("unique (B, C)")); + Assert.That(script, Text.DoesNotContain("unique (C)")); + + new SchemaExport(cfg).Drop(false, true); + } + + [Test] + public void GenerateSchemaMultipleIndex() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <generator class='assigned' /> + </id> + <property name='A' index='AC'/> + <property name='B' index='BC'/> + <property name='C' index='AC, BC'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("create index AC on Entity (A, C)")); + Assert.That(script, Text.Contains("create index BC on Entity (B, C)")); + + new SchemaExport(cfg).Drop(false, true); + } + + [Test] + public void GenerateSchemaMultipleIndexOnColumn() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <generator class='assigned' /> + </id> + <property name='A'> + <column name='A' index='AC'/> + </property> + <property name='B'> + <column name='B' index='BC'/> + </property> + <property name='C'> + <column name='C' index='AC,BC'/> + </property> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("create index AC on Entity (A, C)")); + Assert.That(script, Text.Contains("create index BC on Entity (B, C)")); + + new SchemaExport(cfg).Drop(false, true); + } + [Test] + public void GenerateSchemaIndexOnId() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <column name='Id' index='IdxId1,IdxId2'/> + <generator class='assigned' /> + </id> + <property name='A'/> + <property name='B'/> + <property name='C'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("create index IdxId1 on Entity (Id)")); + Assert.That(script, Text.Contains("create index IdxId2 on Entity (Id)")); + + new SchemaExport(cfg).Drop(false, true); + } + + [Test] + public void GenerateSchemaUniqueOnId() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <column name='Id' unique-key='UIdxId1,UIdxId2'/> + <generator class='assigned' /> + </id> + <property name='A'/> + <property name='B'/> + <property name='C'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.AppendLine(sl), true); + var script = scriptB.ToString().Split(new[] { System.Environment.NewLine, "\n" }, StringSplitOptions.RemoveEmptyEntries); + int count=0; + foreach (var s in script) + { + if (s.Contains("unique (Id)")) + count++; + } + Assert.That(count, Is.EqualTo(2)); + + new SchemaExport(cfg).Drop(false, true); + } + + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 04:22:51 UTC (rev 4403) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 06:15:26 UTC (rev 4404) @@ -364,6 +364,7 @@ <Compile Include="NHSpecificTest\NH1343\Product.cs" /> <Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" /> <Compile Include="NHSpecificTest\NH1388\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1487\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1531\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1531\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1553\MsSQL\Person.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-03 22:56:52
|
Revision: 4405 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4405&view=rev Author: fabiomaulo Date: 2009-06-03 22:56:42 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fix NH-1427 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 06:15:26 UTC (rev 4404) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 22:56:42 UTC (rev 4405) @@ -345,10 +345,13 @@ //PropertiesFromXML(node, persistentClass, mappings); foreach (XmlNode subnode in node.ChildNodes) { + //I am only concerned with elements that are from the nhibernate namespace + if (subnode.NamespaceURI != Configuration.MappingSchemaXMLNS) + continue; + string name = subnode.Name; XmlAttribute nameAttribute = subnode.Attributes["name"]; string propertyName = nameAttribute == null ? null : nameAttribute.Value; - IValue value = null; var collectionBinder = new CollectionBinder(this); if (collectionBinder.CanCreate(name)) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs 2009-06-03 22:56:42 UTC (rev 4405) @@ -0,0 +1,16 @@ +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1427 +{ + [TestFixture] + public class Fixture + { + [Test] + public void TestMappingWithJoinElementContainingXmlComments() + { + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + Assert.DoesNotThrow(() => cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1427.Mappings.hbm.xml", GetType().Assembly)); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml 2009-06-03 22:56:42 UTC (rev 4405) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1427"> + + <class name="Person" table="Person1"> + + <id name="PersonId" column="PersonId" type="Int32"> + <generator class="assigned" /> + </id> + + <property name="Name" column="Name" type="String" length="25" not-null="true" /> + + <join table="Person2"> + <!-- Comment: causes test to fail --> + <key column="PersonId" /> + <property name="LogonId" column="LogonId" type="String" length="16" not-null="true" /> + <property name="LastLogon" column="LastLogon" type="DateTime" not-null="false" /> + </join> + + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs 2009-06-03 22:56:42 UTC (rev 4405) @@ -0,0 +1,12 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1427 +{ + public class Person + { + public virtual int PersonId { get; set; } + public virtual string Name { get; set; } + public virtual string LogonId { get; set; } + public virtual DateTime LastLogon { 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-06-03 06:15:26 UTC (rev 4404) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 22:56:42 UTC (rev 4405) @@ -364,6 +364,8 @@ <Compile Include="NHSpecificTest\NH1343\Product.cs" /> <Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" /> <Compile Include="NHSpecificTest\NH1388\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1427\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1427\Person.cs" /> <Compile Include="NHSpecificTest\NH1487\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1531\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1531\SampleTest.cs" /> @@ -1858,6 +1860,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1427\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1531\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1757\Mappings.hbm.xml" /> <EmbeddedResource Include="Events\PostEvents\SimpleEntity.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-03 23:41:25
|
Revision: 4406 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4406&view=rev Author: fabiomaulo Date: 2009-06-03 23:41:22 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fix NH-1044 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-06-03 22:56:42 UTC (rev 4405) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-06-03 23:41:22 UTC (rev 4406) @@ -2,7 +2,7 @@ /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -83,7 +83,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -110,7 +110,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -128,7 +128,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -193,7 +193,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -207,7 +207,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -372,7 +372,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -386,7 +386,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -413,7 +413,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -465,7 +465,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -524,7 +524,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -565,7 +565,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -586,7 +586,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -618,7 +618,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -632,7 +632,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -770,7 +770,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -784,7 +784,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -888,7 +888,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1005,7 +1005,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1023,7 +1023,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1041,7 +1041,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1121,7 +1121,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1151,7 +1151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1255,7 +1255,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1277,7 +1277,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1329,7 +1329,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1343,7 +1343,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1373,7 +1373,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1591,7 +1591,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1829,7 +1829,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1851,7 +1851,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1920,7 +1920,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1970,7 +1970,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2015,7 +2015,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [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.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2086,7 +2086,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2104,7 +2104,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2158,7 +2158,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2185,7 +2185,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2210,6 +2210,7 @@ [System.Xml.Serialization.XmlElementAttribute("bag", typeof(HbmBag))] [System.Xml.Serialization.XmlElementAttribute("component", typeof(HbmComponent))] [System.Xml.Serialization.XmlElementAttribute("dynamic-component", typeof(HbmDynamicComponent))] + [System.Xml.Serialization.XmlElementAttribute("idbag", typeof(HbmIdbag))] [System.Xml.Serialization.XmlElementAttribute("list", typeof(HbmList))] [System.Xml.Serialization.XmlElementAttribute("many-to-one", typeof(HbmManyToOne))] [System.Xml.Serialization.XmlElementAttribute("map", typeof(HbmMap))] @@ -2270,7 +2271,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2334,7 +2335,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2519,7 +2520,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2713,7 +2714,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2732,7 +2733,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2751,7 +2752,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2777,7 +2778,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2807,7 +2808,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2842,7 +2843,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2877,7 +2878,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2970,7 +2971,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3112,7 +3113,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayOuterjoin { @@ -3131,7 +3132,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayFetch { @@ -3150,7 +3151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3334,170 +3335,11 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - [System.Xml.Serialization.XmlRootAttribute("timestamp", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] - public partial class HbmTimestamp { - - /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("meta")] - public HbmMeta[] meta; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string name; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string node; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string column; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string access; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] - public HbmTimestampUnsavedvalue unsavedvalue; - - /// <remarks/> - [System.Xml.Serialization.XmlIgnoreAttribute()] - public bool unsavedvalueSpecified; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute(HbmTimestampSource.Vm)] - public HbmTimestampSource source; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] - public HbmVersionGeneration generated; - - public HbmTimestamp() { - this.source = HbmTimestampSource.Vm; - this.generated = HbmVersionGeneration.Never; - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - public enum HbmTimestampUnsavedvalue { - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("null")] - Null, - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("undefined")] - Undefined, - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - public enum HbmTimestampSource { - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("vm")] - Vm, - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("db")] - Db, - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] - public enum HbmVersionGeneration { - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("never")] - Never, - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("always")] - Always, - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - [System.Xml.Serialization.XmlRootAttribute("version", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] - public partial class HbmVersion { - - /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("meta")] - public HbmMeta[] meta; - - /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("column")] - public HbmColumn[] column; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string name; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string node; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string access; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("column")] - public string column1; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute("Int32")] - public string type; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] - public string unsavedvalue; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] - public HbmVersionGeneration generated; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public bool insert; - - /// <remarks/> - [System.Xml.Serialization.XmlIgnoreAttribute()] - public bool insertSpecified; - - public HbmVersion() { - this.type = "Int32"; - this.generated = HbmVersionGeneration.Never; - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] [System.Xml.Serialization.XmlRootAttribute("idbag", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] public partial class HbmIdbag { @@ -3676,7 +3518,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3709,11 +3551,170 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + [System.Xml.Serialization.XmlRootAttribute("timestamp", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] + public partial class HbmTimestamp { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("meta")] + public HbmMeta[] meta; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string name; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string node; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string column; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string access; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] + public HbmTimestampUnsavedvalue unsavedvalue; + + /// <remarks/> + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool unsavedvalueSpecified; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(HbmTimestampSource.Vm)] + public HbmTimestampSource source; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] + public HbmVersionGeneration generated; + + public HbmTimestamp() { + this.source = HbmTimestampSource.Vm; + this.generated = HbmVersionGeneration.Never; + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + public enum HbmTimestampUnsavedvalue { + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("null")] + Null, + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("undefined")] + Undefined, + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + public enum HbmTimestampSource { + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("vm")] + Vm, + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("db")] + Db, + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] + public enum HbmVersionGeneration { + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("never")] + Never, + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("always")] + Always, + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + [System.Xml.Serialization.XmlRootAttribute("version", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] + public partial class HbmVersion { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("meta")] + public HbmMeta[] meta; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("column")] + public HbmColumn[] column; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string name; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string node; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string access; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("column")] + public string column1; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute("Int32")] + public string type; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] + public string unsavedvalue; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] + public HbmVersionGeneration generated; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public bool insert; + + /// <remarks/> + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool insertSpecified; + + public HbmVersion() { + this.type = "Int32"; + this.generated = HbmVersionGeneration.Never; + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] [System.Xml.Serialization.XmlRootAttribute("properties", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] public partial class HbmProperties { @@ -3761,7 +3762,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3844,7 +3845,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmJoinFetch { @@ -3859,7 +3860,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4020,7 +4021,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4041,7 +4042,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4072,7 +4073,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4094,7 +4095,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4108,7 +4109,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLockMode { @@ -4135,7 +4136,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4174,7 +4175,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4188,7 +4189,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4219,7 +4220,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4237,7 +4238,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4312,7 +4313,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4330,7 +4331,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFlushMode { @@ -4349,7 +4350,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheMode { @@ -4376,7 +4377,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4466,7 +4467,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4605,7 +4606,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4763,7 +4764,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPolymorphismType { @@ -4778,7 +4779,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOptimisticLockMode { @@ -4801,7 +4802,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4815,7 +4816,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4835,7 +4836,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4849,7 +4850,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4863,7 +4864,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4881,7 +4882,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4907,7 +4908,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4925,7 +4926,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5014,7 +5015,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5036,7 +5037,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-06-03 22:56:42 UTC (rev 4405) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-06-03 23:41:22 UTC (rev 4406) @@ -266,6 +266,7 @@ <xs:element ref="set" /> <xs:element ref="list" /> <xs:element ref="bag" /> + <xs:element ref="idbag" /> <xs:element ref="array" /> <xs:element ref="primitive-array" /> </xs:choice> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs 2009-06-03 23:41:22 UTC (rev 4406) @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1044 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual Delivery Delivery { get; set; } + } + + public class Delivery + { + public Delivery() + { + Adresses = new List<string>(); + } + public virtual IList<string> Adresses { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs 2009-06-03 23:41:22 UTC (rev 4406) @@ -0,0 +1,40 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1044 +{ + [TestFixture] + public class Fixture: BugTestCase + { + [Test] + public void Crud() + { + // Only as a quick check that is can work with the idbag inside the component + var p = new Person {Name = "Fiamma", Delivery = new Delivery()}; + p.Delivery.Adresses.Add("via Parenzo 96"); + p.Delivery.Adresses.Add("viale Don Bosco 192"); + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(p); + t.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var pp = s.Get<Person>(p.Id); + pp.Delivery.Adresses.RemoveAt(0); + t.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var pp = s.Get<Person>(p.Id); + Assert.That(pp.Delivery.Adresses.Count, Is.EqualTo(1)); + s.Delete(pp); + t.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml 2009-06-03 23:41:22 UTC (rev 4406) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1044" + assembly="NHibernate.Test"> + + <class name="Person"> + <id name="Id"> + <generator class="hilo"/> + </id> + <property name="Name"/> + <component name="Delivery"> + <idbag name="Adresses" cascade="all"> + <collection-id type="int" column="poid"> + <generator class="hilo"/> + </collection-id> + <key column="owner"/> + <element column="street"/> + </idbag> + </component> + </class> +</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-06-03 22:56:42 UTC (rev 4405) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 23:41:22 UTC (rev 4406) @@ -350,6 +350,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\NH1044\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1044\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\SimpleCached.cs" /> <Compile Include="NHSpecificTest\NH1159\Contact.cs" /> @@ -1860,6 +1862,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1044\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1427\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1531\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1757\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-06-04 00:06:47
|
Revision: 4407 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4407&view=rev Author: fabiomaulo Date: 2009-06-04 00:06:41 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Test for bulkUpdate with StatelessSession (with minor bug fix) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-06-03 23:41:22 UTC (rev 4406) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-06-04 00:06:41 UTC (rev 4407) @@ -61,6 +61,10 @@ var parameterTypes = new List<SqlType>(Parameters.Count); foreach (var parameterSpecification in Parameters) { + if (parameterSpecification.ExpectedType == null) + { + throw new QuerySyntaxException("Can't determine SqlType of parameter " + parameterSpecification.RenderDisplayInfo()+"\n Possible cause: wrong case-sensitive property-name."); + } parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); } st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes.ToArray()); Modified: trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs 2009-06-03 23:41:22 UTC (rev 4406) +++ trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs 2009-06-04 00:06:41 UTC (rev 4407) @@ -39,8 +39,10 @@ return typedValue.Type.GetColumnSpan( session.Factory ); } - public override string RenderDisplayInfo() { - return "name=" + _name + ", expectedType=" + ExpectedType; + public override string RenderDisplayInfo() + { + const string format = "name={0}, expectedType={1}"; + return ExpectedType != null ? string.Format(format, _name, ExpectedType) : string.Format(format, _name, "Unknow"); } /// <summary> Modified: trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-06-03 23:41:22 UTC (rev 4406) +++ trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-06-04 00:06:41 UTC (rev 4407) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Threading; +using NHibernate.Hql.Ast.ANTLR; using NUnit.Framework; namespace NHibernate.Test.Stateless @@ -88,7 +89,7 @@ } } - [Test, Ignore("Not supported yet")] + [Test] public void HqlBulk() { IStatelessSession ss = sessions.OpenStatelessSession(); @@ -101,10 +102,10 @@ tx = ss.BeginTransaction(); int count = - ss.CreateQuery("update Document set name = :newName where name = :oldName").SetString("newName", "Foos").SetString( + ss.CreateQuery("update Document set Name = :newName where Name = :oldName").SetString("newName", "Foos").SetString( "oldName", "Blahs").ExecuteUpdate(); Assert.AreEqual(1, count, "hql-delete on stateless session"); - count = ss.CreateQuery("update Paper set color = :newColor").SetString("newColor", "Goldenrod").ExecuteUpdate(); + count = ss.CreateQuery("update Paper set Color = :newColor").SetString("newColor", "Goldenrod").ExecuteUpdate(); Assert.AreEqual(1, count, "hql-delete on stateless session"); tx.Commit(); @@ -118,6 +119,27 @@ } [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-06-05 04:39:26
|
Revision: 4412 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4412&view=rev Author: fabiomaulo Date: 2009-06-05 04:39:24 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Breaking Change for external framework The method GetSession() was removed (some user is thinking that it is for child-session where it was only to avoid downcast in NHSR) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -270,13 +270,6 @@ /// </summary> bool TransactionInProgress { get; } - /// <summary> - /// Allow to get the ISession instance without having to - /// down cast - /// </summary> - /// <returns></returns> - ISession GetSession(); - /// <summary> Retrieve the entity mode in effect for this session. </summary> EntityMode EntityMode { get; } Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -99,7 +99,6 @@ public abstract IList<T> ListCustomQuery<T>(ICustomQuery customQuery, QueryParameters queryParameters); public abstract object GetFilterParameterValue(string filterParameterName); public abstract IType GetFilterParameterType(string filterParameterName); - public abstract ISession GetSession(); public abstract IDictionary<string, IFilter> EnabledFilters { get; } public virtual IQuery GetNamedSQLQuery(string name) Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -2334,11 +2334,6 @@ return this; } - public override ISession GetSession() - { - return this; - } - public ISession GetSession(EntityMode entityMode) { using (new SessionIdLoggingContext(SessionId)) Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -924,12 +924,6 @@ #endregion - public override ISession GetSession() - { - // TODO: Verify the use of this method in NH.Search and remove it - throw new NotSupportedException(); - } - public override int ExecuteNativeUpdate(NativeSQLQuerySpecification nativeSQLQuerySpecification, QueryParameters queryParameters) { using (new SessionIdLoggingContext(SessionId)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-05 06:01:35
|
Revision: 4413 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4413&view=rev Author: fabiomaulo Date: 2009-06-05 06:01:33 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Fix NH-1617 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Order.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/User.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-06-05 04:39:24 UTC (rev 4412) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-06-05 06:01:33 UTC (rev 4413) @@ -129,6 +129,7 @@ RegisterKeyword("top"); RegisterKeyword("integer"); + RegisterKeyword("int"); DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.SqlClientDriver"; } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Fixture.cs 2009-06-05 06:01:33 UTC (rev 4413) @@ -0,0 +1,67 @@ +using System.Collections.Generic; +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1617 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2005Dialect; + } + + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + using (ITransaction tran = session.BeginTransaction()) + { + var newUser = new User(); + var newOrder1 = new Order(); + newOrder1.User = newUser; + newOrder1.Status = true; + var newOrder2 = new Order(); + newOrder2.User = newUser; + newOrder2.Status = true; + + session.Save(newUser); + session.Save(newOrder1); + session.Save(newOrder2); + tran.Commit(); + } + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + using (ITransaction tran = session.BeginTransaction()) + { + session.Delete("from Order"); + session.Delete("from User"); + tran.Commit(); + } + } + } + + [Test] + public void CanUseDataTypeInFormulaWithCriteriaQuery() + { + using (ISession session = OpenSession()) + { + using (ITransaction tran = session.BeginTransaction()) + { + string sql = "from User"; + IList<User> list = session.CreateQuery(sql).List<User>(); + Assert.That(list.Count, Is.EqualTo(1)); + Assert.That(list[0].OrderStatus, Is.EqualTo(2)); + } + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Mappings.hbm.xml 2009-06-05 06:01:33 UTC (rev 4413) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1617"> + + <class name="User" table="Users"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="OrderStatus" formula="CASE ISNULL((SELECT MIN(CONVERT(INT,ISNULL(o.Status,0))) FROM dbo.Orders o WHERE o.userid=id),-1) WHEN -1 THEN 0 WHEN 0 THEN 1 ELSE 2 END" /> + </class> + + <class name="Order" table="Orders"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Status" /> + <many-to-one name="User" class="User" column="UserID" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Order.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Order.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/Order.cs 2009-06-05 06:01:33 UTC (rev 4413) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH1617 +{ + public class Order + { + public virtual int Id { get; set; } + public virtual bool Status { get; set; } + public virtual User User { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/User.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/User.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1617/User.cs 2009-06-05 06:01:33 UTC (rev 4413) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.NHSpecificTest.NH1617 +{ + public class User + { + public virtual int Id { get; set; } + public virtual int OrderStatus { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 04:39:24 UTC (rev 4412) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 06:01:33 UTC (rev 4413) @@ -405,6 +405,9 @@ <Compile Include="NHSpecificTest\NH1391\SivasKangal.cs" /> <Compile Include="NHSpecificTest\NH1393\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1393\Person.cs" /> + <Compile Include="NHSpecificTest\NH1617\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1617\Order.cs" /> + <Compile Include="NHSpecificTest\NH1617\User.cs" /> <Compile Include="NHSpecificTest\NH1635\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1635\ForumMessage.cs" /> <Compile Include="NHSpecificTest\NH1635\ForumThread.cs" /> @@ -1874,6 +1877,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1617\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1810\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1092\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1507\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-06-05 14:08:19
|
Revision: 4414 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4414&view=rev Author: fabiomaulo Date: 2009-06-05 13:50:25 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Fix NH-1601 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture1.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture2.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Project.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Scenario.cs Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs 2009-06-05 06:01:33 UTC (rev 4413) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs 2009-06-05 13:50:25 UTC (rev 4414) @@ -93,6 +93,12 @@ EvictCachedCollections(persister, id, source.Factory); + // NH Different behavior : NH-1601 + // At this point the entity need the real refresh, all elementes of collections are Refreshed, + // the collection state was evicted, but the PersistentCollection (in the entity state) + // is associated with a possible previous session. + new WrapVisitor(source).Process(obj, persister); + string previousFetchProfile = source.FetchProfile; source.FetchProfile = "refresh"; object result = persister.Load(id, obj, @event.LockMode, source); Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture1.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture1.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture1.cs 2009-06-05 13:50:25 UTC (rev 4414) @@ -0,0 +1,137 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1601 +{ + [TestFixture] + public class Fixture1 : BugTestCase + { + /// <summary> + /// Loads the project do not call Count on the list assigned. + /// </summary> + [Test] + public void TestSaveAndLoadWithoutCount() + { + ProjectWithOneList.TestAccessToList = false; + SaveAndLoadProjectWithOneList(); + } + + /// <summary> + /// Refreshes the project do not call Count on the list assigned. + /// </summary> + [Test] + public void TestRefreshWithoutCount() + { + ProjectWithOneList.TestAccessToList = false; + SaveLoadAndRefreshProjectWithOneList(); + } + + /// <summary> + /// Loads the project and when Scenario1 is assigned call Count on the list. + /// </summary> + [Test] + public void TestSaveAndLoadWithCount() + { + ProjectWithOneList.TestAccessToList = true; + SaveAndLoadProjectWithOneList(); + } + + /// <summary> + /// Refreshes the project and when Scenario1 is assigned call Count on the list. + /// </summary> + [Test] + public void TestRefreshWithCount() + { + ProjectWithOneList.TestAccessToList = true; + SaveLoadAndRefreshProjectWithOneList(); + } + + /// <summary> + /// Create and save a Project + /// </summary> + public void SaveAndLoadProjectWithOneList() + { + SaveProject(); + LoadProject(); + } + + /// <summary> + /// Create, save and refresh projects + /// </summary> + public void SaveLoadAndRefreshProjectWithOneList() + { + SaveProject(); + ProjectWithOneList project = LoadProject(); + RefreshProject(project); + } + + public ProjectWithOneList SaveProject( ) + { + ProjectWithOneList project; + + using( ISession session = OpenSession( ) ) + using( ITransaction tx = session.BeginTransaction( ) ) + { + //Create a project scenario + project = new ProjectWithOneList(); + Scenario scenario = new Scenario( ); + + //Add the scenario to both lists + project.ScenarioList1.Add(scenario); + + //Set the primary key on the project + project.Name = "Test"; + + //Save the created project + session.Save( project ); + + tx.Commit( ); + } + return project; + } + + + public ProjectWithOneList LoadProject() + { + ProjectWithOneList project; + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + //The project is loaded and Scenario1, Scenario2 and Scenario3 properties can be set + //This will succeed regardless of whether the scenario list is accessed during the set + project = session.Get<ProjectWithOneList>("Test"); + + //Commit the transaction and cloase the session + tx.Commit(); + } + return project; + } + + public void RefreshProject(ProjectWithOneList project) + { + + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + //The project is refreshed and Scenario1, Scenario2 and Scenario3 properties can be set + //This will succeed when the scenario list is set and accessed during the set but only for + //Scenario 2 and Scenario3. It will fail if the scenario list is accessed during the set for Scenario1 + session.Refresh(project); + } + } + + protected override void OnTearDown( ) + { + base.OnTearDown( ); + using( ISession session = OpenSession( ) ) + { + using( ITransaction tx = session.BeginTransaction( ) ) + { + session.Delete(" from ProjectWithOneList"); + session.Delete( "from Scenario" ); + tx.Commit( ); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture2.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture2.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Fixture2.cs 2009-06-05 13:50:25 UTC (rev 4414) @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1601 +{ + [TestFixture] + public class Fixture2 : BugTestCase + { + /// <summary> + /// Loads the project and when Scenario2 and Scenario3 are set calls Count on the list assigned. + /// </summary> + [Test] + public void TestSaveAndLoadWithTwoCounts() + { + Project.TestAccessToList = false; + SaveAndLoadProject(); + } + + /// <summary> + /// Refreshes the project and when Scenario2 and Scenario3 are set calls Count on the list assigned. + /// </summary> + [Test] + public void TestRefreshWithTwoCounts() + { + Project.TestAccessToList = false; + SaveLoadAndRefreshProject(); + } + + /// <summary> + /// Loads the project and when Scenario1, Scenario2 and Scenario3 are set calls Count on the list assigned. + /// </summary> + [Test] + public void TestTestSaveAndLoadWithThreeCounts() + { + Project.TestAccessToList = true; + SaveAndLoadProject(); + } + + /// <summary> + /// Refreshes the project and when Scenario1, Scenario2 and Scenario3 are set calls Count on the list assigned. + /// Throws an exception on calling Count on Scenario1. + /// </summary> + [Test] + public void TestRefreshWithThreeCounts() + { + Project.TestAccessToList = true; + SaveLoadAndRefreshProject(); + } + + + /// <summary> + /// Create and save a Project + /// </summary> + public void SaveAndLoadProject() + { + SaveProject(); + LoadProject(); + } + + /// <summary> + /// Create, save and refresh projects + /// </summary> + public void SaveLoadAndRefreshProject() + { + SaveProject(); + Project project = LoadProject(); + RefreshProject(project); + } + + + public Project SaveProject( ) + { + Project project; + + using( ISession session = OpenSession( ) ) + using( ITransaction tx = session.BeginTransaction( ) ) + { + //Create a project scenario + project = new Project( ); + Scenario scenario1 = new Scenario( ); + Scenario scenario2 = new Scenario(); + Scenario scenario3 = new Scenario(); + + + //Add the scenario to all lists + project.ScenarioList1.Add(scenario1); + project.ScenarioList2.Add(scenario2); + project.ScenarioList3.Add(scenario3); + + + //Set the primary key on the project + project.Name = "Test"; + + //Save the created project + session.Save( project ); + + tx.Commit( ); + } + return project; + } + + + public Project LoadProject() + { + Project project; + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + //The project is loaded and Scenario1, Scenario2 and Scenario3 properties can be set + //This will succeed regardless of whether the scenario list is accessed during the set + project = session.Get<Project>("Test"); + + //Commit the transaction and cloase the session + tx.Commit(); + } + return project; + } + + public void RefreshProject(Project project) + { + + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + //The project is refreshed and Scenario1, Scenario2 and Scenario3 properties can be set + //This will succeed when the scenario list is set and accessed during the set but only for + //Scenario 2 and Scenario3. It will fail if the scenario list is accessed during the set for Scenario1 + session.Refresh(project); + } + } + + protected override void OnTearDown( ) + { + base.OnTearDown( ); + using( ISession session = OpenSession( ) ) + { + using( ITransaction tx = session.BeginTransaction( ) ) + { + session.Delete( "from Project" ); + session.Delete( "from Scenario" ); + tx.Commit( ); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Mappings.hbm.xml 2009-06-05 13:50:25 UTC (rev 4414) @@ -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.NH1601" + default-lazy="false"> + + <class name="Project" table="Project" lazy="false"> + <id name="Name" type="string"> + <column name="id"/> + <generator class="assigned" /> + </id> + + <!--First mapped list fails on refresh when setter accesses list--> + <list name="ScenarioList1" cascade="all" lazy="false"> + <key column="ScenarioList1ID"/> + <index column ="ScenarioList1Index"/> + <one-to-many class="Scenario"/> + </list> + <!--Subsequent mapped lists succeed on refresh when setter accesses list--> + <list name="ScenarioList2" cascade="all" lazy="false"> + <key column="ScenarioList2ID"/> + <index column ="ScenarioList2Index"/> + <one-to-many class="Scenario"/> + </list> + <list name="ScenarioList3" cascade="all" lazy="false"> + <key column="ScenarioList3ID"/> + <index column ="ScenarioList3Index"/> + <one-to-many class="Scenario"/> + </list> + </class> + + <class name="ProjectWithOneList" table="ProjectWithOneList" lazy="false"> + <id name="Name" type="string"> + <column name="id"/> + <generator class="assigned" /> + </id> + + <!-- First mapped list fails on refresh when setter accesses list --> + <list name="ScenarioList1" cascade="all" lazy="false"> + <key column="ScenarioListPWOLID"/> + <index column ="ScenarioListPWOLIndex"/> + <one-to-many class="Scenario"/> + </list> + + </class> + + <class name="Scenario" table="Scenario" lazy="false"> + <id type="Int32" name="id"> + <column name="ScenarioID"/> + <generator class="increment" /> + </id> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Project.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Project.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Project.cs 2009-06-05 13:50:25 UTC (rev 4414) @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + + +namespace NHibernate.Test.NHSpecificTest.NH1601 +{ + public class Project + { + public static bool TestAccessToList = false; + + /// <summary> + /// NHibernate sets this property on load and refresh. It fails in refresh if + /// the value is accessed during the set. This occurs on this list because it is + /// mapped first in the XML mapping. + /// </summary> + public IList<Scenario> ScenarioList1 + { + get { return scenarioList1; } + set { + scenarioList1 = value; + if (TestAccessToList) + { int i = scenarioList1.Count;} + } + } + + public IList<Scenario> ScenarioList2 + { + get { return scenarioList2; } + set { scenarioList2 = value; + int i = scenarioList2.Count; + } + } + + public IList<Scenario> ScenarioList3 + { + get { return scenarioList3; } + set + { + scenarioList3 = value; + int i = scenarioList3.Count; + } + } + + public Project( ) + { + } + + private string name; + + public string Name + { + get { return name; } + set { name = value;} + } + + private IList<Scenario> scenarioList1 = new List<Scenario>(); + private IList<Scenario> scenarioList2 = new List<Scenario>(); + private IList<Scenario> scenarioList3 = new List<Scenario>(); + + + } + public class ProjectWithOneList + { + public static bool TestAccessToList = false; + + /// <summary> + /// NHibernate sets this property on load and refresh. It fails in refresh if + /// the value is accessed during the set. This occurs on this list because it is + /// mapped first in the XML mapping. + /// </summary> + public IList<Scenario> ScenarioList1 + { + get { return scenarioList1; } + set + { + scenarioList1 = value; + if (TestAccessToList) + { int i = scenarioList1.Count; } + } + } + + public ProjectWithOneList() + { + } + + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + + private IList<Scenario> scenarioList1 = new List<Scenario>(); + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Scenario.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Scenario.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1601/Scenario.cs 2009-06-05 13:50:25 UTC (rev 4414) @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1601 +{ + + public class Scenario + { + + protected int _id; + + + public virtual int id + { + get { return _id; } + set { _id = value; } + } + + + public Scenario( ) + { + } + + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 06:01:33 UTC (rev 4413) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 13:50:25 UTC (rev 4414) @@ -405,6 +405,10 @@ <Compile Include="NHSpecificTest\NH1391\SivasKangal.cs" /> <Compile Include="NHSpecificTest\NH1393\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1393\Person.cs" /> + <Compile Include="NHSpecificTest\NH1601\Fixture1.cs" /> + <Compile Include="NHSpecificTest\NH1601\Fixture2.cs" /> + <Compile Include="NHSpecificTest\NH1601\Project.cs" /> + <Compile Include="NHSpecificTest\NH1601\Scenario.cs" /> <Compile Include="NHSpecificTest\NH1617\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1617\Order.cs" /> <Compile Include="NHSpecificTest\NH1617\User.cs" /> @@ -1877,6 +1881,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1601\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1617\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1810\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1092\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-06-05 18:10:39
|
Revision: 4416 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4416&view=rev Author: fabiomaulo Date: 2009-06-05 18:10:33 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Fix NH-1813 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-06-05 17:05:23 UTC (rev 4415) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-06-05 18:10:33 UTC (rev 4416) @@ -2632,7 +2632,7 @@ var exceptionContext = new AdoExceptionContextInfo { SqlException = sqle, - Message = "could not insert: " + MessageHelper.InfoString(this), + Message = "could not insert: " + MessageHelper.InfoString(this, id), Sql = sql.ToString(), EntityName = EntityName, EntityId = id Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs 2009-06-05 17:05:23 UTC (rev 4415) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs 2009-06-05 18:10:33 UTC (rev 4416) @@ -29,5 +29,10 @@ { get { return parameterTypes; } } + + public override string ToString() + { + return Text != null ? Text.ToString().Trim(): GetType().FullName; + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs 2009-06-05 18:10:33 UTC (rev 4416) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.NHSpecificTest.NH1813 +{ + public class EntityWithUnique + { + public int Id { get; set; } + public string Description { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs 2009-06-05 18:10:33 UTC (rev 4416) @@ -0,0 +1,66 @@ +using NHibernate.Cfg; +using NHibernate.Exceptions; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1813 +{ + [TestFixture] + public class Fixture: BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.BatchSize, "0"); + } + + [Test] + public void ContainSQLInInsert() + { + using (ISession s = OpenSession()) + using(ITransaction t = s .BeginTransaction()) + { + s.Save(new EntityWithUnique {Id = 1, Description = "algo"}); + t.Commit(); + } + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new EntityWithUnique { Id = 2, Description = "algo" }); + var exception = Assert.Throws<GenericADOException>(t.Commit); + Assert.That(exception.Message, Text.Contains("INSERT"), "should contain SQL"); + Assert.That(exception.Message, Text.Contains("#2"), "should contain id"); + } + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithUnique").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void ContainSQLInUpdate() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new EntityWithUnique { Id = 1, Description = "algo" }); + s.Save(new EntityWithUnique { Id = 2, Description = "mas" }); + t.Commit(); + } + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var e = s.Get<EntityWithUnique>(2); + e.Description = "algo"; + var exception = Assert.Throws<GenericADOException>(t.Commit); + Assert.That(exception.Message, Text.Contains("UPDATE"), "should contain SQL"); + } + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithUnique").ExecuteUpdate(); + t.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml 2009-06-05 18:10:33 UTC (rev 4416) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1813" + assembly="NHibernate.Test" + default-lazy="false"> + <class name="EntityWithUnique"> + <id name="Id"/> + <property name="Description" unique-key="ewu_description"/> + </class> +</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-06-05 17:05:23 UTC (rev 4415) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 18:10:33 UTC (rev 4416) @@ -488,6 +488,8 @@ <Compile Include="NHSpecificTest\NH1810\Parent.cs" /> <Compile Include="NHSpecificTest\NH1812\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1812\Model.cs" /> + <Compile Include="NHSpecificTest\NH1813\EntityWithUnique.cs" /> + <Compile Include="NHSpecificTest\NH1813\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1883,6 +1885,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1813\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1812\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1601\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1617\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-06-05 21:28:43
|
Revision: 4420 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4420&view=rev Author: fabiomaulo Date: 2009-06-05 21:27:54 +0000 (Fri, 05 Jun 2009) Log Message: ----------- - Fix NH-1171 - Minor refactoring for wrong method name Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/EngineTest/ParameterParserFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-06-05 20:15:26 UTC (rev 4419) +++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -158,7 +158,7 @@ private static ParameterMetadata BuildParameterMetadata(IParameterTranslations parameterTranslations, string hql) { long start = DateTime.Now.Ticks; - ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations(hql); + ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(hql); long end = DateTime.Now.Ticks; if (log.IsDebugEnabled) { Modified: trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs 2009-06-05 20:15:26 UTC (rev 4419) +++ trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -19,9 +19,9 @@ /// </summary> /// <param name="query">The query to be parsed for parameter locations. </param> /// <returns> The generated recognizer, with journaled location info. </returns> - public static ParamLocationRecognizer parseLocations(string query) + public static ParamLocationRecognizer ParseLocations(string query) { - ParamLocationRecognizer recognizer = new ParamLocationRecognizer(); + var recognizer = new ParamLocationRecognizer(); ParameterParser.Parse(query, recognizer); return recognizer; } Modified: trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-06-05 20:15:26 UTC (rev 4419) +++ trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -12,6 +12,8 @@ /// </summary> public class ParameterParser { + private static readonly int NewLineLength = Environment.NewLine.Length; + public interface IRecognizer { void OutParameter(int position); @@ -47,8 +49,30 @@ int stringLength = sqlString.Length; bool inQuote = false; + bool afterNewLine = false; for (int indx = 0; indx < stringLength; indx++) { + // check comments + if (indx + 1 < stringLength && sqlString.Substring(indx,2) == "/*") + { + var closeCommentIdx = sqlString.IndexOf("*/"); + indx = closeCommentIdx + 1; + continue; + } + if (afterNewLine && (indx + 1 < stringLength) && sqlString.Substring(indx, 2) == "--") + { + var closeCommentIdx = sqlString.IndexOf(Environment.NewLine, indx + 2); + indx = closeCommentIdx + NewLineLength - 1; + continue; + } + if (indx + NewLineLength -1 < stringLength && sqlString.Substring(indx, NewLineLength) == Environment.NewLine) + { + afterNewLine = true; + indx += NewLineLength - 1; + continue; + } + afterNewLine = false; + char c = sqlString[indx]; if (inQuote) { Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-06-05 20:15:26 UTC (rev 4419) +++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -125,7 +125,7 @@ private ParameterMetadata BuildNativeSQLParameterMetadata(string sqlString) { - ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations(sqlString); + ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(sqlString); OrdinalParameterDescriptor[] ordinalDescriptors = new OrdinalParameterDescriptor[recognizer.OrdinalParameterLocationList.Count]; for (int i = 0; i < recognizer.OrdinalParameterLocationList.Count; i++) Added: trunk/nhibernate/src/NHibernate.Test/EngineTest/ParameterParserFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/EngineTest/ParameterParserFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/EngineTest/ParameterParserFixture.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -0,0 +1,63 @@ +using NHibernate.Engine.Query; +using NUnit.Framework; + +namespace NHibernate.Test.EngineTest +{ + [TestFixture] + public class ParameterParserFixture + { + [Test] + public void CanFindParameterAfterComment() + { + string query = + @" +SELECT id +FROM tablea +/* Comment with ' number 2 */ +WHERE Name = :name +ORDER BY Name"; + + var recognizer = new ParamLocationRecognizer(); + ParameterParser.Parse(query, recognizer); + ParamLocationRecognizer.NamedParameterDescription p; + Assert.DoesNotThrow(() => p = recognizer.NamedParameterDescriptionMap["name"]); + } + + [Test] + public void CanFindParameterAfterInlineComment() + { + string query = + @" +SELECT id +FROM tablea +-- Comment with ' number 1 +WHERE Name = :name +ORDER BY Name"; + + var recognizer = new ParamLocationRecognizer(); + ParameterParser.Parse(query, recognizer); + ParamLocationRecognizer.NamedParameterDescription p; + Assert.DoesNotThrow(() => p = recognizer.NamedParameterDescriptionMap["name"]); + } + + [Test] + public void CanFindParameterAfterAnyComment() + { + string query = + @" +SELECT id +FROM tablea +-- Comment with ' number 1 +WHERE Name = :name +/* Comment with ' number 2 */ +ORDER BY Name + :pizza"; + + var recognizer = new ParamLocationRecognizer(); + ParameterParser.Parse(query, recognizer); + ParamLocationRecognizer.NamedParameterDescription p; + Assert.DoesNotThrow(() => p = recognizer.NamedParameterDescriptionMap["name"]); + Assert.DoesNotThrow(() => p = recognizer.NamedParameterDescriptionMap["pizza"]); + } + + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Domain.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.NHSpecificTest.NH1171 +{ + public class ClassA + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs 2009-06-05 21:27:54 UTC (rev 4420) @@ -0,0 +1,28 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1171 +{ + [TestFixture] + public class Fixture: BugTestCase + { + [Test] + public void SupportSQLQueryWithComments() + { + string sql = + @" +SELECT id +FROM tablea +-- Comment with ' number 1 +WHERE Name = :name +/* Comment with ' number 2 */ +ORDER BY Name +"; + using (ISession s = OpenSession()) + { + var q =s.CreateSQLQuery(sql); + q.SetString("name", "Evgeny Potashnik"); + q.List(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Mappings.hbm.xml 2009-06-05 21:27:54 UTC (rev 4420) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1171" + assembly="NHibernate.Test"> + + <class name="ClassA" table="tablea"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Name"/> + </class> +</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-06-05 20:15:26 UTC (rev 4419) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 21:27:54 UTC (rev 4420) @@ -177,6 +177,7 @@ <Compile Include="DynamicEntity\Tuplizer\MyEntityTuplizer.cs" /> <Compile Include="DynamicEntity\Tuplizer\TuplizerDynamicEntity.cs" /> <Compile Include="EngineTest\NativeSqlQueryReturnTest.cs" /> + <Compile Include="EngineTest\ParameterParserFixture.cs" /> <Compile Include="EngineTest\TypedValueFixture.cs" /> <Compile Include="EntityModeTest\Map\Basic\DynamicClassFixture.cs" /> <Compile Include="EntityModeTest\Multi\MultiRepresentationFixture.cs" /> @@ -360,6 +361,8 @@ <Compile Include="NHSpecificTest\NH1159\ContactTitle.cs" /> <Compile Include="NHSpecificTest\NH1159\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1159\HibernateInterceptor.cs" /> + <Compile Include="NHSpecificTest\NH1171\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1171\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1264\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1264\Name.cs" /> <Compile Include="NHSpecificTest\NH1264\Passenger.cs" /> @@ -1889,6 +1892,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1171\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1400\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1444\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1813\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-06-06 20:16:57
|
Revision: 4423 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4423&view=rev Author: fabiomaulo Date: 2009-06-06 20:16:42 +0000 (Sat, 06 Jun 2009) Log Message: ----------- - Fix NH-1814 (by default) - Fix NH-188 (so far explicitly or trough configuration) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs trunk/nhibernate/src/NHibernate/Cfg/Settings.cs trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs trunk/nhibernate/src/NHibernate/Dialect/Schema/IDataBaseSchema.cs trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd trunk/nhibernate/src/NHibernate.Test/App.config trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaMetadataUpdater.cs trunk/nhibernate/src/NHibernate.Test/CfgTest/SettingsFactoryFixture.cs trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.cs trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -135,9 +135,9 @@ // The classname of the HQL query parser factory public const string QueryTranslator = "query.factory_class"; - // Unused, not implemented public const string QueryImports = "query.imports"; public const string Hbm2ddlAuto = "hbm2ddl.auto"; + public const string Hbm2ddlKeyWords = "hbm2ddl.keywords"; // Unused, not implemented public const string SqlExceptionConverter = "sql_exception_converter"; Modified: trunk/nhibernate/src/NHibernate/Cfg/Settings.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Settings.cs 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/Cfg/Settings.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -59,6 +59,10 @@ public bool IsAutoValidateSchema { get; internal set; } + public bool IsAutoQuoteEnabled { get; internal set; } + + public bool IsKeywordsImportEnabled { get; internal set; } + public bool IsQueryCacheEnabled { get; internal set; } public bool IsStructuredCacheEntriesEnabled { get; internal set; } Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -140,6 +140,7 @@ log.Info("Query language substitutions: " + CollectionPrinter.ToString((IDictionary) querySubstitutions)); } + #region Hbm2DDL string autoSchemaExport = PropertiesHelper.GetString(Environment.Hbm2ddlAuto, properties, null); if ("update" == autoSchemaExport) { @@ -158,6 +159,29 @@ { settings.IsAutoValidateSchema = true; } + + string autoKeyWordsImport = PropertiesHelper.GetString(Environment.Hbm2ddlKeyWords, properties, "not-defined"); + switch (autoKeyWordsImport.ToLowerInvariant()) + { + case "none": + settings.IsKeywordsImportEnabled = false; + settings.IsAutoQuoteEnabled = false; + break; + case "keywords": + settings.IsKeywordsImportEnabled = true; + break; + case "auto-quote": + settings.IsKeywordsImportEnabled = true; + settings.IsAutoQuoteEnabled = true; + break; + case "not-defined": + settings.IsKeywordsImportEnabled = true; + settings.IsAutoQuoteEnabled = false; + break; + } + + #endregion + bool useSecondLevelCache = PropertiesHelper.GetBoolean(Environment.UseSecondLevelCache, properties, true); bool useQueryCache = PropertiesHelper.GetBoolean(Environment.UseQueryCache, properties); @@ -305,11 +329,6 @@ } } - internal SettingsFactory() - { - //should not be publically creatable - } - private static ConnectionReleaseMode ParseConnectionReleaseMode(string name) { switch (name) Modified: trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -1,5 +1,6 @@ using System.Data; using System.Data.Common; +using Iesi.Collections.Generic; namespace NHibernate.Dialect.Schema { @@ -90,6 +91,17 @@ return connection.GetSchema(ForeignKeysSchemaName, restrictions); } + public virtual ISet<string> GetReservedWords() + { + var result = new HashedSet<string>(); + DataTable dtReservedWords = connection.GetSchema(DbMetaDataCollectionNames.ReservedWords); + foreach (DataRow row in dtReservedWords.Rows) + { + result.Add(row["ReservedWord"].ToString()); + } + return result; + } + protected virtual string ForeignKeysSchemaName { get { return "ForeignKeys"; } Modified: trunk/nhibernate/src/NHibernate/Dialect/Schema/IDataBaseSchema.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Schema/IDataBaseSchema.cs 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/Dialect/Schema/IDataBaseSchema.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -1,4 +1,5 @@ using System.Data; +using Iesi.Collections.Generic; namespace NHibernate.Dialect.Schema { @@ -115,5 +116,11 @@ /// <param name="table">A table name</param> /// <returns>A description of the foreign keys available</returns> DataTable GetForeignKeys(string catalog, string schema, string table); + + /// <summary> + /// Get all reserved words + /// </summary> + /// <returns>A set of reserved words</returns> + ISet<string> GetReservedWords(); } } Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -162,6 +162,22 @@ log.Debug("instantiating session factory with properties: " + CollectionPrinter.ToString(properties)); } + try + { + if (settings.IsKeywordsImportEnabled) + { + SchemaMetadataUpdater.Update(this); + } + if (settings.IsAutoQuoteEnabled) + { + SchemaMetadataUpdater.QuoteTableAndColumns(cfg); + } + } + catch (NotSupportedException) + { + // Ignore if the Dialect does not provide DataBaseSchema + } + #region Caches settings.CacheProvider.Start(properties); #endregion Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-06 20:16:42 UTC (rev 4423) @@ -600,6 +600,7 @@ <Compile Include="Param\VersionTypeSeedParameterSpecification.cs" /> <Compile Include="Proxy\AbstractProxyFactory.cs" /> <Compile Include="SqlCommand\InsertSelect.cs" /> + <Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" /> <Compile Include="Transaction\AdoNetWithDistrubtedTransactionFactory.cs" /> <Compile Include="Transform\ToListResultTransformer.cs" /> <Compile Include="Util\NullableDictionary.cs" /> Added: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaMetadataUpdater.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaMetadataUpdater.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaMetadataUpdater.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -0,0 +1,79 @@ +using Iesi.Collections.Generic; +using NHibernate.Cfg; +using NHibernate.Engine; +using NHibernate.Mapping; +using System.Collections.Generic; + +namespace NHibernate.Tool.hbm2ddl +{ + // Candidate to be exstensions of ISessionFactory and Configuration + public static class SchemaMetadataUpdater + { + public static void Update(ISessionFactory sessionFactory) + { + var factory = (ISessionFactoryImplementor) sessionFactory; + var dialect = factory.Dialect; + var connectionHelper = new SuppliedConnectionProviderConnectionHelper(factory.ConnectionProvider); + factory.Dialect.Keywords.AddAll(GetReservedWords(dialect, connectionHelper)); + } + + public static void QuoteTableAndColumns(Configuration configuration) + { + ISet<string> reservedDb = GetReservedWords(configuration.Properties); + foreach (var cm in configuration.ClassMappings) + { + QuoteTable(cm.Table, reservedDb); + } + foreach (var cm in configuration.CollectionMappings) + { + QuoteTable(cm.Table, reservedDb); + } + } + + private static ISet<string> GetReservedWords(IDictionary<string, string> cfgProperties) + { + var dialect = Dialect.Dialect.GetDialect(cfgProperties); + var connectionHelper = new ManagedProviderConnectionHelper(cfgProperties); + return GetReservedWords(dialect, connectionHelper); + } + + private static ISet<string> GetReservedWords(Dialect.Dialect dialect, IConnectionHelper connectionHelper) + { + ISet<string> reservedDb = new HashedSet<string>(); + connectionHelper.Prepare(); + try + { + var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection); + foreach (var rw in metaData.GetReservedWords()) + { + reservedDb.Add(rw.ToLowerInvariant()); + } + } + finally + { + connectionHelper.Release(); + } + return reservedDb; + } + + private static void QuoteTable(Table table, ICollection<string> reservedDb) + { + if (!table.IsQuoted && reservedDb.Contains(table.Name.ToLowerInvariant())) + { + table.Name = GetNhQuoted(table.Name); + } + foreach (var column in table.ColumnIterator) + { + if (!column.IsQuoted && reservedDb.Contains(column.Name.ToLowerInvariant())) + { + column.Name = GetNhQuoted(column.Name); + } + } + } + + private static string GetNhQuoted(string name) + { + return "`" + name + "`"; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd 2009-06-06 20:16:42 UTC (rev 4423) @@ -84,6 +84,7 @@ <xs:enumeration value="query.factory_class" /> <xs:enumeration value="query.imports" /> <xs:enumeration value="hbm2ddl.auto" /> + <xs:enumeration value="hbm2ddl.keywords" /> <xs:enumeration value="sql_exception_converter" /> <xs:enumeration value="adonet.wrap_result_sets" /> <xs:enumeration value="prepare_sql" /> Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-06-06 20:16:42 UTC (rev 4423) @@ -54,6 +54,7 @@ --> <property name="adonet.batch_size">10</property> <property name="connection.isolation">ReadCommitted</property> + <property name="hbm2ddl.keywords">none</property> <property name="format_sql">true</property> <!-- This is the System.Data.dll provider for MSSQL Server --> Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/SettingsFactoryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CfgTest/SettingsFactoryFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CfgTest/SettingsFactoryFixture.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.CfgTest +{ + [TestFixture] + public class SettingsFactoryFixture + { + [Test] + public void DefaultValueForKeyWords() + { + var properties = new Dictionary<string, string> + { + {"dialect", typeof (Dialect.MsSql2005Dialect).FullName} + }; + var settings = new SettingsFactory().BuildSettings(properties); + Assert.That(settings.IsKeywordsImportEnabled); + Assert.That(!settings.IsAutoQuoteEnabled); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 22:49:48 UTC (rev 4422) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-06 20:16:42 UTC (rev 4423) @@ -110,6 +110,7 @@ <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> + <Compile Include="CfgTest\SettingsFactoryFixture.cs" /> <Compile Include="Classic\EntityWithLifecycle.cs" /> <Compile Include="Classic\LifecycleFixture.cs" /> <Compile Include="Classic\ValidatableFixture.cs" /> @@ -1157,6 +1158,8 @@ <Compile Include="Stateless\StatelessWithRelationsFixture.cs" /> <Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.cs" /> <Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTagFixture.cs" /> + <Compile Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.cs" /> + <Compile Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\SchemaMetadataUpdaterFixture.cs" /> <Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" /> <Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" /> <Compile Include="SecondLevelCacheTest\AnotherItem.cs" /> @@ -1894,6 +1897,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1182\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1171\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1400\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -0,0 +1,11 @@ +namespace NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest +{ + public class Order + { + public string Select { get; set; } + public string From { get; set; } + public string And { get; set; } + public string Column { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/HeavyEntity.hbm.xml 2009-06-06 20:16:42 UTC (rev 4423) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest" + assembly="NHibernate.Test" + default-lazy="false"> + + <class name="Order"> + <id type="int"> + <generator class="native"/> + </id> + <property name="Select"/> + <property name="From"/> + <property name="And"/> + <property name="Column"/> + <property name="Name"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs 2009-06-06 20:16:42 UTC (rev 4423) @@ -0,0 +1,169 @@ +using System.Collections.Generic; +using Iesi.Collections.Generic; +using NHibernate.Cfg; +using NHibernate.Engine; +using NHibernate.Mapping; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; + +namespace NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest +{ + [TestFixture] + public class SchemaMetadataUpdaterFixture + { + [Test] + public void CanRetrieveReservedWords() + { + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + var dialect = Dialect.Dialect.GetDialect(configuration.Properties); + var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties); + connectionHelper.Prepare(); + try + { + var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection); + var reserved = metaData.GetReservedWords(); + Assert.That(reserved, Is.Not.Empty); + Assert.That(reserved, Has.Member("SELECT")); + Assert.That(reserved, Has.Member("FROM")); + } + finally + { + connectionHelper.Release(); + } + } + + [Test] + public void UpdateReservedWordsInDialect() + { + var reservedDb = new HashedSet<string>(); + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + var dialect = Dialect.Dialect.GetDialect(configuration.Properties); + var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties); + connectionHelper.Prepare(); + try + { + var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection); + foreach (var rw in metaData.GetReservedWords()) + { + reservedDb.Add(rw.ToLowerInvariant()); + } + } + finally + { + connectionHelper.Release(); + } + + var sf = (ISessionFactoryImplementor) configuration.BuildSessionFactory(); + SchemaMetadataUpdater.Update(sf); + var match = reservedDb.Intersect(sf.Dialect.Keywords); + Assert.That(match, Is.EquivalentTo(reservedDb)); + } + + [Test] + public void ExplicitAutoQuote() + { + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml", + GetType().Assembly); + + SchemaMetadataUpdater.QuoteTableAndColumns(configuration); + + var cm = configuration.GetClassMapping(typeof(Order)); + Assert.That(cm.Table.IsQuoted); + var culs = new List<Column>(cm.Table.ColumnIterator); + Assert.That(GetColumnByName(culs, "From").IsQuoted); + Assert.That(GetColumnByName(culs, "And").IsQuoted); + Assert.That(GetColumnByName(culs, "Select").IsQuoted); + Assert.That(GetColumnByName(culs, "Column").IsQuoted); + Assert.That(!GetColumnByName(culs, "Name").IsQuoted); + } + + [Test] + public void AutoQuoteTableAndColumnsAtStratup() + { + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml", + GetType().Assembly); + configuration.BuildSessionFactory(); + var cm = configuration.GetClassMapping(typeof (Order)); + Assert.That(cm.Table.IsQuoted); + var culs = new List<Column>(cm.Table.ColumnIterator); + Assert.That(GetColumnByName(culs, "From").IsQuoted); + Assert.That(GetColumnByName(culs, "And").IsQuoted); + Assert.That(GetColumnByName(culs, "Select").IsQuoted); + Assert.That(GetColumnByName(culs, "Column").IsQuoted); + Assert.That(!GetColumnByName(culs, "Name").IsQuoted); + } + + [Test] + public void AutoQuoteTableAndColumnsAtStratupIncludeKeyWordsImport() + { + var reservedDb = new HashedSet<string>(); + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + var dialect = Dialect.Dialect.GetDialect(configuration.Properties); + var connectionHelper = new ManagedProviderConnectionHelper(configuration.Properties); + connectionHelper.Prepare(); + try + { + var metaData = dialect.GetDataBaseSchema(connectionHelper.Connection); + foreach (var rw in metaData.GetReservedWords()) + { + reservedDb.Add(rw.ToLowerInvariant()); + } + } + finally + { + connectionHelper.Release(); + } + + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml", + GetType().Assembly); + var sf = (ISessionFactoryImplementor)configuration.BuildSessionFactory(); + var match = reservedDb.Intersect(sf.Dialect.Keywords); + Assert.That(match, Is.EquivalentTo(reservedDb)); + } + + private static Column GetColumnByName(IEnumerable<Column> culs, string colName) + { + Column result= null; + foreach (var column in culs) + { + if (column.Name.Equals(colName)) + { + result = column; + break; + } + } + return result; + } + + [Test] + public void CanWorkWithAutoQuoteTableAndColumnsAtStratup() + { + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + configuration.SetProperty(Environment.Hbm2ddlAuto, "create-drop"); + configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml", + GetType().Assembly); + var sf = configuration.BuildSessionFactory(); + using (ISession s = sf.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Order {From = "from", Column = "column", And = "order"}); + t.Commit(); + } + + using (ISession s = sf.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete("from Order"); + t.Commit(); + } + + new SchemaExport(configuration).Drop(false, false); + } + + } +} \ 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: <fab...@us...> - 2009-06-07 23:03:20
|
Revision: 4428 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4428&view=rev Author: fabiomaulo Date: 2009-06-07 23:03:14 +0000 (Sun, 07 Jun 2009) Log Message: ----------- Fix NH-1817 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/TypeParameters/DefinedTypeForIdFixture.cs trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.cs trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-06-07 14:58:43 UTC (rev 4427) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-06-07 23:03:14 UTC (rev 4428) @@ -98,8 +98,22 @@ if (idSchema.generator.@class == null) throw new MappingException("no class given for generator"); - id.IdentifierGeneratorStrategy = idSchema.generator.@class; - id.IdentifierGeneratorProperties = GetGeneratorProperties(idSchema, id); + // NH Differen behavior : specific feature NH-1817 + TypeDef typeDef = mappings.GetTypeDef(idSchema.generator.@class); + if (typeDef != null) + { + id.IdentifierGeneratorStrategy = typeDef.TypeClass; + // parameters on the property mapping should override parameters in the typedef + var allParameters = new Dictionary<string, string>(typeDef.Parameters); + ArrayHelper.AddAll(allParameters, GetGeneratorProperties(idSchema, id)); + + id.IdentifierGeneratorProperties = allParameters; + } + else + { + id.IdentifierGeneratorStrategy = idSchema.generator.@class; + id.IdentifierGeneratorProperties = GetGeneratorProperties(idSchema, id); + } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-07 14:58:43 UTC (rev 4427) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-07 23:03:14 UTC (rev 4428) @@ -1234,6 +1234,8 @@ <Compile Include="TransformTests\AliasToBeanResultTransformerFixture.cs" /> <Compile Include="TransformTests\Simple.cs" /> <Compile Include="TypeParameters\DefaultValueIntegerType.cs" /> + <Compile Include="TypeParameters\DefinedTypeForIdFixture.cs" /> + <Compile Include="TypeParameters\EntityCustomId.cs" /> <Compile Include="TypeParameters\TypeParameterTest.cs" /> <Compile Include="TypeParameters\Widget.cs" /> <Compile Include="TypesTest\BinaryBlobClass.cs" /> @@ -1897,6 +1899,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="TypeParameters\EntityCustomId.hbm.xml" /> <EmbeddedResource Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1182\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1171\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/TypeParameters/DefinedTypeForIdFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypeParameters/DefinedTypeForIdFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypeParameters/DefinedTypeForIdFixture.cs 2009-06-07 23:03:14 UTC (rev 4428) @@ -0,0 +1,56 @@ +using System.Collections; +using NHibernate.Mapping; +using NUnit.Framework; + +namespace NHibernate.Test.TypeParameters +{ + [TestFixture] + public class DefinedTypeForIdFixture : TestCase + { + protected override IList Mappings + { + get { return new[] { "TypeParameters.EntityCustomId.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + [Test] + public void HasParametrizedId() + { + var pc = cfg.GetClassMapping(typeof(EntityCustomId)); + var idMap = (SimpleValue)pc.IdentifierProperty.Value; + Assert.That(idMap.IdentifierGeneratorStrategy, Is.EqualTo("NHibernate.Id.TableHiLoGenerator, NHibernate")); + Assert.That(idMap.IdentifierGeneratorProperties["max_lo"], Is.EqualTo("99")); + } + + [Test] + [Description("Ensure the parametrized generator is working.")] + public void Save() + { + object savedId1; + object savedId2; + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + savedId1 = s.Save(new EntityCustomId()); + savedId2 = s.Save(new EntityCustomId()); + t.Commit(); + } + + Assert.That(savedId1, Is.LessThan(200), "should be work with custo parameters"); + Assert.That(savedId1, Is.GreaterThan(99)); + Assert.That(savedId2, Is.EqualTo((int)savedId1 + 1)); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityCustomId").ExecuteUpdate(); + t.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.cs 2009-06-07 23:03:14 UTC (rev 4428) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.TypeParameters +{ + public class EntityCustomId + { + public int Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypeParameters/EntityCustomId.hbm.xml 2009-06-07 23:03:14 UTC (rev 4428) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.TypeParameters" + default-lazy='false'> + + <typedef name="HighLow" class="NHibernate.Id.TableHiLoGenerator, NHibernate"> + <param name="max_lo">99</param> + </typedef> + + <class name="EntityCustomId"> + <id name="Id"> + <generator class="HighLow"/> + </id> + <property name="Name"/> + </class> +</hibernate-mapping> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-09 22:06:40
|
Revision: 4436 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4436&view=rev Author: fabiomaulo Date: 2009-06-09 22:05:38 +0000 (Tue, 09 Jun 2009) Log Message: ----------- First step to have injectable ICollectionTypeFactory Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-09 19:26:22 UTC (rev 4435) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-09 22:05:38 UTC (rev 4436) @@ -603,6 +603,8 @@ <Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" /> <Compile Include="Transaction\AdoNetWithDistrubtedTransactionFactory.cs" /> <Compile Include="Transform\ToListResultTransformer.cs" /> + <Compile Include="Type\CollectionTypeFactory.cs" /> + <Compile Include="Type\ICollectionTypeFactory.cs" /> <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> Added: trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs 2009-06-09 22:05:38 UTC (rev 4436) @@ -0,0 +1,103 @@ +using System.Collections; +using System.Collections.Generic; + +namespace NHibernate.Type +{ + public class CollectionTypeFactory : ICollectionTypeFactory + { + public virtual CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) + { + return new ArrayType(role, propertyRef, elementClass, embedded); + } + + public virtual CollectionType Bag(string role, string propertyRef, bool embedded) + { + return new BagType(role, propertyRef, embedded); + } + + public virtual CollectionType Bag<T>(string role, string propertyRef, bool embedded) + { + return new GenericBagType<T>(role, propertyRef); + } + + public virtual CollectionType List(string role, string propertyRef, bool embedded) + { + return new ListType(role, propertyRef, embedded); + } + + public virtual CollectionType List<T>(string role, string propertyRef, bool embedded) + { + return new GenericListType<T>(role, propertyRef); + } + + public virtual CollectionType IdBag(string role, string propertyRef, bool embedded) + { + return new IdentifierBagType(role, propertyRef, embedded); + } + + public virtual CollectionType IdBag<T>(string role, string propertyRef, bool embedded) + { + return new GenericIdentifierBagType<T>(role, propertyRef); + } + + public virtual CollectionType Set(string role, string propertyRef, bool embedded) + { + return new SetType(role, propertyRef, embedded); + } + + public virtual CollectionType OrderedSet(string role, string propertyRef, bool embedded) + { + return new OrderedSetType(role, propertyRef, embedded); + } + + public virtual CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer) + { + return new SortedSetType(role, propertyRef, comparer, embedded); + } + + public virtual CollectionType Set<T>(string role, string propertyRef, bool embedded) + { + return new GenericSetType<T>(role, propertyRef); + } + + public virtual CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer) + { + return new GenericSortedSetType<T>(role, propertyRef, comparer); + } + + public virtual CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded) + { + return new GenericOrderedSetType<T>(role, propertyRef); + } + + public virtual CollectionType Map(string role, string propertyRef, bool embedded) + { + return new MapType(role, propertyRef, embedded); + } + + public virtual CollectionType OrderedMap(string role, string propertyRef, bool embedded) + { + return new OrderedMapType(role, propertyRef, embedded); + } + + public virtual CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer) + { + return new SortedMapType(role, propertyRef, comparer, embedded); + } + + public virtual CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded) + { + return new GenericMapType<TKey, TValue>(role, propertyRef); + } + + public virtual CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer) + { + return new GenericSortedDictionaryType<TKey, TValue>(role, propertyRef, comparer); + } + + public virtual CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer) + { + return new GenericSortedListType<TKey, TValue>(role, propertyRef, comparer); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs 2009-06-09 22:05:38 UTC (rev 4436) @@ -0,0 +1,248 @@ +using System.Collections; +using System.Collections.Generic; +namespace NHibernate.Type +{ + /// <summary> + /// Type factory for collections types. + /// </summary> + public interface ICollectionTypeFactory + { + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="System.Array"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="elementClass">The <see cref="System.Type"/> to use to create the array.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// An <see cref="ArrayType"/> for the specified role. + /// </returns> + CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> + /// with bag semantics. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="BagType"/> for the specified role. + /// </returns> + CollectionType Bag(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the owner object containing the collection ID, + /// or <see langword="null" /> if it is the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="GenericBagType{T}"/> for the specified role. + /// </returns> + CollectionType Bag<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="ListType"/> for the specified role. + /// </returns> + CollectionType List(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IList<T>"/> with list + /// semantics. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="ListType"/> for the specified role. + /// </returns> + CollectionType List<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> + /// with id-bag semantics. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="IdentifierBagType"/> for the specified role. + /// </returns> + CollectionType IdBag(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IList{T}"/> with identifier + /// bag semantics. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="GenericIdentifierBagType{T}"/> for the specified role. + /// </returns> + CollectionType IdBag<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="SetType"/> for the specified role. + /// </returns> + CollectionType Set(string role, string propertyRef, bool embedded); + + CollectionType OrderedSet(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/> + /// that is sorted by an <see cref="IComparer"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="SortedSetType"/> for the specified role. + /// </returns> + CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + CollectionType Set<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for a sorted <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <param name="comparer">The <see cref="System.Collections.Generic.IComparer{T}" /> to use for the set.</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the owner object containing the collection ID, + /// or <see langword="null" /> if it is the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="MapType"/> for the specified role. + /// </returns> + CollectionType Map(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> + /// that maintains insertion order of elements. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="OrderedMapType"/> for the specified role. + /// </returns> + CollectionType OrderedMap(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> + /// that is sorted by an <see cref="IComparer"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="SortedMapType"/> for the specified role. + /// </returns> + CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/>. + /// </summary> + /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam> + /// <typeparam name="TValue">The type of values in the dictionary.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.< + /// /param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="MapType"/> for the specified role. + /// </returns> + CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded); + + + CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer); + CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-09 19:26:22 UTC (rev 4435) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-09 22:05:38 UTC (rev 4436) @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.Reflection; using NHibernate.Classic; using NHibernate.Engine; using NHibernate.Intercept; @@ -36,6 +37,9 @@ private static readonly char[] precisionScaleSplit = new char[] { '(', ')', ',' }; private static readonly char[] lengthSplit = new char[] { '(', ')' }; + private static readonly ICollectionTypeFactory collectionTypeFactory; + private static readonly System.Type[] GenericCollectionSimpleSignature = new[] { typeof(string), typeof(string), typeof(bool) }; + /* * Maps the string representation of the type to the IType. The string * representation is how the type will appear in the mapping file and in @@ -92,6 +96,10 @@ /// <summary></summary> static TypeFactory() { + collectionTypeFactory = + (ICollectionTypeFactory) + Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(typeof (CollectionTypeFactory)); + //basicTypes.Add(NHibernate.Blob.Name, NHibernate.Blob); //basicTypes.Add(NHibernate.Clob.Name, NHibernate.Clob); @@ -646,346 +654,134 @@ return new ManyToOneType(persistentClass, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML, ignoreNotFound); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="System.Array"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementClass">The <see cref="System.Type"/> to use to create the array.</param> - /// <param name="embedded"></param> - /// <returns> - /// An <see cref="ArrayType"/> for the specified role. - /// </returns> public static CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) { - return new ArrayType(role, propertyRef, elementClass, embedded); + return collectionTypeFactory.Array(role, propertyRef, embedded, elementClass); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="ListType"/> for the specified role. - /// </returns> public static CollectionType List(string role, string propertyRef, bool embedded) { - return new ListType(role, propertyRef, embedded); + return collectionTypeFactory.List(role, propertyRef, embedded); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> - /// with bag semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="BagType"/> for the specified role. - /// </returns> public static CollectionType Bag(string role, string propertyRef, bool embedded) { - return new BagType(role, propertyRef, embedded); + return collectionTypeFactory.Bag(role, propertyRef, embedded); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> - /// with id-bag semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="IdentifierBagType"/> for the specified role. - /// </returns> public static CollectionType IdBag(string role, string propertyRef, bool embedded) { - return new IdentifierBagType(role, propertyRef, embedded); + return collectionTypeFactory.IdBag(role, propertyRef, embedded); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="MapType"/> for the specified role. - /// </returns> public static CollectionType Map(string role, string propertyRef, bool embedded) { - return new MapType(role, propertyRef, embedded); + return collectionTypeFactory.Map(role, propertyRef, embedded); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="SetType"/> for the specified role. - /// </returns> public static CollectionType Set(string role, string propertyRef, bool embedded) { - return new SetType(role, propertyRef, embedded); + return collectionTypeFactory.Set(role, propertyRef, embedded); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> - /// that is sorted by an <see cref="IComparer"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="SortedMapType"/> for the specified role. - /// </returns> public static CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer) { - return new SortedMapType(role, propertyRef, comparer, embedded); + return collectionTypeFactory.SortedMap(role, propertyRef, embedded, comparer); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> - /// that maintains insertion order of elements. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="OrderedMapType"/> for the specified role. - /// </returns> public static CollectionType OrderedMap(string role, string propertyRef, bool embedded) { - return new OrderedMapType(role, propertyRef, embedded); + return collectionTypeFactory.OrderedMap(role, propertyRef, embedded); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/> - /// that is sorted by an <see cref="IComparer"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> - /// <param name="embedded"></param> - /// <returns> - /// A <see cref="SortedSetType"/> for the specified role. - /// </returns> public static CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer) { - return new SortedSetType(role, propertyRef, comparer, embedded); + return collectionTypeFactory.SortedSet(role, propertyRef, embedded, comparer); } public static CollectionType OrderedSet(string role, string propertyRef, bool embedded) { - return new OrderedSetType(role, propertyRef, embedded); + return collectionTypeFactory.OrderedSet(role, propertyRef, embedded); } - - - private static CollectionType CreateCollectionType( - System.Type genericCollectionType, - string role, - string propertyRef, - params System.Type[] typeArguments) + public static CollectionType GenericBag(string role, string propertyRef, System.Type elementClass) { - return - (CollectionType) - Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance( - genericCollectionType.MakeGenericType(typeArguments), role, propertyRef); - } + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("Bag", new[] {elementClass}, + GenericCollectionSimpleSignature); - private static CollectionType CreateSortedCollectionType( - System.Type genericCollectionType, - string role, - string propertyRef, - object comparer, - params System.Type[] typeArguments) - { - return - (CollectionType) - Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance( - genericCollectionType.MakeGenericType(typeArguments), role, propertyRef, comparer); + return (CollectionType) mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); } - private static CollectionType CreateOrderedCollectionType(System.Type genericCollectionType, - string role, - string propertyRef, - params System.Type[] typeArguments) + public static CollectionType GenericIdBag(string role, string propertyRef, System.Type elementClass) { - return - (CollectionType) - Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance( - genericCollectionType.MakeGenericType(typeArguments), role, propertyRef); - } + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("IdBag", new[] { elementClass }, + GenericCollectionSimpleSignature); - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementClass"> - /// The <see cref="System.Type"/> to use to create the - /// <see cref="System.Collections.Generic.IList{T}"/> with. - /// </param> - /// <returns> - /// A <see cref="GenericBagType{T}"/> for the specified role. - /// </returns> - public static CollectionType GenericBag(string role, string propertyRef, System.Type elementClass) - { - return CreateCollectionType(typeof(GenericBagType<>), role, propertyRef, elementClass); + return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IList{T}"/> with identifier - /// bag semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementClass"> - /// The <see cref="System.Type"/> to use to create the - /// <see cref="System.Collections.Generic.IList{T}"/> with. - /// </param> - /// <returns> - /// A <see cref="GenericIdentifierBagType{T}"/> for the specified role. - /// </returns> - public static CollectionType GenericIdBag(string role, string propertyRef, System.Type elementClass) - { - return CreateCollectionType(typeof(GenericIdentifierBagType<>), role, propertyRef, elementClass); - } - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IList<T>"/> with list - /// semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementClass"> - /// The <see cref="System.Type"/> to use to create the - /// <see cref="System.Collections.Generic.IList<T>"/> with. - /// </param> - /// <returns> - /// A <see cref="ListType"/> for the specified role. - /// </returns> public static CollectionType GenericList(string role, string propertyRef, System.Type elementClass) { - return CreateCollectionType(typeof(GenericListType<>), role, propertyRef, elementClass); + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("List", new[] { elementClass }, + GenericCollectionSimpleSignature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="indexClass"> - /// The <see cref="System.Type"/> to use as the <c>TKey</c> to create the - /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/> with. - /// </param> - /// <param name="elementClass"> - /// The <see cref="System.Type"/> to use as the <c>TValue</c> to create the - /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/> with. - /// </param> - /// <returns> - /// A <see cref="MapType"/> for the specified role. - /// </returns> public static CollectionType GenericMap(string role, string propertyRef, System.Type indexClass, System.Type elementClass) { - return CreateCollectionType(typeof(GenericMapType<,>), role, propertyRef, indexClass, elementClass); + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("Map", new[] {indexClass, elementClass }, + GenericCollectionSimpleSignature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); } public static CollectionType GenericSortedList(string role, string propertyRef, object comparer, System.Type indexClass, System.Type elementClass) { - return - CreateSortedCollectionType(typeof(GenericSortedListType<,>), role, propertyRef, comparer, indexClass, elementClass); + var signature = new[] { typeof(string), typeof(string), typeof(bool), typeof(IComparer<>).MakeGenericType(indexClass) }; + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("SortedList", new[] { indexClass, elementClass }, + signature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new[] { role, propertyRef, false, comparer }); } public static CollectionType GenericSortedDictionary(string role, string propertyRef, object comparer, System.Type indexClass, System.Type elementClass) { - return - CreateSortedCollectionType(typeof(GenericSortedDictionaryType<,>), role, propertyRef, comparer, indexClass, - elementClass); + var signature = new[] { typeof(string), typeof(string), typeof(bool), typeof(IComparer<>).MakeGenericType(indexClass) }; + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("SortedDictionary", new[] { indexClass, elementClass }, + signature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new[] { role, propertyRef, false, comparer }); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.Generic.ISet{T}" />. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementClass">The type of the set elements.</param> - /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> public static CollectionType GenericSet(string role, string propertyRef, System.Type elementClass) { - return CreateCollectionType(typeof(GenericSetType<>), role, propertyRef, elementClass); + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("Set", new[] { elementClass }, + GenericCollectionSimpleSignature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for a sorted <see cref="Iesi.Collections.Generic.ISet{T}" />. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="comparer">The <see cref="System.Collections.Generic.IComparer{T}" /> to use for the set.</param> - /// <param name="elementType">The type of the elements in the set.</param> - /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> public static CollectionType GenericSortedSet(string role, string propertyRef, object comparer, - System.Type elementType) + System.Type elementClass) { - return CreateSortedCollectionType(typeof(GenericSortedSetType<>), role, propertyRef, comparer, elementType); + var signature = new[] { typeof(string), typeof(string), typeof(bool), typeof(IComparer<>).MakeGenericType(elementClass) }; + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("SortedSet", new[] { elementClass }, + signature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new[] { role, propertyRef, false, comparer }); } - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementType">The type of the elements in the set.</param> - /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> public static CollectionType GenericOrderedSet(string role, string propertyRef, - System.Type elementType) + System.Type elementClass) { - return CreateOrderedCollectionType(typeof(GenericOrderedSetType<>), role, propertyRef, elementType); + MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("OrderedSet", new[] { elementClass }, + GenericCollectionSimpleSignature); + + return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); } /// <summary> Deep copy a series of values from one array to another... </summary> Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-09 19:26:22 UTC (rev 4435) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-09 22:05:38 UTC (rev 4436) @@ -563,5 +563,36 @@ return null; } + + public static MethodInfo GetGenericMethodFrom<T>(string methodName, System.Type[] genericArgs, System.Type[] signature) + { + MethodInfo result = null; + MethodInfo[] methods = typeof (T).GetMethods(); + foreach (var method in methods) + { + if (method.Name.Equals(methodName) && method.IsGenericMethod + && signature.Length == method.GetParameters().Length + && method.GetGenericArguments().Length == genericArgs.Length) + { + bool foundCandidate = true; + result = method.MakeGenericMethod(genericArgs); + + ParameterInfo[] ms = result.GetParameters(); + for (int i = 0; i < signature.Length; i++) + { + if (ms[i].ParameterType != signature[i]) + { + foundCandidate = false; + } + } + + if (foundCandidate) + { + return result; + } + } + } + return result; + } } } Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2009-06-09 19:26:22 UTC (rev 4435) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2009-06-09 22:05:38 UTC (rev 4436) @@ -3,6 +3,7 @@ using NHibernate.DomainModel; using NHibernate.Util; using NUnit.Framework; +using System.Collections.Generic; namespace NHibernate.Test.UtilityTest { @@ -140,8 +141,26 @@ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mddg), Is.Not.Null); Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdds), Is.Null); } + + [Test] + public void GetGenericMethodFrom() + { + var signature = new[] {typeof (string), typeof (string), typeof (bool)}; + Assert.That(ReflectHelper.GetGenericMethodFrom<ISomething>("List", new[] {typeof (BRhf)}, signature), Is.Not.Null); + Assert.That(ReflectHelper.GetGenericMethodFrom<ISomething>("List", new[] { typeof(int), typeof(string) }, signature), Is.Not.Null); + Assert.That(ReflectHelper.GetGenericMethodFrom<ISomething>("List", new[] { typeof(int), typeof(string) } + , new[] { typeof(string), typeof(string), typeof(bool), typeof(IComparer<>).MakeGenericType(typeof(int)) }), Is.Not.Null); + } } + public interface ISomething + { + int List(string role, string propertyRef, bool embedded); + int List<T>(string role, string propertyRef, bool embedded); + int List<TK, TV>(string role, string propertyRef, bool embedded); + int List<TK, TV>(string role, string propertyRef, bool embedded, IComparer<TK> comparer); + } + public class ARhf { public override bool Equals(object obj) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-06-10 04:45:38
|
Revision: 4440 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4440&view=rev Author: darioquintana Date: 2009-06-10 04:45:36 +0000 (Wed, 10 Jun 2009) Log Message: ----------- - fix for NH-1826 - bug fixed. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs 2009-06-10 03:08:30 UTC (rev 4439) +++ trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs 2009-06-10 04:45:36 UTC (rev 4440) @@ -62,7 +62,7 @@ RegisterFunction("current_timestamp", new NoArgSQLFunction("now", NHibernateUtil.DateTime, true)); RegisterFunction("str", new SQLFunctionTemplate(NHibernateUtil.String, "cast(?1 as varchar)")); RegisterFunction("locate", new PositionSubstringFunction()); - + RegisterFunction("iif", new SQLFunctionTemplate(null, "case when ?1 then ?2 else ?3 end")); DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.NpgsqlDriver"; } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs 2009-06-10 03:08:30 UTC (rev 4439) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs 2009-06-10 04:45:36 UTC (rev 4440) @@ -117,7 +117,8 @@ { // TODO: something much better - look at the type of the other expression! // TODO: Have comparisonExpression and/or arithmeticExpression rules complete the resolution of boolean nodes. - String replacement = _walker.TokenReplacements[constant.Text]; + string replacement; + _walker.TokenReplacements.TryGetValue(constant.Text, out replacement); if ( replacement != null ) { constant.Text = replacement; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-10 14:26:10
|
Revision: 4443 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4443&view=rev Author: fabiomaulo Date: 2009-06-10 14:25:57 +0000 (Wed, 10 Jun 2009) Log Message: ----------- Fix NH-1822 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs Modified: trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2009-06-10 05:30:11 UTC (rev 4442) +++ trunk/nhibernate/src/NHibernate/Util/TypeNameParser.cs 2009-06-10 14:25:57 UTC (rev 4443) @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text; +using System.Text.RegularExpressions; namespace NHibernate.Util { @@ -14,6 +15,8 @@ { private readonly string defaultNamespace; private readonly string defaultAssembly; + private static readonly Regex WhiteSpaces = new Regex(@"[\t\r\n]", RegexOptions.Compiled); + private static readonly Regex MultipleSpaces = new Regex(@"[ ]+", RegexOptions.Compiled); public TypeNameParser(string defaultNamespace, string defaultAssembly) { @@ -31,17 +34,18 @@ return new TypeNameParser(defaultNamespace, defaultAssembly).ParseTypeName(type); } - public AssemblyQualifiedTypeName ParseTypeName(string type) + public AssemblyQualifiedTypeName ParseTypeName(string typeName) { - if (type == null) + if (typeName == null) { - throw new ArgumentNullException("type"); + throw new ArgumentNullException("typeName"); } - if (type.Trim('[',']','\\', ',') == string.Empty) + var type = WhiteSpaces.Replace(typeName, " "); + type = MultipleSpaces.Replace(type, " ").Replace(", [", ",[").Replace("[ [", "[[").Replace("] ]", "]]"); + if (type.Trim(' ','[', ']', '\\', ',') == string.Empty) { - throw new ArgumentException(string.Format("The type to parse is not a type name:{0}", type), "type"); + throw new ArgumentException(string.Format("The type to parse is not a type name:{0}", typeName), "typeName"); } - int genericTypeArgsStartIdx = type.IndexOf('['); int genericTypeArgsEndIdx = type.LastIndexOf(']'); int genericTypeCardinalityIdx = -1; Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs 2009-06-10 05:30:11 UTC (rev 4442) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/TypeNameParserFixture.cs 2009-06-10 14:25:57 UTC (rev 4443) @@ -251,5 +251,19 @@ var a = TypeNameParser.Parse(typeName); Assert.AreEqual(typeName, a.ToString()); } + + [Test] + [Description("Parse with new lines")] + public void NH1822() + { + var typeName = + @"OldMutual.SalesGear.Data.ReferenceType`2[ + [OldMutual.SalesGear.Reference.Core.Channel, OldMutual.SalesGear.Reference.Core], + [OldMutual.SalesGear.Reference.Core.Channels, OldMutual.SalesGear.Reference.Core] + ], OldMutual.SalesGear.Data"; + var expected = "OldMutual.SalesGear.Data.ReferenceType`2[[OldMutual.SalesGear.Reference.Core.Channel, OldMutual.SalesGear.Reference.Core],[OldMutual.SalesGear.Reference.Core.Channels, OldMutual.SalesGear.Reference.Core]], OldMutual.SalesGear.Data"; + var a = TypeNameParser.Parse(typeName); + Assert.That(a.ToString(), Is.EqualTo(expected)); + } } } \ 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: <fab...@us...> - 2009-06-11 02:37:38
|
Revision: 4449 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4449&view=rev Author: fabiomaulo Date: 2009-06-11 02:37:36 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Fix NH-1830 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs 2009-06-10 23:27:21 UTC (rev 4448) +++ trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs 2009-06-11 02:37:36 UTC (rev 4449) @@ -71,7 +71,7 @@ public static AbstractCriterion Like(string propertyName, string value, MatchMode matchMode, char? escapeChar) { - return new LikeExpression(propertyName, value, escapeChar, false); + return new LikeExpression(propertyName, value, matchMode, escapeChar, false); } /// <summary> Added: trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs 2009-06-11 02:37:36 UTC (rev 4449) @@ -0,0 +1,18 @@ +using NHibernate.Criterion; +using NUnit.Framework; + +namespace NHibernate.Test.Criteria +{ + [TestFixture] + public class RestrictionsFixture + { + [Test] + public void LikeShouldContainsMatch() + { + ICriterion c = Restrictions.Like("Name", "n", MatchMode.Anywhere, null); + Assert.That(c, Is.InstanceOf<LikeExpression>()); + var likeExpression = (LikeExpression) c; + Assert.That(likeExpression.ToString(), Is.EqualTo("Name like %n%")); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-10 23:27:21 UTC (rev 4448) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-11 02:37:36 UTC (rev 4449) @@ -147,6 +147,7 @@ <Compile Include="Criteria\MaterialResource.cs" /> <Compile Include="Criteria\ProjectionsTest.cs" /> <Compile Include="Criteria\Reptile.cs" /> + <Compile Include="Criteria\RestrictionsFixture.cs" /> <Compile Include="Criteria\Student.cs" /> <Compile Include="Criteria\StudentDTO.cs" /> <Compile Include="DebugConnectionProvider.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-11 04:37:22
|
Revision: 4452 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4452&view=rev Author: fabiomaulo Date: 2009-06-11 04:36:17 +0000 (Thu, 11 Jun 2009) Log Message: ----------- - Fix NH-1821 - Fix unreported bug related with NH-1171 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Entity.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs 2009-06-11 03:04:00 UTC (rev 4451) +++ trunk/nhibernate/src/NHibernate/Engine/Query/ParamLocationRecognizer.cs 2009-06-11 04:36:17 UTC (rev 4452) @@ -74,6 +74,11 @@ // don't care... } + public void Other(string sqlPart) + { + // don't care... + } + private NamedParameterDescription GetOrBuildNamedParameterDescription(string name, bool jpa) { NamedParameterDescription desc; Modified: trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-06-11 03:04:00 UTC (rev 4451) +++ trunk/nhibernate/src/NHibernate/Engine/Query/ParameterParser.cs 2009-06-11 04:36:17 UTC (rev 4452) @@ -21,6 +21,7 @@ void NamedParameter(string name, int position); void JpaPositionalParameter(string name, int position); void Other(char character); + void Other(string sqlPart); } // Disallow instantiation @@ -56,12 +57,14 @@ if (indx + 1 < stringLength && sqlString.Substring(indx,2) == "/*") { var closeCommentIdx = sqlString.IndexOf("*/"); + recognizer.Other(sqlString.Substring(indx, (closeCommentIdx- indx)+2)); indx = closeCommentIdx + 1; continue; } if (afterNewLine && (indx + 1 < stringLength) && sqlString.Substring(indx, 2) == "--") { var closeCommentIdx = sqlString.IndexOf(Environment.NewLine, indx + 2); + recognizer.Other(sqlString.Substring(indx, closeCommentIdx - indx)); indx = closeCommentIdx + NewLineLength - 1; continue; } @@ -69,6 +72,7 @@ { afterNewLine = true; indx += NewLineLength - 1; + recognizer.Other(Environment.NewLine); continue; } afterNewLine = false; Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs 2009-06-11 03:04:00 UTC (rev 4451) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs 2009-06-11 04:36:17 UTC (rev 4452) @@ -26,7 +26,7 @@ private readonly Dictionary<string, object> namedParameters = new Dictionary<string, object>(); - private long aliasesFound = 0; + private long aliasesFound; public SQLQueryParser(string sqlQuery, IParserContext context) { @@ -283,6 +283,11 @@ result.Add(character.ToString()); } + public void Other(string sqlPart) + { + result.Add(sqlPart); + } + private void AddNamedParameter(string name) { int loc = parameterCount++; Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs 2009-06-11 03:04:00 UTC (rev 4451) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1171/Fixture.cs 2009-06-11 04:36:17 UTC (rev 4452) @@ -1,3 +1,4 @@ +using NHibernate.Cfg; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1171 @@ -5,6 +6,11 @@ [TestFixture] public class Fixture: BugTestCase { + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + configuration.SetProperty(Environment.FormatSql, "false"); + } + [Test] public void SupportSQLQueryWithComments() { @@ -24,5 +30,31 @@ q.List(); } } + + [Test] + public void ExecutedContainsComments() + { + string sql = + @" +SELECT id +FROM tablea +-- Comment with ' number 1 +WHERE Name = :name +/* Comment with ' number 2 */ +ORDER BY Name +"; + using (var ls = new SqlLogSpy()) + { + using (ISession s = OpenSession()) + { + var q = s.CreateSQLQuery(sql); + q.SetString("name", "Evgeny Potashnik"); + q.List(); + } + string message = ls.GetWholeLog(); + Assert.That(message, Text.Contains("-- Comment with ' number 1")); + Assert.That(message, Text.Contains("/* Comment with ' number 2 */")); + } + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Entity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Entity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Entity.cs 2009-06-11 04:36:17 UTC (rev 4452) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.NHSpecificTest.NH1821 +{ + public class Entity + { + public virtual int Id { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Fixture.cs 2009-06-11 04:36:17 UTC (rev 4452) @@ -0,0 +1,44 @@ +using System.Text.RegularExpressions; +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1821 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2005Dialect; + } + + [Test] + public void ShouldNotRemoveLineBreaksFromSqlQueries() + { + using (var spy = new SqlLogSpy()) + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + const string sql = @" +select Id +from Entity +where 1=1"; + var query = s.CreateSQLQuery(sql); + Assert.DoesNotThrow(() => query.List()); + + string renderedSql = spy.Appender.GetEvents()[0].RenderedMessage; + + Regex whitespaces = new Regex(@"\s+", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled); + + Assert.AreEqual( + string.Compare( + whitespaces.Replace(sql, " ").Trim(), + whitespaces.Replace(renderedSql, " ").Trim(), + true + ), + 0 + ); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1821/Mappings.hbm.xml 2009-06-11 04:36:17 UTC (rev 4452) @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1821" + assembly="NHibernate.Test"> + <class name="Entity" table="Entity"> + <id name="Id"/> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-11 03:04:00 UTC (rev 4451) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-11 04:36:17 UTC (rev 4452) @@ -501,6 +501,8 @@ <Compile Include="NHSpecificTest\NH1812\Model.cs" /> <Compile Include="NHSpecificTest\NH1813\EntityWithUnique.cs" /> <Compile Include="NHSpecificTest\NH1813\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1821\Entity.cs" /> + <Compile Include="NHSpecificTest\NH1821\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1900,6 +1902,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1821\Mappings.hbm.xml" /> <EmbeddedResource Include="TypeParameters\EntityCustomId.hbm.xml" /> <EmbeddedResource Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1182\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-06-11 07:00:51
|
Revision: 4453 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4453&view=rev Author: fabiomaulo Date: 2009-06-11 07:00:45 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Fix NH-1810 (thanks to Lee Henson for all his work around the issue) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs 2009-06-11 04:36:17 UTC (rev 4452) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentSet.cs 2009-06-11 07:00:45 UTC (rev 4453) @@ -13,6 +13,109 @@ namespace NHibernate.Collection { + internal interface ISetSnapshot<T>: ICollection<T>, ICollection + { + T this[T element]{ get;} + } + + [Serializable] + internal class SetSnapShot<T> : ISetSnapshot<T> + { + private readonly List<T> elements; + public SetSnapShot() + { + elements = new List<T>(); + } + + public SetSnapShot(int capacity) + { + elements = new List<T>(capacity); + } + + public SetSnapShot(IEnumerable<T> collection) + { + elements = new List<T>(collection); + } + + public IEnumerator<T> GetEnumerator() + { + return elements.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + elements.Add(item); + } + + public void Clear() + { + throw new InvalidOperationException(); + } + + public bool Contains(T item) + { + return elements.Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + elements.CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + throw new InvalidOperationException(); + } + + public void CopyTo(Array array, int index) + { + ((ICollection)elements).CopyTo(array, index); + } + + int ICollection.Count + { + get { return elements.Count; } + } + + public object SyncRoot + { + get { return ((ICollection)elements).SyncRoot; } + } + + public bool IsSynchronized + { + get { return ((ICollection)elements).IsSynchronized; } + } + + int ICollection<T>.Count + { + get { return elements.Count; } + } + + public bool IsReadOnly + { + get { return ((ICollection<T>)elements).IsReadOnly; } + } + + public T this[T element] + { + get + { + var idx = elements.IndexOf(element); + if(idx >=0) + { + return elements[idx]; + } + return default(T); + } + } + } + /// <summary> /// .NET has no design equivalent for Java's Set so we are going to use the /// Iesi.Collections library. This class is internal to NHibernate and shouldn't @@ -78,28 +181,30 @@ { EntityMode entityMode = Session.EntityMode; - //if (set==null) return new Set(session); - Hashtable clonedSet = new Hashtable(set.Count); + // NH Different behavior : for NH-1810 and the way is working the possible underlining collection + // the Snapshot is represented using a List<T> + // (perhaps it has less performance then IDictionary but it is working) + // TODO : should use ever underlining collection type or something to have same performace and same order + var clonedSet = new SetSnapShot<object>(set.Count); foreach (object current in set) { object copied = persister.ElementType.DeepCopy(current, entityMode, persister.Factory); - clonedSet[copied] = copied; + clonedSet.Add(copied); } return clonedSet; } public override ICollection GetOrphans(object snapshot, string entityName) { - IDictionary sn = (IDictionary) snapshot; - // NH Different implementation : sn.Keys return a new collection we don't need "re-new" - return GetOrphans(sn.Keys, set, entityName, Session); + var sn = new SetSnapShot<object>((IEnumerable<object>)snapshot); + return GetOrphans(sn, set, entityName, Session); } public override bool EqualsSnapshot(ICollectionPersister persister) { IType elementType = persister.ElementType; - IDictionary snapshot = (IDictionary) GetSnapshot(); - if (snapshot.Count != set.Count) + var snapshot = (ISetSnapshot<object>)GetSnapshot(); + if (((ICollection)snapshot).Count != set.Count) { return false; } @@ -118,7 +223,7 @@ public override bool IsSnapshotEmpty(object snapshot) { - return ((IDictionary) snapshot).Count == 0; + return ((ICollection)snapshot).Count == 0; } public override void BeforeInitialize(ICollectionPersister persister, int anticipatedSize) @@ -212,9 +317,9 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) { IType elementType = persister.ElementType; - IDictionary sn = (IDictionary) GetSnapshot(); - List<object> deletes = new List<object>(sn.Count); - foreach (object obj in sn.Keys) + var sn = (ISetSnapshot<object>)GetSnapshot(); + var deletes = new List<object>(((ICollection)sn).Count); + foreach (object obj in sn) { if (!set.Contains(obj)) { @@ -237,7 +342,7 @@ public override bool NeedsInserting(object entry, int i, IType elemType) { - IDictionary sn = (IDictionary) GetSnapshot(); + var sn = (ISetSnapshot<object>) GetSnapshot(); object oldKey = sn[entry]; // note that it might be better to iterate the snapshot but this is safe, // assuming the user implements equals() properly, as required by the PersistentSet Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs 2009-06-11 04:36:17 UTC (rev 4452) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs 2009-06-11 07:00:45 UTC (rev 4453) @@ -4,7 +4,7 @@ namespace NHibernate.Test.NHSpecificTest.NH1810 { - [TestFixture, Ignore("To investigate.")] + [TestFixture] public class Fixture : BugTestCase { // The problem is the same using a default sort="natural" collection for Children This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-11 17:49:00
|
Revision: 4455 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4455&view=rev Author: fabiomaulo Date: 2009-06-11 17:48:51 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Fix NH-1833 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs 2009-06-11 14:30:32 UTC (rev 4454) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs 2009-06-11 17:48:51 UTC (rev 4455) @@ -193,25 +193,33 @@ private string DetermineIntegerRepresentation(string text, int type) { + // prevent the fisrt-exception as possible + var literalValue = text; + bool hasLongSpec = literalValue.EndsWith("l") || literalValue.EndsWith("L"); + if (hasLongSpec) + { + literalValue = literalValue.Substring(0, literalValue.Length - 1); + } try { - if (type == HqlSqlWalker.NUM_INT) + if (type == HqlSqlWalker.NUM_INT && literalValue.Length <= 10 || hasLongSpec) { try { - return int.Parse(text).ToString(); + return int.Parse(literalValue).ToString(); } catch (FormatException) { - log.Info("could not format incoming text [" + text + "] as a NUM_INT; assuming numeric overflow and attempting as NUM_LONG"); + log.Info("could not format incoming text [" + text + + "] as a NUM_INT; assuming numeric overflow and attempting as NUM_LONG"); } + catch (OverflowException) + { + log.Info("could not format incoming text [" + text + + "] as a NUM_INT; assuming numeric overflow and attempting as NUM_LONG"); + } } - String literalValue = text; - if (literalValue.EndsWith("l") || literalValue.EndsWith("L")) - { - literalValue = literalValue.Substring(0, literalValue.Length - 1); - } return long.Parse(literalValue).ToString(); } catch (Exception t) Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2009-06-11 14:30:32 UTC (rev 4454) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2009-06-11 17:48:51 UTC (rev 4455) @@ -117,5 +117,19 @@ s.Transaction.Commit(); } } + + [Test] + public void CanParseMaxLong() + { + // NH-1833 + using (ISession s = OpenSession()) + { + s.CreateQuery(string.Format("from SimpleClass sc where sc.LongValue = {0}", long.MaxValue)).List(); + s.CreateQuery(string.Format("from SimpleClass sc where sc.LongValue = {0}L", long.MaxValue)).List(); + s.CreateQuery(string.Format("from SimpleClass sc where sc.LongValue = 123L")).List(); + s.CreateQuery(string.Format("from SimpleClass sc where sc.LongValue = 123")).List(); + s.CreateQuery(string.Format("from SimpleClass sc where sc.LongValue = {0}", int.MaxValue + 1L)).List(); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs 2009-06-11 14:30:32 UTC (rev 4454) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.cs 2009-06-11 17:48:51 UTC (rev 4455) @@ -3,5 +3,7 @@ public class SimpleClass { public virtual string Description { get; set; } + public virtual long LongValue { get; set; } + public virtual int IntValue { get; set; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml 2009-06-11 14:30:32 UTC (rev 4454) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/SimpleClass.hbm.xml 2009-06-11 17:48:51 UTC (rev 4455) @@ -8,5 +8,7 @@ <generator class="native" /> </id> <property name="Description"/> + <property name="LongValue"/> + <property name="IntValue"/> </class> </hibernate-mapping> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-11 21:49:58
|
Revision: 4457 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4457&view=rev Author: fabiomaulo Date: 2009-06-11 21:49:52 +0000 (Thu, 11 Jun 2009) Log Message: ----------- One more step for injectable ICollectionTypeFactory Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -8,6 +8,7 @@ { private readonly IObjectsFactory objectsFactory = new ActivatorObjectsFactory(); protected System.Type proxyFactoryFactory; + private ICollectionTypeFactory collectionTypeFactory; #region IBytecodeProvider Members @@ -38,6 +39,34 @@ get { return objectsFactory; } } + public ICollectionTypeFactory CollectionTypeFactory + { + get + { + if (collectionTypeFactory == null) + { + try + { + collectionTypeFactory = + (ICollectionTypeFactory) ObjectsFactory.CreateInstance(typeof (Type.DefaultCollectionTypeFactory)); + } + catch (Exception e) + { + throw new HibernateByteCodeException("Failed to create an instance of CollectionTypeFactory!", e); + } + } + return collectionTypeFactory; + } + protected set + { + if(value == null) + { + throw new InvalidOperationException("The CollectionTypeFactory can't be null."); + } + collectionTypeFactory = value; + } + } + #endregion #region IInjectableProxyFactoryFactory Members Modified: trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/Bytecode/IBytecodeProvider.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -20,8 +20,19 @@ /// <returns>The reflection optimization delegate.</returns> IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters); + /// <summary> + /// NHibernate's object instaciator. + /// </summary> + /// <remarks> + /// For entities <see cref="IReflectionOptimizer"/> and its implementations. + /// </remarks> IObjectsFactory ObjectsFactory { get; } + /// <summary> + /// Instanciator of NHibernate's collections default types. + /// </summary> + ICollectionTypeFactory CollectionTypeFactory { get; } + // <summary> Generate a ClassTransformer capable of performing bytecode manipulation. </summary> // <param name="classFilter"> // filter used to limit which classes are to be instrumented via this ClassTransformer. Copied: trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs (from rev 4455, trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Bytecode/ICollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -0,0 +1,250 @@ +using System.Collections; +using System.Collections.Generic; +using NHibernate.Type; + +namespace NHibernate.Bytecode +{ + /// <summary> + /// Type factory for collections types. + /// </summary> + public interface ICollectionTypeFactory + { + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="System.Array"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="elementClass">The <see cref="System.Type"/> to use to create the array.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// An <see cref="ArrayType"/> for the specified role. + /// </returns> + CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> + /// with bag semantics. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="BagType"/> for the specified role. + /// </returns> + CollectionType Bag(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the owner object containing the collection ID, + /// or <see langword="null" /> if it is the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="GenericBagType{T}"/> for the specified role. + /// </returns> + CollectionType Bag<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="ListType"/> for the specified role. + /// </returns> + CollectionType List(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IList<T>"/> with list + /// semantics. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="ListType"/> for the specified role. + /// </returns> + CollectionType List<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> + /// with id-bag semantics. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="IdentifierBagType"/> for the specified role. + /// </returns> + CollectionType IdBag(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IList{T}"/> with identifier + /// bag semantics. + /// </summary> + /// <typeparam name="T">The type of elements in the list.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="GenericIdentifierBagType{T}"/> for the specified role. + /// </returns> + CollectionType IdBag<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="SetType"/> for the specified role. + /// </returns> + CollectionType Set(string role, string propertyRef, bool embedded); + + CollectionType OrderedSet(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/> + /// that is sorted by an <see cref="IComparer"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="SortedSetType"/> for the specified role. + /// </returns> + CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + CollectionType Set<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for a sorted <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <param name="comparer">The <see cref="System.Collections.Generic.IComparer{T}" /> to use for the set.</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <typeparam name="T">The type of elements in the collection.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the owner object containing the collection ID, + /// or <see langword="null" /> if it is the primary key. + /// </param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef"> + /// The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="MapType"/> for the specified role. + /// </returns> + CollectionType Map(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> + /// that maintains insertion order of elements. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="OrderedMapType"/> for the specified role. + /// </returns> + CollectionType OrderedMap(string role, string propertyRef, bool embedded); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> + /// that is sorted by an <see cref="IComparer"/>. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="SortedMapType"/> for the specified role. + /// </returns> + CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer); + + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an + /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/>. + /// </summary> + /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam> + /// <typeparam name="TValue">The type of values in the dictionary.</typeparam> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.< + /// /param> + /// <param name="embedded">Is embedded in XML (not supported yet)</param> + /// <returns> + /// A <see cref="MapType"/> for the specified role. + /// </returns> + CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded); + + + CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer); + CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/Bytecode/IObjectsFactory.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -1,5 +1,8 @@ namespace NHibernate.Bytecode { + /// <summary> + /// Interface for instanciate all NHibernate objects. + /// </summary> public interface IObjectsFactory { /// <summary> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-06-11 21:49:52 UTC (rev 4457) @@ -603,8 +603,8 @@ <Compile Include="Tool\hbm2ddl\SchemaMetadataUpdater.cs" /> <Compile Include="Transaction\AdoNetWithDistrubtedTransactionFactory.cs" /> <Compile Include="Transform\ToListResultTransformer.cs" /> - <Compile Include="Type\CollectionTypeFactory.cs" /> - <Compile Include="Type\ICollectionTypeFactory.cs" /> + <Compile Include="Type\DefaultCollectionTypeFactory.cs" /> + <Compile Include="Bytecode\ICollectionTypeFactory.cs" /> <Compile Include="Util\NullableDictionary.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\PathHelper.cs" /> <Compile Include="Hql\Ast\ANTLR\Util\SyntheticAndFactory.cs" /> Deleted: trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -1,103 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace NHibernate.Type -{ - public class CollectionTypeFactory : ICollectionTypeFactory - { - public virtual CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) - { - return new ArrayType(role, propertyRef, elementClass, embedded); - } - - public virtual CollectionType Bag(string role, string propertyRef, bool embedded) - { - return new BagType(role, propertyRef, embedded); - } - - public virtual CollectionType Bag<T>(string role, string propertyRef, bool embedded) - { - return new GenericBagType<T>(role, propertyRef); - } - - public virtual CollectionType List(string role, string propertyRef, bool embedded) - { - return new ListType(role, propertyRef, embedded); - } - - public virtual CollectionType List<T>(string role, string propertyRef, bool embedded) - { - return new GenericListType<T>(role, propertyRef); - } - - public virtual CollectionType IdBag(string role, string propertyRef, bool embedded) - { - return new IdentifierBagType(role, propertyRef, embedded); - } - - public virtual CollectionType IdBag<T>(string role, string propertyRef, bool embedded) - { - return new GenericIdentifierBagType<T>(role, propertyRef); - } - - public virtual CollectionType Set(string role, string propertyRef, bool embedded) - { - return new SetType(role, propertyRef, embedded); - } - - public virtual CollectionType OrderedSet(string role, string propertyRef, bool embedded) - { - return new OrderedSetType(role, propertyRef, embedded); - } - - public virtual CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer) - { - return new SortedSetType(role, propertyRef, comparer, embedded); - } - - public virtual CollectionType Set<T>(string role, string propertyRef, bool embedded) - { - return new GenericSetType<T>(role, propertyRef); - } - - public virtual CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer) - { - return new GenericSortedSetType<T>(role, propertyRef, comparer); - } - - public virtual CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded) - { - return new GenericOrderedSetType<T>(role, propertyRef); - } - - public virtual CollectionType Map(string role, string propertyRef, bool embedded) - { - return new MapType(role, propertyRef, embedded); - } - - public virtual CollectionType OrderedMap(string role, string propertyRef, bool embedded) - { - return new OrderedMapType(role, propertyRef, embedded); - } - - public virtual CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer) - { - return new SortedMapType(role, propertyRef, comparer, embedded); - } - - public virtual CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded) - { - return new GenericMapType<TKey, TValue>(role, propertyRef); - } - - public virtual CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer) - { - return new GenericSortedDictionaryType<TKey, TValue>(role, propertyRef, comparer); - } - - public virtual CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer) - { - return new GenericSortedListType<TKey, TValue>(role, propertyRef, comparer); - } - } -} \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs (from rev 4455, trunk/nhibernate/src/NHibernate/Type/CollectionTypeFactory.cs) =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/DefaultCollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -0,0 +1,104 @@ +using System.Collections; +using System.Collections.Generic; +using NHibernate.Bytecode; + +namespace NHibernate.Type +{ + public class DefaultCollectionTypeFactory : ICollectionTypeFactory + { + public virtual CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) + { + return new ArrayType(role, propertyRef, elementClass, embedded); + } + + public virtual CollectionType Bag(string role, string propertyRef, bool embedded) + { + return new BagType(role, propertyRef, embedded); + } + + public virtual CollectionType Bag<T>(string role, string propertyRef, bool embedded) + { + return new GenericBagType<T>(role, propertyRef); + } + + public virtual CollectionType List(string role, string propertyRef, bool embedded) + { + return new ListType(role, propertyRef, embedded); + } + + public virtual CollectionType List<T>(string role, string propertyRef, bool embedded) + { + return new GenericListType<T>(role, propertyRef); + } + + public virtual CollectionType IdBag(string role, string propertyRef, bool embedded) + { + return new IdentifierBagType(role, propertyRef, embedded); + } + + public virtual CollectionType IdBag<T>(string role, string propertyRef, bool embedded) + { + return new GenericIdentifierBagType<T>(role, propertyRef); + } + + public virtual CollectionType Set(string role, string propertyRef, bool embedded) + { + return new SetType(role, propertyRef, embedded); + } + + public virtual CollectionType OrderedSet(string role, string propertyRef, bool embedded) + { + return new OrderedSetType(role, propertyRef, embedded); + } + + public virtual CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer) + { + return new SortedSetType(role, propertyRef, comparer, embedded); + } + + public virtual CollectionType Set<T>(string role, string propertyRef, bool embedded) + { + return new GenericSetType<T>(role, propertyRef); + } + + public virtual CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer) + { + return new GenericSortedSetType<T>(role, propertyRef, comparer); + } + + public virtual CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded) + { + return new GenericOrderedSetType<T>(role, propertyRef); + } + + public virtual CollectionType Map(string role, string propertyRef, bool embedded) + { + return new MapType(role, propertyRef, embedded); + } + + public virtual CollectionType OrderedMap(string role, string propertyRef, bool embedded) + { + return new OrderedMapType(role, propertyRef, embedded); + } + + public virtual CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer) + { + return new SortedMapType(role, propertyRef, comparer, embedded); + } + + public virtual CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded) + { + return new GenericMapType<TKey, TValue>(role, propertyRef); + } + + public virtual CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer) + { + return new GenericSortedDictionaryType<TKey, TValue>(role, propertyRef, comparer); + } + + public virtual CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer) + { + return new GenericSortedListType<TKey, TValue>(role, propertyRef, comparer); + } + } +} \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/Type/ICollectionTypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -1,248 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -namespace NHibernate.Type -{ - /// <summary> - /// Type factory for collections types. - /// </summary> - public interface ICollectionTypeFactory - { - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="System.Array"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="elementClass">The <see cref="System.Type"/> to use to create the array.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// An <see cref="ArrayType"/> for the specified role. - /// </returns> - CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> - /// with bag semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="BagType"/> for the specified role. - /// </returns> - CollectionType Bag(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics. - /// </summary> - /// <typeparam name="T">The type of elements in the list.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef"> - /// The name of the property in the owner object containing the collection ID, - /// or <see langword="null" /> if it is the primary key. - /// </param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="GenericBagType{T}"/> for the specified role. - /// </returns> - CollectionType Bag<T>(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="ListType"/> for the specified role. - /// </returns> - CollectionType List(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IList<T>"/> with list - /// semantics. - /// </summary> - /// <typeparam name="T">The type of elements in the list.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef"> - /// The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key. - /// </param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="ListType"/> for the specified role. - /// </returns> - CollectionType List<T>(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IList"/> - /// with id-bag semantics. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="IdentifierBagType"/> for the specified role. - /// </returns> - CollectionType IdBag(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IList{T}"/> with identifier - /// bag semantics. - /// </summary> - /// <typeparam name="T">The type of elements in the list.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key. - /// </param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="GenericIdentifierBagType{T}"/> for the specified role. - /// </returns> - CollectionType IdBag<T>(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="SetType"/> for the specified role. - /// </returns> - CollectionType Set(string role, string propertyRef, bool embedded); - - CollectionType OrderedSet(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.ISet"/> - /// that is sorted by an <see cref="IComparer"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="SortedSetType"/> for the specified role. - /// </returns> - CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="Iesi.Collections.Generic.ISet{T}" />. - /// </summary> - /// <typeparam name="T">The type of elements in the collection.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> - CollectionType Set<T>(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for a sorted <see cref="Iesi.Collections.Generic.ISet{T}" />. - /// </summary> - /// <typeparam name="T">The type of elements in the collection.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <param name="comparer">The <see cref="System.Collections.Generic.IComparer{T}" /> to use for the set.</param> - /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> - CollectionType SortedSet<T>(string role, string propertyRef, bool embedded, IComparer<T> comparer); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />. - /// </summary> - /// <typeparam name="T">The type of elements in the collection.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef"> - /// The name of the property in the owner object containing the collection ID, - /// or <see langword="null" /> if it is the primary key. - /// </param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> - CollectionType OrderedSet<T>(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef"> - /// The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="MapType"/> for the specified role. - /// </returns> - CollectionType Map(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> - /// that maintains insertion order of elements. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="OrderedMapType"/> for the specified role. - /// </returns> - CollectionType OrderedMap(string role, string propertyRef, bool embedded); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an <see cref="IDictionary"/> - /// that is sorted by an <see cref="IComparer"/>. - /// </summary> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.</param> - /// <param name="comparer">The <see cref="IComparer"/> that does the sorting.</param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="SortedMapType"/> for the specified role. - /// </returns> - CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer); - - /// <summary> - /// Creates a new <see cref="CollectionType"/> for an - /// <see cref="System.Collections.Generic.IDictionary<TKey,TValue>"/>. - /// </summary> - /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam> - /// <typeparam name="TValue">The type of values in the dictionary.</typeparam> - /// <param name="role">The role the collection is in.</param> - /// <param name="propertyRef">The name of the property in the - /// owner object containing the collection ID, or <see langword="null" /> if it is - /// the primary key.< - /// /param> - /// <param name="embedded">Is embedded in XML (not supported yet)</param> - /// <returns> - /// A <see cref="MapType"/> for the specified role. - /// </returns> - CollectionType Map<TKey, TValue>(string role, string propertyRef, bool embedded); - - - CollectionType SortedDictionary<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer); - CollectionType SortedList<TKey, TValue>(string role, string propertyRef, bool embedded, IComparer<TKey> comparer); - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-11 19:17:20 UTC (rev 4456) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-11 21:49:52 UTC (rev 4457) @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Reflection; +using NHibernate.Bytecode; using NHibernate.Classic; using NHibernate.Engine; using NHibernate.Intercept; @@ -95,10 +96,7 @@ /// <summary></summary> static TypeFactory() { - Instance = - new TypeFactory( - (ICollectionTypeFactory) - Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(typeof (CollectionTypeFactory))); + Instance = new TypeFactory(); //basicTypes.Add(NHibernate.Blob.Name, NHibernate.Blob); //basicTypes.Add(NHibernate.Clob.Name, NHibernate.Clob); @@ -184,11 +182,16 @@ getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, GetDecimalType); } - public ICollectionTypeFactory CollectionTypeFactory { get; private set; } + public ICollectionTypeFactory CollectionTypeFactory + { + get + { + return Cfg.Environment.BytecodeProvider.CollectionTypeFactory; + } + } - private TypeFactory(ICollectionTypeFactory collectionTypeFactory) + private TypeFactory() { - CollectionTypeFactory = collectionTypeFactory; } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |