You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2009-06-09 23:08:15
|
Revision: 4437 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4437&view=rev Author: fabiomaulo Date: 2009-06-09 23:08:08 +0000 (Tue, 09 Jun 2009) Log Message: ----------- One more step First for injectable ICollectionTypeFactory Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-09 22:05:38 UTC (rev 4436) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-09 23:08:08 UTC (rev 4437) @@ -36,8 +36,7 @@ private static readonly char[] precisionScaleSplit = new char[] { '(', ')', ',' }; private static readonly char[] lengthSplit = new char[] { '(', ')' }; - - private static readonly ICollectionTypeFactory collectionTypeFactory; + private static readonly TypeFactory Instance; private static readonly System.Type[] GenericCollectionSimpleSignature = new[] { typeof(string), typeof(string), typeof(bool) }; /* @@ -96,9 +95,10 @@ /// <summary></summary> static TypeFactory() { - collectionTypeFactory = - (ICollectionTypeFactory) - Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(typeof (CollectionTypeFactory)); + Instance = + new TypeFactory( + (ICollectionTypeFactory) + Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(typeof (CollectionTypeFactory))); //basicTypes.Add(NHibernate.Blob.Name, NHibernate.Blob); //basicTypes.Add(NHibernate.Clob.Name, NHibernate.Clob); @@ -184,10 +184,11 @@ getTypeDelegatesWithPrecision.Add(NHibernateUtil.Decimal.Name, GetDecimalType); } + public ICollectionTypeFactory CollectionTypeFactory { get; private set; } - private TypeFactory() + private TypeFactory(ICollectionTypeFactory collectionTypeFactory) { - throw new NotSupportedException(); + CollectionTypeFactory = collectionTypeFactory; } /// <summary> @@ -656,52 +657,52 @@ public static CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) { - return collectionTypeFactory.Array(role, propertyRef, embedded, elementClass); + return Instance.CollectionTypeFactory.Array(role, propertyRef, embedded, elementClass); } public static CollectionType List(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.List(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.List(role, propertyRef, embedded); } public static CollectionType Bag(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.Bag(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.Bag(role, propertyRef, embedded); } public static CollectionType IdBag(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.IdBag(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.IdBag(role, propertyRef, embedded); } public static CollectionType Map(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.Map(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.Map(role, propertyRef, embedded); } public static CollectionType Set(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.Set(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.Set(role, propertyRef, embedded); } public static CollectionType SortedMap(string role, string propertyRef, bool embedded, IComparer comparer) { - return collectionTypeFactory.SortedMap(role, propertyRef, embedded, comparer); + return Instance.CollectionTypeFactory.SortedMap(role, propertyRef, embedded, comparer); } public static CollectionType OrderedMap(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.OrderedMap(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.OrderedMap(role, propertyRef, embedded); } public static CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer) { - return collectionTypeFactory.SortedSet(role, propertyRef, embedded, comparer); + return Instance.CollectionTypeFactory.SortedSet(role, propertyRef, embedded, comparer); } public static CollectionType OrderedSet(string role, string propertyRef, bool embedded) { - return collectionTypeFactory.OrderedSet(role, propertyRef, embedded); + return Instance.CollectionTypeFactory.OrderedSet(role, propertyRef, embedded); } public static CollectionType GenericBag(string role, string propertyRef, System.Type elementClass) @@ -709,7 +710,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("Bag", new[] {elementClass}, GenericCollectionSimpleSignature); - return (CollectionType) mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); } public static CollectionType GenericIdBag(string role, string propertyRef, System.Type elementClass) @@ -717,7 +718,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("IdBag", new[] { elementClass }, GenericCollectionSimpleSignature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); } public static CollectionType GenericList(string role, string propertyRef, System.Type elementClass) @@ -725,7 +726,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("List", new[] { elementClass }, GenericCollectionSimpleSignature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); } public static CollectionType GenericMap(string role, string propertyRef, System.Type indexClass, @@ -734,7 +735,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("Map", new[] {indexClass, elementClass }, GenericCollectionSimpleSignature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); } public static CollectionType GenericSortedList(string role, string propertyRef, object comparer, @@ -744,7 +745,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("SortedList", new[] { indexClass, elementClass }, signature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new[] { role, propertyRef, false, comparer }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new[] { role, propertyRef, false, comparer }); } public static CollectionType GenericSortedDictionary(string role, string propertyRef, object comparer, @@ -754,7 +755,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("SortedDictionary", new[] { indexClass, elementClass }, signature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new[] { role, propertyRef, false, comparer }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new[] { role, propertyRef, false, comparer }); } public static CollectionType GenericSet(string role, string propertyRef, System.Type elementClass) @@ -762,7 +763,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("Set", new[] { elementClass }, GenericCollectionSimpleSignature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); } public static CollectionType GenericSortedSet(string role, string propertyRef, object comparer, @@ -772,7 +773,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("SortedSet", new[] { elementClass }, signature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new[] { role, propertyRef, false, comparer }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new[] { role, propertyRef, false, comparer }); } public static CollectionType GenericOrderedSet(string role, string propertyRef, @@ -781,7 +782,7 @@ MethodInfo mi = ReflectHelper.GetGenericMethodFrom<ICollectionTypeFactory>("OrderedSet", new[] { elementClass }, GenericCollectionSimpleSignature); - return (CollectionType)mi.Invoke(collectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); } /// <summary> Deep copy a series of values from one array to another... </summary> 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-09 19:26:26
|
Revision: 4435 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4435&view=rev Author: darioquintana Date: 2009-06-09 19:26:22 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Cannot infer the result-set order for each RDBMS Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs 2009-06-09 18:41:06 UTC (rev 4434) +++ trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs 2009-06-09 19:26:22 UTC (rev 4435) @@ -362,12 +362,13 @@ IQuery q = dq.GetExecutableQuery(s); IList<Foo> l = q.List<Foo>(); Assert.AreEqual(2, l.Count); - Assert.AreEqual("N2", l[0].Name); - Assert.AreEqual("N3", l[1].Name); + + Assert.True(l.Contains(new Foo("N2", "D2"))); + Assert.True(l.Contains(new Foo("N3", "D3"))); } // Pagination - dq = new DetachedQuery("from Foo"); + dq = new DetachedQuery("from Foo f order by f.IntValue"); dq.SetFirstResult(0).SetMaxResults(2); using (ISession s = OpenSession()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-06-09 18:41:33
|
Revision: 4434 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4434&view=rev Author: darioquintana Date: 2009-06-09 18:41:06 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Minor: Using Transaction instead of Flush() (passing now for MySQL too) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/MultipleCollectionFetchTest/AbstractMultipleCollectionFetchFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/MultipleCollectionFetchTest/AbstractMultipleCollectionFetchFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MultipleCollectionFetchTest/AbstractMultipleCollectionFetchFixture.cs 2009-06-09 18:34:49 UTC (rev 4433) +++ trunk/nhibernate/src/NHibernate.Test/MultipleCollectionFetchTest/AbstractMultipleCollectionFetchFixture.cs 2009-06-09 18:41:06 UTC (rev 4434) @@ -52,10 +52,11 @@ protected virtual void RunLinearJoinFetchTest(Person parent) { - using (ISession s = OpenSession()) + using (ISession s = OpenSession()) + using(ITransaction tx = s.BeginTransaction()) { s.Save(parent); - s.Flush(); + tx.Commit(); } using (ISession s = OpenSession()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-06-09 18:34:52
|
Revision: 4433 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4433&view=rev Author: darioquintana Date: 2009-06-09 18:34:49 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Minor: Using Transaction instead of Flush() (passing for MySQL) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs 2009-06-09 17:32:21 UTC (rev 4432) +++ trunk/nhibernate/src/NHibernate.Test/QueryTest/DetachedQueryFixture.cs 2009-06-09 18:34:49 UTC (rev 4433) @@ -27,23 +27,25 @@ protected override void OnSetUp() { - using (ISession s = OpenSession()) + using (var s = OpenSession()) + using(var tx = s.BeginTransaction()) { for (int i = 0; i < totalFoo; i++) { Foo f = new Foo("N" + i, "D" + i, i); s.Save(f); } - s.Flush(); + tx.Commit(); } } protected override void OnTearDown() { - using (ISession s = OpenSession()) + using (var s = OpenSession()) + using(var tx = s.BeginTransaction()) { s.Delete("from Foo"); - s.Flush(); + tx.Commit(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-06-09 17:32:54
|
Revision: 4432 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4432&view=rev Author: darioquintana Date: 2009-06-09 17:32:21 +0000 (Tue, 09 Jun 2009) Log Message: ----------- NH-1824 fixed: MySQL: support for Temporary Tables Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs 2009-06-09 14:11:03 UTC (rev 4431) +++ trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs 2009-06-09 17:32:21 UTC (rev 4432) @@ -231,5 +231,15 @@ { return " drop index " + constraintName; } + + public override bool SupportsTemporaryTables + { + get { return true; } + } + + public override string CreateTemporaryTableString + { + get { return "create temporary table if not exists"; } + } } } \ 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: <dar...@us...> - 2009-06-09 14:11:34
|
Revision: 4431 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4431&view=rev Author: darioquintana Date: 2009-06-09 14:11:03 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Test refactoring & reformatting Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-06-09 01:23:41 UTC (rev 4430) +++ trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-06-09 14:11:03 UTC (rev 4431) @@ -13,18 +13,19 @@ protected override IList Mappings { - get { return new string[] {"Extralazy.UserGroup.hbm.xml"}; } + get { return new[] {"Extralazy.UserGroup.hbm.xml"}; } } protected override string CacheConcurrencyStrategy { get { return null; } } + [Test] public void ExtraLazyWithWhereClause() { - using(ISession s = OpenSession()) - using(ITransaction t=s.BeginTransaction()) + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { s.CreateSQLQuery("insert into Users (Name,Password) values('gavin','secret')") .UniqueResult(); @@ -35,226 +36,258 @@ t.Commit(); } - using(ISession s = OpenSession()) + using (ISession s = OpenSession()) { var gavin = s.Get<User>("gavin"); Assert.AreEqual(1, gavin.Photos.Count); Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents)); } - using(ISession s=OpenSession()) - using(ITransaction t=s.BeginTransaction()) + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) { s.CreateSQLQuery("delete from Photos") - .UniqueResult(); + .UniqueResult(); s.CreateSQLQuery("delete from Users") - .UniqueResult(); + .UniqueResult(); t.Commit(); } - sessions.Evict(typeof(User)); - sessions.Evict(typeof(Photo)); + sessions.Evict(typeof (User)); + sessions.Evict(typeof (Photo)); } + [Test] public void OrphanDelete() { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - User gavin = new User("gavin", "secret"); - Document hia = new Document("HiA", "blah blah blah", gavin); - Document hia2 = new Document("HiA2", "blah blah blah blah", gavin); - gavin.Documents.Add(hia); // NH: added ; I don't understand how can work in H3.2.5 without add - gavin.Documents.Add(hia2);// NH: added - s.Persist(gavin); - t.Commit(); - s.Close(); + User gavin = null; + Document hia = null; + Document hia2 = null; - s = OpenSession(); - t = s.BeginTransaction(); - gavin = s.Get<User>("gavin"); - Assert.AreEqual(2, gavin.Documents.Count); - gavin.Documents.Remove(hia2); - Assert.IsFalse(gavin.Documents.Contains(hia2)); - Assert.IsTrue(gavin.Documents.Contains(hia)); - Assert.AreEqual(1, gavin.Documents.Count); - Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents)); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + gavin = new User("gavin", "secret"); + hia = new Document("HiA", "blah blah blah", gavin); + hia2 = new Document("HiA2", "blah blah blah blah", gavin); + gavin.Documents.Add(hia); // NH: added ; I don't understand how can work in H3.2.5 without add + gavin.Documents.Add(hia2); // NH: added + s.Persist(gavin); + t.Commit(); + } - s = OpenSession(); - t = s.BeginTransaction(); - gavin = s.Get<User>("gavin"); - Assert.AreEqual(1, gavin.Documents.Count); - Assert.IsFalse(gavin.Documents.Contains(hia2)); - Assert.IsTrue(gavin.Documents.Contains(hia)); - Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents)); - Assert.That(s.Get<Document>("HiA2"), Is.Null); - gavin.Documents.Clear(); - Assert.IsTrue(NHibernateUtil.IsInitialized(gavin.Documents)); - s.Delete(gavin); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + gavin = s.Get<User>("gavin"); + Assert.AreEqual(2, gavin.Documents.Count); + gavin.Documents.Remove(hia2); + Assert.IsFalse(gavin.Documents.Contains(hia2)); + Assert.IsTrue(gavin.Documents.Contains(hia)); + Assert.AreEqual(1, gavin.Documents.Count); + Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents)); + t.Commit(); + } + + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + gavin = s.Get<User>("gavin"); + Assert.AreEqual(1, gavin.Documents.Count); + Assert.IsFalse(gavin.Documents.Contains(hia2)); + Assert.IsTrue(gavin.Documents.Contains(hia)); + Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents)); + Assert.That(s.Get<Document>("HiA2"), Is.Null); + gavin.Documents.Clear(); + Assert.IsTrue(NHibernateUtil.IsInitialized(gavin.Documents)); + s.Delete(gavin); + t.Commit(); + } } [Test] public void Get() { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - User gavin = new User("gavin", "secret"); - User turin = new User("turin", "tiger"); - Group g = new Group("developers"); - g.Users.Add("gavin", gavin); - g.Users.Add("turin", turin); - s.Persist(g); - gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); - gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); - t.Commit(); - s.Close(); + User gavin = null; + User turin = null; + Group g = null; - s = OpenSession(); - t = s.BeginTransaction(); - g = s.Get<Group>("developers"); - gavin = (User) g.Users["gavin"]; - turin = (User) g.Users["turin"]; - Assert.That(gavin, Is.Not.Null); - Assert.That(turin, Is.Not.Null); - Assert.That(g.Users["emmanuel"], Is.Null); - Assert.IsFalse(NHibernateUtil.IsInitialized(g.Users)); - Assert.That(gavin.Session["foo"], Is.Not.Null); - Assert.That(turin.Session["foo"], Is.Null); - Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Session)); - Assert.IsFalse(NHibernateUtil.IsInitialized(turin.Session)); - s.Delete(gavin); - s.Delete(turin); - s.Delete(g); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + gavin = new User("gavin", "secret"); + turin = new User("turin", "tiger"); + g = new Group("developers"); + g.Users.Add("gavin", gavin); + g.Users.Add("turin", turin); + s.Persist(g); + gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); + gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); + t.Commit(); + } + + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + g = s.Get<Group>("developers"); + gavin = (User) g.Users["gavin"]; + turin = (User) g.Users["turin"]; + Assert.That(gavin, Is.Not.Null); + Assert.That(turin, Is.Not.Null); + Assert.That(g.Users["emmanuel"], Is.Null); + Assert.IsFalse(NHibernateUtil.IsInitialized(g.Users)); + Assert.That(gavin.Session["foo"], Is.Not.Null); + Assert.That(turin.Session["foo"], Is.Null); + Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Session)); + Assert.IsFalse(NHibernateUtil.IsInitialized(turin.Session)); + s.Delete(gavin); + s.Delete(turin); + s.Delete(g); + t.Commit(); + } } [Test] public void RemoveClear() { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - User gavin = new User("gavin", "secret"); - User turin = new User("turin", "tiger"); - Group g = new Group("developers"); - g.Users.Add("gavin", gavin); - g.Users.Add("turin", turin); - s.Persist(g); - gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); - gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); - t.Commit(); - s.Close(); + User gavin = null; + User turin = null; + Group g = null; - s = OpenSession(); - t = s.BeginTransaction(); - g = s.Get<Group>("developers"); - gavin = (User) g.Users["gavin"]; - turin = (User) g.Users["turin"]; - Assert.IsFalse(NHibernateUtil.IsInitialized(g.Users)); - g.Users.Clear(); - gavin.Session.Remove("foo"); - Assert.IsTrue(NHibernateUtil.IsInitialized(g.Users)); - Assert.IsTrue(NHibernateUtil.IsInitialized(gavin.Session)); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + gavin = new User("gavin", "secret"); + turin = new User("turin", "tiger"); + g = new Group("developers"); + g.Users.Add("gavin", gavin); + g.Users.Add("turin", turin); + s.Persist(g); + gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); + gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); + t.Commit(); + } - s = OpenSession(); - t = s.BeginTransaction(); - g = s.Get<Group>("developers"); - //Assert.IsTrue( g.Users.IsEmpty() ); - //Assert.IsFalse( NHibernateUtil.IsInitialized( g.getUsers() ) ); - gavin = s.Get<User>("gavin"); - Assert.IsFalse(gavin.Session.Contains("foo")); - Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Session)); - s.Delete(gavin); - s.Delete(turin); - s.Delete(g); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + g = s.Get<Group>("developers"); + gavin = (User) g.Users["gavin"]; + turin = (User) g.Users["turin"]; + Assert.IsFalse(NHibernateUtil.IsInitialized(g.Users)); + g.Users.Clear(); + gavin.Session.Remove("foo"); + Assert.IsTrue(NHibernateUtil.IsInitialized(g.Users)); + Assert.IsTrue(NHibernateUtil.IsInitialized(gavin.Session)); + t.Commit(); + } + + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + g = s.Get<Group>("developers"); + //Assert.IsTrue( g.Users.IsEmpty() ); + //Assert.IsFalse( NHibernateUtil.IsInitialized( g.getUsers() ) ); + gavin = s.Get<User>("gavin"); + Assert.IsFalse(gavin.Session.Contains("foo")); + Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Session)); + s.Delete(gavin); + s.Delete(turin); + s.Delete(g); + t.Commit(); + } } [Test] public void IndexFormulaMap() { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - User gavin = new User("gavin", "secret"); - User turin = new User("turin", "tiger"); - Group g = new Group("developers"); - g.Users.Add("gavin", gavin); - g.Users.Add("turin", turin); - s.Persist(g); - gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); - gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); - t.Commit(); - s.Close(); + User gavin = null; + User turin = null; + Group g = null; + IDictionary smap = null; - s = OpenSession(); - t = s.BeginTransaction(); - g = s.Get<Group>("developers"); - Assert.AreEqual(2, g.Users.Count); - g.Users.Remove("turin"); - IDictionary smap = ((User) g.Users["gavin"]).Session; - Assert.AreEqual(2, smap.Count); - smap.Remove("bar"); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + gavin = new User("gavin", "secret"); + turin = new User("turin", "tiger"); + g = new Group("developers"); + g.Users.Add("gavin", gavin); + g.Users.Add("turin", turin); + s.Persist(g); + gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); + gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); + t.Commit(); + } - s = OpenSession(); - t = s.BeginTransaction(); - g = s.Get<Group>("developers"); - Assert.AreEqual(1, g.Users.Count); - smap = ((User) g.Users["gavin"]).Session; - Assert.AreEqual(1, smap.Count); - gavin = (User) g.Users["gavin"]; // NH: put in JAVA return the previous value - g.Users["gavin"]= turin; - s.Delete(gavin); - Assert.AreEqual(0, s.CreateQuery("select count(*) from SessionAttribute").UniqueResult<long>()); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + g = s.Get<Group>("developers"); + Assert.AreEqual(2, g.Users.Count); + g.Users.Remove("turin"); + smap = ((User) g.Users["gavin"]).Session; + Assert.AreEqual(2, smap.Count); + smap.Remove("bar"); + t.Commit(); + } - s = OpenSession(); - t = s.BeginTransaction(); - g = s.Get<Group>("developers"); - Assert.AreEqual(1, g.Users.Count); - turin = (User) g.Users["turin"]; - smap = turin.Session; - Assert.AreEqual(0, smap.Count); - Assert.AreEqual(1L, s.CreateQuery("select count(*) from User").UniqueResult<long>()); - s.Delete(g); - s.Delete(turin); - Assert.AreEqual(0, s.CreateQuery("select count(*) from User").UniqueResult<long>()); - t.Commit(); - s.Close(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + g = s.Get<Group>("developers"); + Assert.AreEqual(1, g.Users.Count); + smap = ((User) g.Users["gavin"]).Session; + Assert.AreEqual(1, smap.Count); + gavin = (User) g.Users["gavin"]; // NH: put in JAVA return the previous value + g.Users["gavin"] = turin; + s.Delete(gavin); + Assert.AreEqual(0, s.CreateQuery("select count(*) from SessionAttribute").UniqueResult<long>()); + t.Commit(); + } + + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + g = s.Get<Group>("developers"); + Assert.AreEqual(1, g.Users.Count); + turin = (User) g.Users["turin"]; + smap = turin.Session; + Assert.AreEqual(0, smap.Count); + Assert.AreEqual(1L, s.CreateQuery("select count(*) from User").UniqueResult<long>()); + s.Delete(g); + s.Delete(turin); + Assert.AreEqual(0, s.CreateQuery("select count(*) from User").UniqueResult<long>()); + t.Commit(); + } } [Test] public void SQLQuery() { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - User gavin = new User("gavin", "secret"); - User turin = new User("turin", "tiger"); - gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); - gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); - s.Persist(gavin); - s.Persist(turin); - s.Flush(); - s.Clear(); + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) + { + User gavin = new User("gavin", "secret"); + User turin = new User("turin", "tiger"); + gavin.Session.Add("foo", new SessionAttribute("foo", "foo bar baz")); + gavin.Session.Add("bar", new SessionAttribute("bar", "foo bar baz 2")); + s.Persist(gavin); + s.Persist(turin); + s.Flush(); + s.Clear(); - IList results = s.GetNamedQuery("UserSessionData").SetParameter("uname", "%in").List(); - Assert.AreEqual(2, results.Count); - // NH Different behavior : NH1612, HHH-2831 - gavin = (User)results[0]; - Assert.AreEqual("gavin", gavin.Name); - Assert.AreEqual(2, gavin.Session.Count); - t.Commit(); - s.Close(); + IList results = s.GetNamedQuery("UserSessionData").SetParameter("uname", "%in").List(); + Assert.AreEqual(2, results.Count); + // NH Different behavior : NH1612, HHH-2831 + gavin = (User) results[0]; + Assert.AreEqual("gavin", gavin.Name); + Assert.AreEqual(2, gavin.Session.Count); + t.Commit(); + } - using (s = OpenSession()) - using (t= s.BeginTransaction()) + using (var s = OpenSession()) + using (var t = s.BeginTransaction()) { s.Delete("from SessionAttribute"); s.Delete("from User"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-06-09 01:23:45
|
Revision: 4430 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4430&view=rev Author: darioquintana Date: 2009-06-09 01:23:41 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Minor: - Adding class into a explicit namespace. - Making the SQLExceptionConversion pass to all PostgreSQL Dialects Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs 2009-06-08 23:12:35 UTC (rev 4429) +++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs 2009-06-09 01:23:41 UTC (rev 4430) @@ -2,28 +2,31 @@ using System.Data.Common; using NHibernate.Exceptions; -public class PostgresExceptionConverterExample : ISQLExceptionConverter +namespace NHibernate.Test.ExceptionsTest { - #region ISQLExceptionConverter Members + public class PostgresExceptionConverterExample : ISQLExceptionConverter + { + #region ISQLExceptionConverter Members - public Exception Convert(AdoExceptionContextInfo exInfo) - { - var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as DbException; - if (sqle != null) + public Exception Convert(AdoExceptionContextInfo exInfo) { - string code = (string) sqle.GetType().GetProperty("Code").GetValue(sqle, null); + var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as DbException; + if (sqle != null) + { + string code = (string)sqle.GetType().GetProperty("Code").GetValue(sqle, null); - if (code == "23503") - { - return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null); + if (code == "23503") + { + return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null); + } + if (code == "42P01") + { + return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql); + } } - if (code == "42P01") - { - return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql); - } + return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql); } - return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql); + + #endregion } - - #endregion } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-06-08 23:12:35 UTC (rev 4429) +++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-06-09 01:23:41 UTC (rev 4430) @@ -34,7 +34,7 @@ typeof(OracleClientExceptionConverterExample).AssemblyQualifiedName); } - if (Dialect is PostgreSQL82Dialect) + if (Dialect is PostgreSQLDialect) { configuration.SetProperty(Cfg.Environment.SqlExceptionConverter, typeof(PostgresExceptionConverterExample).AssemblyQualifiedName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-06-08 23:13:05
|
Revision: 4429 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4429&view=rev Author: darioquintana Date: 2009-06-08 23:12:35 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Fix NH-1820 - PostgreSQL: support for Temporary Tables Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs 2009-06-07 23:03:14 UTC (rev 4428) +++ trunk/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs 2009-06-08 23:12:35 UTC (rev 4429) @@ -175,5 +175,30 @@ //i.e. 'null::decimal(19, 2)', even if 'null::decimal' would be enough return "null::" + GetTypeName(sqlType); } + + public override bool SupportsTemporaryTables + { + get { return true; } + } + + /*public override bool DropTemporaryTableAfterUse() + { + //we have to, because postgres sets current tx + //to rollback only after a failed create table + return true; + }*/ + + public override string CreateTemporaryTableString + { + get { return "create temporary table"; } + } + + public override string CreateTemporaryTablePostfix + { + get + { + return "on commit drop"; + } + } } } 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-07 14:58:45
|
Revision: 4427 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4427&view=rev Author: fabiomaulo Date: 2009-06-07 14:58:43 +0000 (Sun, 07 Jun 2009) Log Message: ----------- Updated for release Modified Paths: -------------- trunk/nhibernate/releasenotes.txt Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2009-06-07 14:45:06 UTC (rev 4426) +++ trunk/nhibernate/releasenotes.txt 2009-06-07 14:58:43 UTC (rev 4427) @@ -32,6 +32,38 @@ * ISQLExceptionConverter was changed in order to have more flexibility about information available for the conversion and followed management. * ADOException now use string instead SqlString +Build 2.1.0.Beta1 (rev4424) +============================= +** Bug + * [NH-959] - HQL queries with math operators and aggregates fail + * [NH-1092] - An Aggregate Count(*) on on an Abstract Base Class (Polymorphic) with UniqueResults returns 1 result per subclass when using the table per subclass approach + * [NH-1171] - Named parameters in SQL query are not substituted when query contains comments with apostrophes + * [NH-1182] - Calling session.delete() causes unnecessary update to timestamp before sql:delete + * [NH-1400] - HQL string literals with dots in are tried loaded as types (classes) and fails + * [NH-1427] - XML Comments inside <join> tag cause exception + * [NH-1444] - broken implicit join + * [NH-1487] - schema generation of unique-key with column involved in multiple unique constraints + * [NH-1507] - NHibernate misplaces JOIN conditions when WHERE references their columns and others altoghether + * [NH-1517] - SaveOrUpdateCopy does not call "public LifecycleVeto OnUpdate(ISession s)" + * [NH-1601] - Problems when accessing lists through property + * [NH-1617] - Formulas containing a data type incorrectly have that data type aliased with the outer entity alias + * [NH-1735] - TicksType used as entity version causes exceptions on cache put operation. + * [NH-1789] - A proxy sometimes doesn't call the overriden Equals() method (mapping interface instead class) + * [NH-1801] - Cross join with a where clause where lhs and rhs are different types of associations breaks with the new AST Query Translator + * [NH-1802] - Query Cache does not include filters in QueryKey.ToString + * [NH-1805] - Does ignore <meta> on <subclass> + * [NH-1813] - Not understandable exception message + +** Improvement + * [NH-1814] - Autoregister ReservedWords from MetaData + +** New Feature + * [NH-188] - Should Table/Column names be quoted automatically? + +** Patch + * [NH-1044] - IdBag for component not in XSD + * [NH-1804] - Expiration property of session factory not handled when configured via XML + Build 2.1.0.Alpha3 (rev4378) ============================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-07 14:45:37
|
Revision: 4426 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4426&view=rev Author: fabiomaulo Date: 2009-06-07 14:45:06 +0000 (Sun, 07 Jun 2009) Log Message: ----------- Actual trunk is pointing 2.1.0Beta2 Modified Paths: -------------- trunk/nhibernate/build-common/common.xml Modified: trunk/nhibernate/build-common/common.xml =================================================================== --- trunk/nhibernate/build-common/common.xml 2009-06-07 04:57:41 UTC (rev 4425) +++ trunk/nhibernate/build-common/common.xml 2009-06-07 14:45:06 UTC (rev 4426) @@ -76,7 +76,7 @@ effectively SP0). --> - <property name="project.version" value="2.1.0.Beta1" overwrite="false" /> + <property name="project.version" value="2.1.0.Beta2" overwrite="false" /> <!-- Compute short project version (major.minor) using a regex --> <regex input="${project.version}" pattern="^(?'shortversion'\d+\.\d+)" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-07 04:57:43
|
Revision: 4425 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4425&view=rev Author: fabiomaulo Date: 2009-06-07 04:57:41 +0000 (Sun, 07 Jun 2009) Log Message: ----------- Official logo Added Paths: ----------- trunk/nhibernate/doc/reference/images/NhLogo.png trunk/nhibernate/doc/reference/images/nhibernate_logo_a.png Added: trunk/nhibernate/doc/reference/images/NhLogo.png =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/doc/reference/images/NhLogo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/nhibernate/doc/reference/images/nhibernate_logo_a.png =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/doc/reference/images/nhibernate_logo_a.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-06 23:42:25
|
Revision: 4424 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4424&view=rev Author: fabiomaulo Date: 2009-06-06 23:41:52 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Added a test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs 2009-06-06 20:16:42 UTC (rev 4423) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs 2009-06-06 23:41:52 UTC (rev 4424) @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace NHibernate.Test.NHSpecificTest.NH1747 { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs 2009-06-06 20:16:42 UTC (rev 4423) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs 2009-06-06 23:41:52 UTC (rev 4424) @@ -1,13 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1747 { [TestFixture,Ignore] public class JoinTraversalTest : BugTestCase { + [Test] + public void PaymentTableNotContainsFk() + { + var cm = cfg.GetClassMapping(typeof (Payment)); + bool containsFK= false; + foreach (var column in cm.Table.ColumnIterator) + { + if (column.Name.Equals("PaymentBatchFK_ID")) + containsFK = true; + } + Assert.That(containsFK, Is.False); + } protected override void OnSetUp() { 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-05 22:49:54
|
Revision: 4422 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4422&view=rev Author: fabiomaulo Date: 2009-06-05 22:49:48 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Test for NH-959 (fixed) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-06-05 22:06:40 UTC (rev 4421) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-06-05 22:49:48 UTC (rev 4422) @@ -203,6 +203,15 @@ } [Test] + public void AggregatesAndMathNH959() + { + using (ISession s = OpenSession()) + { + Assert.DoesNotThrow(() => s.CreateQuery("select a.Id, sum(BodyWeight)/avg(BodyWeight) from Animal a group by a.Id having sum(BodyWeight)>0").List()); + } + } + + [Test] public void SubString() { IgnoreIfNotSupported("substring"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-05 22:06:41
|
Revision: 4421 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4421&view=rev Author: fabiomaulo Date: 2009-06-05 22:06:40 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Test for NH-1182 (was fixed in some moment in the past) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs 2009-06-05 22:06:40 UTC (rev 4421) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1182 +{ + public class ObjectA + { + public virtual int Id { get; set; } + public virtual DateTime Version { get; set; } + public virtual IList<ObjectB> Bs { get; set; } + } + + public class ObjectB + { + public virtual int Id { get; set; } + public virtual DateTime Version { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs 2009-06-05 22:06:40 UTC (rev 4421) @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1182 +{ + [TestFixture] + public class Fixture: BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.FormatSql, "false"); + } + [Test] + public void DeleteWithoutUpdateVersion() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new ObjectA { Bs = new List<ObjectB> { new ObjectB(), new ObjectB() } }); + t.Commit(); + } + + using (var ls = new SqlLogSpy()) + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var a = s.CreateCriteria<ObjectA>().UniqueResult<ObjectA>(); + s.Delete(a); + t.Commit(); + } + string wholeLog = ls.GetWholeLog(); + Assert.That(wholeLog, Text.DoesNotContain("UPDATE ObjectA")); + Assert.That(wholeLog, Text.Contains("UPDATE ObjectB"),"should create orphans"); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from ObjectB").ExecuteUpdate(); + s.CreateQuery("delete from ObjectA").ExecuteUpdate(); + t.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml 2009-06-05 22:06:40 UTC (rev 4421) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1182" + assembly="NHibernate.Test"> + + <class name="ObjectA"> + <id name="Id"> + <generator class="native"/> + </id> + <timestamp name="Version"/> + <bag name="Bs" cascade="all"> + <key column="AId"/> + <one-to-many class="ObjectB"/> + </bag> + </class> + + <class name="ObjectB"> + <id name="Id"> + <generator class="native"/> + </id> + <timestamp name="Version"/> + </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 21:27:54 UTC (rev 4420) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 22:06:40 UTC (rev 4421) @@ -363,6 +363,8 @@ <Compile Include="NHSpecificTest\NH1159\HibernateInterceptor.cs" /> <Compile Include="NHSpecificTest\NH1171\Domain.cs" /> <Compile Include="NHSpecificTest\NH1171\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1182\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1182\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1264\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1264\Name.cs" /> <Compile Include="NHSpecificTest\NH1264\Passenger.cs" /> @@ -1892,6 +1894,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1182\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1171\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1400\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1444\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-05 20:16:32
|
Revision: 4419 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4419&view=rev Author: fabiomaulo Date: 2009-06-05 20:15:26 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Fix NH-1400 (probably fixed by new parser) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs 2009-06-05 20:15:26 UTC (rev 4419) @@ -0,0 +1,7 @@ +namespace NHibernate.Test.NHSpecificTest.NH1400 +{ + public class SimpleGeographicalAddress + { + public string Line2 { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs 2009-06-05 20:15:26 UTC (rev 4419) @@ -0,0 +1,17 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1400 +{ + [TestFixture] + public class Fixture: BugTestCase + { + [Test] + public void DotInStringLiteralsConstant() + { + using (ISession s = OpenSession()) + { + Assert.DoesNotThrow(() => s.CreateQuery("from SimpleGeographicalAddress as dga where dga.Line2 = 'B1 P9, Scb, Ap. 18'").List()); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml 2009-06-05 20:15:26 UTC (rev 4419) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1400" + default-lazy="false"> + + <class name="SimpleGeographicalAddress"> + <id type="int"> + <generator class="native" /> + </id> + <property name="Line2" /> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 19:55:12 UTC (rev 4418) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 20:15:26 UTC (rev 4419) @@ -368,6 +368,8 @@ <Compile Include="NHSpecificTest\NH1343\Product.cs" /> <Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" /> <Compile Include="NHSpecificTest\NH1388\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1400\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1400\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1427\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1427\Person.cs" /> <Compile Include="NHSpecificTest\NH1444\classes.cs" /> @@ -1887,6 +1889,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1400\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1444\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1813\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1812\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 19:56:12
|
Revision: 4418 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4418&view=rev Author: fabiomaulo Date: 2009-06-05 19:55:12 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Sorry!! 2 files missed in previous commit. Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/classes.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Mappings.hbm.xml 2009-06-05 19:55:12 UTC (rev 4418) @@ -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.NHSpecificTest.NH1444" + default-cascade="save-update"> + <class name="xparent" table="xparent"> + <id name="Id" column="Id" type="Int64"> + <generator class="identity"/> + </id> + <property name="A" type="Int64"/> + <set name="Children" inverse="true"> + <key column="ParentId"/> + <one-to-many class="xchild"/> + </set> + </class> + <class name="xchild" table="xchild"> + <id name="Id" column="Id" type="Int64"> + <generator class="identity"/> + </id> + <property name="B" type="Int64"/> + <many-to-one name="Parent" column="ParentId"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/classes.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/classes.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/classes.cs 2009-06-05 19:55:12 UTC (rev 4418) @@ -0,0 +1,18 @@ +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1444 +{ + public class xparent + { + public virtual long Id { get; set; } + public virtual long? A { get; set; } + public virtual ISet<xchild> Children { get; set; } + } + + public class xchild + { + public virtual long Id { get; set; } + public virtual long? B { get; set; } + public virtual xparent Parent { get; set; } + } +} \ 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-05 19:48:57
|
Revision: 4417 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4417&view=rev Author: fabiomaulo Date: 2009-06-05 19:46:56 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Fix NH-1444 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs 2009-06-05 19:46:56 UTC (rev 4417) @@ -0,0 +1,30 @@ +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1444 +{ + [TestFixture] + public class Fixture: BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.FormatSql, "false"); + } + [Test] + public void Bug() + { + using (ISession s = OpenSession()) + { + long? filter = null; + using (var ls = new SqlLogSpy()) + { + s.CreateQuery(@"SELECT c FROM xchild c WHERE (:filternull = true OR c.Parent.A < :filterval)") + .SetParameter("filternull", !filter.HasValue) + .SetParameter("filterval", filter.HasValue ? filter.Value : 0).List<xchild>(); + var message = ls.GetWholeLog(); + Assert.That(message, Text.Contains("xchild0_.ParentId=xparent1_.Id and (@p0=1 or xparent1_.A<@p1)")); + } + } + } + } +} \ 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 18:10:33 UTC (rev 4416) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 19:46:56 UTC (rev 4417) @@ -370,6 +370,8 @@ <Compile Include="NHSpecificTest\NH1388\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1427\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1427\Person.cs" /> + <Compile Include="NHSpecificTest\NH1444\classes.cs" /> + <Compile Include="NHSpecificTest\NH1444\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1487\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1507\Employee.cs" /> <Compile Include="NHSpecificTest\NH1507\Fixture.cs" /> @@ -1885,6 +1887,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1444\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1813\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1812\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1601\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 17:05:25
|
Revision: 4415 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4415&view=rev Author: fabiomaulo Date: 2009-06-05 17:05:23 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Test for NH-1812 (not fixed yet) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs 2009-06-05 17:05:23 UTC (rev 4415) @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1812 +{ + public class AstBugBase : BugTestCase + { + [Test] + public void Test() + { + var p = new Person(); + + const string query = + @"select p from Person p + left outer join p.PeriodCollection p1 + where p1.Start > coalesce((select max(p2.Start) from Period p2), :nullStart)"; + + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(p); + tx.Commit(); + } + + s.CreateQuery(query) + .SetDateTime("nullStart", new DateTime(2001, 1, 1)) + .List<Person>(); + } + + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Person"); + tx.Commit(); + } + } + } + } + + [TestFixture, Ignore("To fix for AST parser; there are problems with subquery in various places.")] + public class AstBug : AstBugBase + { + + /* to the nh guy... + * sorry for not coming up with a more realistic use case + * We have a query that works fine with the old parser but not with the new AST parser + * I've broke our complex query down to this... + * I believe the problem is when mixing aggregate methods with isnull() + */ + } + + [TestFixture] + public class ItWorksWithClassicParser : AstBugBase + { + + protected override void Configure(Cfg.Configuration configuration) + { + configuration.AddProperties(new Dictionary<string, string> + { + { + Cfg.Environment.QueryTranslator, + typeof (NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).FullName + } + } + ); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml 2009-06-05 17:05:23 UTC (rev 4415) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1812" + assembly="NHibernate.Test" > + + <class name="Person"> + <id name="Id"> + <generator class="native" /> + </id> + <bag name="PeriodCollection"> + <key column="fk" /> + <one-to-many class="Period"/> + </bag> + </class> + + <class name="Period"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Start" /> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs 2009-06-05 17:05:23 UTC (rev 4415) @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1812 +{ + public class Person + { + public virtual int Id {get; set;} + public virtual IList<Period> PeriodCollection { get; set; } + + public Person(){PeriodCollection=new List<Period>();} + } + + public class Period + { + public virtual int Id { get; set; } + public virtual DateTime? Start { 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-05 13:50:25 UTC (rev 4414) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 17:05:23 UTC (rev 4415) @@ -486,6 +486,8 @@ <Compile Include="NHSpecificTest\NH1810\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1810\MedicalRecord.cs" /> <Compile Include="NHSpecificTest\NH1810\Parent.cs" /> + <Compile Include="NHSpecificTest\NH1812\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1812\Model.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1881,6 +1883,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1812\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1601\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1617\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1810\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 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. |