|
From: <te...@us...> - 2009-02-05 23:34:50
|
Revision: 4055
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4055&view=rev
Author: tehlike
Date: 2009-02-05 23:34:48 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Removing Castle folder.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Intercept/Castle/
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-05 22:15:53 UTC (rev 4054)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-05 23:34:48 UTC (rev 4055)
@@ -1162,7 +1162,6 @@
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>
<ItemGroup>
- <Folder Include="Intercept\Castle\" />
<Folder Include="Loader\Hql\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-06 13:23:11
|
Revision: 4056
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4056&view=rev
Author: darioquintana
Date: 2009-02-06 13:22:50 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
Breaking change NH-1657.
- Now type="TimeSpan" maps a TimeSpan (CLR) to a DbTime.Time (DbType)
- TimeType prepared to work with TimeSpan or DateTime, depends the dialect.
- Old TimeSpanType was moved to TimeSpanInt64Type (type="TimeSpanInt64")
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
trunk/nhibernate/src/NHibernate/Type/TimeType.cs
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs
trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -10,7 +10,7 @@
RegisterColumnType(DbType.DateTime2, "DATETIME2");
RegisterColumnType(DbType.DateTimeOffset, "DATETIMEOFFSET");
RegisterColumnType(DbType.Date, "DATE");
- //RegisterColumnType(DbType.Time, "TIME");
+ RegisterColumnType(DbType.Time, "TIME");
RegisterFunction("current_timestamp", new NoArgSQLFunction("sysdatetime", NHibernateUtil.DateTime2, true));
RegisterFunction("current_timestamp_offset", new NoArgSQLFunction("sysdatetimeoffset", NHibernateUtil.DateTimeOffset, true));
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-06 13:22:50 UTC (rev 4056)
@@ -396,7 +396,7 @@
<Compile Include="Type\StringClobType.cs" />
<Compile Include="Type\StringType.cs" />
<Compile Include="Type\TicksType.cs" />
- <Compile Include="Type\TimeSpanType.cs" />
+ <Compile Include="Type\TimeSpanInt64Type.cs" />
<Compile Include="Type\TimestampType.cs" />
<Compile Include="Type\TimeType.cs" />
<Compile Include="Type\TrueFalseType.cs" />
@@ -1084,6 +1084,7 @@
<Compile Include="Type\AnsiCharType.cs" />
<Compile Include="Type\AnyType.cs" />
<Compile Include="Type\AbstractCharType.cs" />
+ <Compile Include="Type\TimeSpanType.cs" />
<Compile Include="Type\DateTime2Type.cs" />
<Compile Include="Type\ClassMetaType.cs" />
<Compile Include="Type\CollectionType.cs" />
Modified: trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -211,6 +211,11 @@
public static readonly NullableType TimeSpan = new TimeSpanType();
/// <summary>
+ /// NHibernate Ticks type
+ /// </summary>
+ public static readonly NullableType TimeSpanInt64 = new TimeSpanInt64Type();
+
+ /// <summary>
/// NHibernate Timestamp type
/// </summary>
public static readonly NullableType Timestamp = new TimestampType();
Copied: trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs (from rev 4049, trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,119 @@
+using System;
+using System.Collections;
+using System.Data;
+using NHibernate.Engine;
+using NHibernate.SqlTypes;
+using System.Collections.Generic;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Int64" /> column
+ /// </summary>
+ [Serializable]
+ public class TimeSpanInt64Type : PrimitiveType, IVersionType, ILiteralType
+ {
+ /// <summary></summary>
+ internal TimeSpanInt64Type()
+ : base(SqlTypeFactory.Int64)
+ {
+ }
+
+ /// <summary></summary>
+ public override string Name
+ {
+ get { return "TimeSpanInt64"; }
+ }
+
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ return new TimeSpan(Convert.ToInt64(rs[index]));
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
+ }
+ }
+
+ public override object Get(IDataReader rs, string name)
+ {
+ try
+ {
+ return new TimeSpan(Convert.ToInt64(rs[name]));
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
+ }
+ }
+
+ /// <summary></summary>
+ public override System.Type ReturnedClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="st"></param>
+ /// <param name="value"></param>
+ /// <param name="index"></param>
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ ((IDataParameter)st.Parameters[index]).Value = ((TimeSpan)value).Ticks;
+ }
+
+ public override string ToString(object val)
+ {
+ return ((TimeSpan)val).Ticks.ToString();
+ }
+
+ #region IVersionType Members
+
+ public object Next(object current, ISessionImplementor session)
+ {
+ return Seed(session);
+ }
+
+ /// <summary></summary>
+ public virtual object Seed(ISessionImplementor session)
+ {
+ return new TimeSpan(DateTime.Now.Ticks);
+ }
+
+ public object StringToObject(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public IComparer Comparator
+ {
+ get { return Comparer<TimeSpan>.Default; }
+ }
+
+ #endregion
+
+ public override object FromStringValue(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public override System.Type PrimitiveClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ public override object DefaultValue
+ {
+ get { return TimeSpan.Zero; }
+ }
+
+ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
+ {
+ return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -1,119 +0,0 @@
-using System;
-using System.Collections;
-using System.Data;
-using NHibernate.Engine;
-using NHibernate.SqlTypes;
-using System.Collections.Generic;
-
-namespace NHibernate.Type
-{
- /// <summary>
- /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Int64" /> column
- /// </summary>
- [Serializable]
- public class TimeSpanType : PrimitiveType, IVersionType, ILiteralType
- {
- /// <summary></summary>
- internal TimeSpanType()
- : base(SqlTypeFactory.Int64)
- {
- }
-
- /// <summary></summary>
- public override string Name
- {
- get { return "TimeSpan"; }
- }
-
- public override object Get(IDataReader rs, int index)
- {
- try
- {
- return new TimeSpan(Convert.ToInt64(rs[index]));
- }
- catch (Exception ex)
- {
- throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
- }
- }
-
- public override object Get(IDataReader rs, string name)
- {
- try
- {
- return new TimeSpan(Convert.ToInt64(rs[name]));
- }
- catch (Exception ex)
- {
- throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
- }
- }
-
- /// <summary></summary>
- public override System.Type ReturnedClass
- {
- get { return typeof(TimeSpan); }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="st"></param>
- /// <param name="value"></param>
- /// <param name="index"></param>
- public override void Set(IDbCommand st, object value, int index)
- {
- ((IDataParameter)st.Parameters[index]).Value = ((TimeSpan)value).Ticks;
- }
-
- public override string ToString(object val)
- {
- return ((TimeSpan)val).Ticks.ToString();
- }
-
- #region IVersionType Members
-
- public object Next(object current, ISessionImplementor session)
- {
- return Seed(session);
- }
-
- /// <summary></summary>
- public virtual object Seed(ISessionImplementor session)
- {
- return new TimeSpan(DateTime.Now.Ticks);
- }
-
- public object StringToObject(string xml)
- {
- return TimeSpan.Parse(xml);
- }
-
- public IComparer Comparator
- {
- get { return Comparer<TimeSpan>.Default; }
- }
-
- #endregion
-
- public override object FromStringValue(string xml)
- {
- return TimeSpan.Parse(xml);
- }
-
- public override System.Type PrimitiveClass
- {
- get { return typeof(TimeSpan); }
- }
-
- public override object DefaultValue
- {
- get { return TimeSpan.Zero; }
- }
-
- public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
- {
- return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
- }
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,114 @@
+using System;
+using System.Collections;
+using System.Data;
+using NHibernate.Engine;
+using NHibernate.SqlTypes;
+using System.Collections.Generic;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Time" /> column
+ /// </summary>
+ [Serializable]
+ public class TimeSpanType : PrimitiveType, IVersionType, ILiteralType
+ {
+ private static readonly DateTime BaseDateValue = new DateTime(1753, 01, 01);
+
+ internal TimeSpanType()
+ : base(SqlTypeFactory.Time)
+ {
+ }
+
+ public override string Name
+ {
+ get { return "TimeSpan"; }
+ }
+
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ return (TimeSpan)rs[index];
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
+ }
+ }
+
+ public override object Get(IDataReader rs, string name)
+ {
+ try
+ {
+ //DateTime time = (DateTime)rs[name];
+ //return new TimeSpan(Convert.ToInt64(time.Ticks));
+ return (TimeSpan)rs[name];
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
+ }
+ }
+
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ DateTime date = BaseDateValue.AddTicks(((TimeSpan)value).Ticks);
+ ((IDataParameter) st.Parameters[index]).Value = date;
+ }
+
+ public override System.Type ReturnedClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ public override string ToString(object val)
+ {
+ return ((TimeSpan)val).Ticks.ToString();
+ }
+
+ #region IVersionType Members
+
+ public object Next(object current, ISessionImplementor session)
+ {
+ return Seed(session);
+ }
+
+ public virtual object Seed(ISessionImplementor session)
+ {
+ return new TimeSpan(DateTime.Now.Ticks);
+ }
+
+ public object StringToObject(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public IComparer Comparator
+ {
+ get { return Comparer<TimeSpan>.Default; }
+ }
+
+ #endregion
+
+ public override object FromStringValue(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public override System.Type PrimitiveClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ public override object DefaultValue
+ {
+ get { return TimeSpan.Zero; }
+ }
+
+ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
+ {
+ return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Type/TimeType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeType.cs 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate/Type/TimeType.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -14,7 +14,7 @@
/// using this Type indicates that you don't care about the Date portion of the DateTime.
/// </para>
/// <para>
- /// A more appropriate choice to store the duration/time is the <see cref="TimeSpanType"/>.
+ /// A more appropriate choice to store the duration/time is the <see cref="TimeSpanInt64Type"/>.
/// The underlying <see cref="DbType.Time"/> tends to be handled differently by different
/// DataProviders.
/// </para>
@@ -37,6 +37,12 @@
{
try
{
+ if(rs[index] is TimeSpan) //For those dialects where DbType.Time means TimeSpan.
+ {
+ TimeSpan time = (TimeSpan) rs[index];
+ return BaseDateValue.AddTicks(time.Ticks);
+ }
+
DateTime dbValue = Convert.ToDateTime(rs[index]);
return new DateTime(1753, 01, 01, dbValue.Hour, dbValue.Minute, dbValue.Second);
}
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -122,6 +122,7 @@
RegisterType(typeof(SByte), NHibernateUtil.SByte, null);
RegisterType(typeof(Single), NHibernateUtil.Single, "float");
RegisterType(typeof(String), NHibernateUtil.String, "string");
+ RegisterType(typeof(TimeSpan), NHibernateUtil.TimeSpanInt64,null);
RegisterType(typeof(TimeSpan), NHibernateUtil.TimeSpan, null);
RegisterType(typeof(System.Type), NHibernateUtil.Class, "class");
@@ -142,6 +143,7 @@
typeByTypeOfName[NHibernateUtil.TrueFalse.Name] = NHibernateUtil.TrueFalse;
typeByTypeOfName[NHibernateUtil.YesNo.Name] = NHibernateUtil.YesNo;
typeByTypeOfName[NHibernateUtil.Ticks.Name] = NHibernateUtil.Ticks;
+ typeByTypeOfName[NHibernateUtil.TimeSpanInt64.Name] = NHibernateUtil.TimeSpanInt64;
typeByTypeOfName[NHibernateUtil.TimeSpan.Name] = NHibernateUtil.TimeSpan;
// need to do add the key "Serializable" because the hbm files will have a
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-06 13:22:50 UTC (rev 4056)
@@ -1004,6 +1004,9 @@
<Compile Include="TypesTest\BooleanTypeFixture.cs" />
<Compile Include="TypesTest\ByteClass.cs" />
<Compile Include="TypesTest\ByteTypeFixture.cs" />
+ <Compile Include="TypesTest\TimeSpanClass.cs" />
+ <Compile Include="TypesTest\TimeSpanTypeFixture.cs" />
+ <Compile Include="TypesTest\TimeSpanInt64Class.cs" />
<Compile Include="TypesTest\Decima2lTypeFixture.cs" />
<Compile Include="TypesTest\DateTimeTypeFixture.cs" />
<Compile Include="TypesTest\DecimalClass.cs" />
@@ -1032,7 +1035,7 @@
<Compile Include="TypesTest\StringClobTypeFixture.cs" />
<Compile Include="TypesTest\StringTypeFixture.cs" />
<Compile Include="TypesTest\TicksTypeFixture.cs" />
- <Compile Include="TypesTest\TimeSpanTypeFixture.cs" />
+ <Compile Include="TypesTest\TimeSpanInt64TypeFixture.cs" />
<Compile Include="TypesTest\TimestampTypeFixture.cs" />
<Compile Include="TypesTest\TypeFactoryFixture.cs" />
<Compile Include="TypesTest\TypeFixtureBase.cs" />
@@ -1641,6 +1644,8 @@
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
<EmbeddedResource Include="NHSpecificTest\NH1289\Mappings.hbm.xml" />
+ <EmbeddedResource Include="TypesTest\TimeSpanClass.hbm.xml" />
+ <EmbeddedResource Include="TypesTest\TimeSpanInt64Class.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\FileStreamSql2008\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Seqidentity\MyEntity.hbm.xml" />
<EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,10 @@
+using System;
+
+namespace NHibernate.Test.TypesTest
+{
+ public class TimeSpanClass
+ {
+ public int Id { get; set; }
+ public TimeSpan TimeSpanValue { get; set; }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml (from rev 4049, trunk/nhibernate/src/NHibernate.Test/TypesTest/StringClobClass.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
+
+ <class name="NHibernate.Test.TypesTest.TimeSpanClass, NHibernate.Test">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="TimeSpanValue" type="TimeSpan" />
+ </class>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,10 @@
+using System;
+
+namespace NHibernate.Test.TypesTest
+{
+ public class TimeSpanInt64Class
+ {
+ public int Id { get; set; }
+ public TimeSpan TimeSpanValue { get; set; }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml (from rev 4049, trunk/nhibernate/src/NHibernate.Test/TypesTest/StringClobClass.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
+
+ <class name="NHibernate.Test.TypesTest.TimeSpanInt64Class, NHibernate.Test">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="TimeSpanValue" type="TimeSpanInt64" />
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs (from rev 4049, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,75 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.TypesTest
+{
+ /// <summary>
+ /// Summary description for TimeSpanTypeFixture.
+ /// </summary>
+ [TestFixture]
+ public class TimeSpanInt64TypeFixture
+ {
+ [Test]
+ public void Next()
+ {
+ var type = (TimeSpanInt64Type) NHibernateUtil.TimeSpanInt64;
+ object current = new TimeSpan(DateTime.Now.Ticks - 5);
+ object next = type.Next(current, null);
+
+ Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
+ Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
+ "next should be greater than current (could be equal depending on how quickly this occurs)");
+ }
+
+ [Test]
+ public void Seed()
+ {
+ var type = (TimeSpanInt64Type) NHibernateUtil.TimeSpanInt64;
+ Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
+ }
+ }
+
+ [TestFixture]
+ public class TimeSpanInt64Fixture2 : TypeFixtureBase
+ {
+ protected override string TypeName
+ {
+ get { return "TimeSpanInt64"; }
+ }
+
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ var ticks = new TimeSpan(1982);
+
+ var entity = new TimeSpanInt64Class
+ {
+ TimeSpanValue = ticks
+ };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(entity);
+ tx.Commit();
+ }
+
+ TimeSpanInt64Class entityReturned;
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ entityReturned = s.CreateQuery("from TimeSpanInt64Class").UniqueResult<TimeSpanInt64Class>();
+ Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete(entityReturned);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-02-05 23:34:48 UTC (rev 4055)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -1,32 +0,0 @@
-using System;
-using NHibernate.Type;
-using NUnit.Framework;
-
-namespace NHibernate.Test.TypesTest
-{
- /// <summary>
- /// Summary description for TimeSpanTypeFixture.
- /// </summary>
- [TestFixture]
- public class TimeSpanTypeFixture
- {
- [Test]
- public void Next()
- {
- TimeSpanType type = (TimeSpanType) NHibernateUtil.TimeSpan;
- object current = new TimeSpan(DateTime.Now.Ticks - 5);
- object next = type.Next(current, null);
-
- Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
- Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
- "next should be greater than current (could be equal depending on how quickly this occurs)");
- }
-
- [Test]
- public void Seed()
- {
- TimeSpanType type = (TimeSpanType) NHibernateUtil.TimeSpan;
- Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
- }
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-02-06 13:22:50 UTC (rev 4056)
@@ -0,0 +1,75 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.TypesTest
+{
+ /// <summary>
+ /// Summary description for TimeSpanTypeFixture.
+ /// </summary>
+ [TestFixture]
+ public class TimeSpanTypeFixture
+ {
+ [Test]
+ public void Next()
+ {
+ var type = (TimeSpanType) NHibernateUtil.TimeSpan;
+ object current = new TimeSpan(DateTime.Now.Ticks - 5);
+ object next = type.Next(current, null);
+
+ Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
+ Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
+ "next should be greater than current (could be equal depending on how quickly this occurs)");
+ }
+
+ [Test]
+ public void Seed()
+ {
+ var type = (TimeSpanType) NHibernateUtil.TimeSpan;
+ Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
+ }
+ }
+
+ [TestFixture]
+ public class TimeSpanFixture2 : TypeFixtureBase
+ {
+ protected override string TypeName
+ {
+ get { return "TimeSpan"; }
+ }
+
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ var ticks = DateTime.Parse("23:59:59").TimeOfDay;
+
+ var entity = new TimeSpanClass
+ {
+ TimeSpanValue = ticks
+ };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(entity);
+ tx.Commit();
+ }
+
+ TimeSpanClass entityReturned;
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult<TimeSpanClass>();
+ Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete(entityReturned);
+ tx.Commit();
+ }
+ }
+ }
+}
\ 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-02-06 14:58:53
|
Revision: 4058
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4058&view=rev
Author: darioquintana
Date: 2009-02-06 14:58:31 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
- Bug fixed: TimeSpanType prepared to work with TimeSpan or DateTime, depends on dialect.
- Tests specifics for DbType supported
- Fixes in Tests
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-02-06 13:40:28 UTC (rev 4057)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-02-06 14:58:31 UTC (rev 4058)
@@ -29,7 +29,12 @@
{
try
{
- return (TimeSpan)rs[index];
+ object value = rs[index];
+ if(value is TimeSpan)
+ return (TimeSpan)value;
+
+ DateTime time = (DateTime)rs[index];
+ return new TimeSpan(Convert.ToInt64(time.Ticks));
}
catch (Exception ex)
{
@@ -41,9 +46,12 @@
{
try
{
- //DateTime time = (DateTime)rs[name];
- //return new TimeSpan(Convert.ToInt64(time.Ticks));
- return (TimeSpan)rs[name];
+ object value = rs[name];
+ if (value is TimeSpan) //For those dialects where DbType.Time means TimeSpan.
+ return (TimeSpan)value;
+
+ DateTime time = (DateTime)rs[name];
+ return new TimeSpan(Convert.ToInt64(time.Ticks));
}
catch (Exception ex)
{
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-02-06 13:40:28 UTC (rev 4057)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-02-06 14:58:31 UTC (rev 4058)
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Data;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.Dates
@@ -12,6 +13,11 @@
get { return new[] {"NHSpecificTest.Dates.Mappings.DateTime2.hbm.xml"}; }
}
+ protected override DbType? AppliesTo()
+ {
+ return DbType.DateTime2;
+ }
+
[Test]
public void SavingAndRetrievingTest()
{
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs 2009-02-06 13:40:28 UTC (rev 4057)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs 2009-02-06 14:58:31 UTC (rev 4058)
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Data;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.Dates
@@ -12,6 +13,11 @@
get { return new[] {"NHSpecificTest.Dates.Mappings.DateTimeOffset.hbm.xml"}; }
}
+ protected override DbType? AppliesTo()
+ {
+ return DbType.DateTimeOffset;
+ }
+
[Test]
public void SavingAndRetrievingTest()
{
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs 2009-02-06 13:40:28 UTC (rev 4057)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs 2009-02-06 14:58:31 UTC (rev 4058)
@@ -1,6 +1,8 @@
using System;
using System.Collections;
+using System.Data;
using NHibernate.Dialect;
+using NHibernate.Util;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.Dates
@@ -17,7 +19,25 @@
protected override bool AppliesTo(Dialect.Dialect dialect)
{
- return dialect is MsSql2008Dialect;
+ var typeNames = (TypeNames)typeof(Dialect.Dialect).GetField("typeNames", ReflectHelper.AnyVisibilityInstance).GetValue(Dialect);
+ try
+ {
+ var value = AppliesTo();
+
+ if (value == null) return true;
+
+ typeNames.Get(value.Value);
+ }
+ catch (ArgumentException arg)
+ {
+ return false;
+ }
+ catch (Exception arg)
+ {
+ Assert.Fail("Probably a bug in the test case.");
+ }
+
+ return true;
}
protected void SavingAndRetrievingAction(AllDates entity, Action<AllDates> action)
@@ -47,5 +67,10 @@
tx.Commit();
}
}
+
+ protected virtual DbType? AppliesTo()
+ {
+ return null;
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs 2009-02-06 13:40:28 UTC (rev 4057)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs 2009-02-06 14:58:31 UTC (rev 4058)
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using NHibernate.Dialect;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.Dates
@@ -16,8 +17,17 @@
public void SavingAndRetrievingTest()
{
var now = DateTime.Parse("23:59:59").TimeOfDay;
+
SavingAndRetrievingAction(new AllDates {Sql_time = now},
- entity => Assert.AreEqual(entity.Sql_time, now));
+ entity =>
+ {
+ Assert.AreEqual(entity.Sql_time.Hours, now.Hours);
+ Assert.AreEqual(entity.Sql_time.Minutes, now.Minutes);
+ Assert.AreEqual(entity.Sql_time.Seconds, now.Seconds);
+ });
+
+ if(Dialect is MsSql2008Dialect)
+ SavingAndRetrievingAction(new AllDates { Sql_time = now }, entity => Assert.AreEqual(entity.Sql_time, now));
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-02-06 13:40:28 UTC (rev 4057)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-02-06 14:58:31 UTC (rev 4058)
@@ -1,4 +1,5 @@
using System;
+using NHibernate.Dialect;
using NHibernate.Type;
using NUnit.Framework;
@@ -61,7 +62,13 @@
using (ITransaction tx = s.BeginTransaction())
{
entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult<TimeSpanClass>();
- Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
+
+ if(Dialect is MsSql2008Dialect)
+ Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
+
+ Assert.AreEqual(entityReturned.TimeSpanValue.Hours,ticks.Hours);
+ Assert.AreEqual(entityReturned.TimeSpanValue.Minutes, ticks.Minutes);
+ Assert.AreEqual(entityReturned.TimeSpanValue.Seconds, ticks.Seconds);
}
using (ISession s = OpenSession())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-06 20:28:20
|
Revision: 4062
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4062&view=rev
Author: fabiomaulo
Date: 2009-02-06 20:28:16 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
Fix NH-1662 (new feature sequence-identity tested and supported by Oracle)
Possible breaking change:
see IDriver
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs
trunk/nhibernate/src/NHibernate/Driver/IDriver.cs
trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs
trunk/nhibernate/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs
trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs
trunk/nhibernate/src/NHibernate/Id/Insert/ReturningIdentifierInsert.cs
trunk/nhibernate/src/NHibernate/Id/SequenceIdentityGenerator.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -2061,5 +2061,14 @@
return null;
}
}
+
+ #region NH specific
+
+ public virtual SqlString AddIdentifierOutParameterToInsert(SqlString insertString, string identifierColumnName, string parameterName)
+ {
+ return insertString;
+ }
+
+ #endregion
}
}
Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -329,6 +329,11 @@
return sequenceName + ".nextval";
}
+ public override SqlString AddIdentifierOutParameterToInsert(SqlString insertString, string identifierColumnName, string parameterName)
+ {
+ return insertString.Append(" returning " + identifierColumnName + " into :" + parameterName);
+ }
+
public override string GetCreateSequenceString(string sequenceName)
{
return "create sequence " + sequenceName; //starts with 1, implicitly
Modified: trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -200,7 +200,7 @@
/// <param name="name">The name to set for IDbDataParameter.Name</param>
/// <param name="sqlType">The SqlType to set for IDbDataParameter.</param>
/// <returns>An IDbDataParameter ready to be added to an IDbCommand.</returns>
- protected IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType)
+ public IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType)
{
IDbDataParameter dbParam = command.CreateParameter();
InitializeParameter(dbParam, name, sqlType);
Modified: trunk/nhibernate/src/NHibernate/Driver/IDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/IDriver.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Driver/IDriver.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -85,5 +85,15 @@
/// </summary>
/// <param name="command"></param>
void PrepareCommand(IDbCommand command);
+
+ /// <summary>
+ /// Generates an IDbDataParameter for the IDbCommand. It does not add the IDbDataParameter to the IDbCommand's
+ /// Parameter collection.
+ /// </summary>
+ /// <param name="command">The IDbCommand to use to create the IDbDataParameter.</param>
+ /// <param name="name">The name to set for IDbDataParameter.Name</param>
+ /// <param name="sqlType">The SqlType to set for IDbDataParameter.</param>
+ /// <returns>An IDbDataParameter ready to be added to an IDbCommand.</returns>
+ IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType);
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -171,6 +171,7 @@
idgenerators.Add("guid.comb", typeof(GuidCombGenerator));
idgenerators.Add("guid.native", typeof(NativeGuidGenerator));
idgenerators.Add("select", typeof(SelectGenerator));
+ idgenerators.Add("sequence-identity", typeof(SequenceIdentityGenerator));
}
private IdentifierGeneratorFactory()
Modified: trunk/nhibernate/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Id/Insert/AbstractReturningDelegate.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -21,7 +21,7 @@
this.persister = persister;
}
- protected internal virtual IPostInsertIdentityPersister Persister
+ protected IPostInsertIdentityPersister Persister
{
get { return persister; }
}
Added: trunk/nhibernate/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Id/Insert/OutputParamReturningDelegate.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -0,0 +1,62 @@
+using System.Data;
+using NHibernate.Engine;
+using NHibernate.SqlCommand;
+using NHibernate.SqlTypes;
+
+namespace NHibernate.Id.Insert
+{
+ /// <summary>
+ /// <see cref="IInsertGeneratedIdentifierDelegate"/> implementation where the
+ /// underlying strategy causes the generated identitifer to be returned, as an
+ /// effect of performing the insert statement, in a Output parameter.
+ /// Thus, there is no need for an additional sql statement to determine the generated identitifer.
+ /// </summary>
+ public class OutputParamReturningDelegate : AbstractReturningDelegate
+ {
+ private const string ReturnParameterName = "nhIdOutParam";
+ private readonly ISessionFactoryImplementor factory;
+ private readonly string idColumnName;
+ private readonly SqlType paramType;
+ private string driveGeneratedParamName = ReturnParameterName;
+
+ public OutputParamReturningDelegate(IPostInsertIdentityPersister persister, ISessionFactoryImplementor factory)
+ : base(persister)
+ {
+ if (Persister.RootTableKeyColumnNames.Length > 1)
+ {
+ throw new HibernateException("identity-style generator cannot be used with multi-column keys");
+ }
+ paramType = Persister.IdentifierType.SqlTypes(factory)[0];
+ idColumnName = Persister.RootTableKeyColumnNames[0];
+ this.factory = factory;
+ }
+
+ #region Overrides of AbstractReturningDelegate
+
+ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert()
+ {
+ return new ReturningIdentifierInsert(factory, idColumnName, ReturnParameterName);
+ }
+
+ protected internal override IDbCommand Prepare(SqlCommandInfo insertSQL, ISessionImplementor session)
+ {
+ IDbCommand command = session.Batcher.PrepareCommand(CommandType.Text, insertSQL.Text, insertSQL.ParameterTypes);
+ //Add the output parameter
+ IDbDataParameter idParameter = factory.ConnectionProvider.Driver.GenerateParameter(command, ReturnParameterName,
+ paramType);
+ driveGeneratedParamName = idParameter.ParameterName;
+ idParameter.Direction = ParameterDirection.ReturnValue;
+
+ command.Parameters.Add(idParameter);
+ return command;
+ }
+
+ public override object ExecuteAndExtract(IDbCommand insert, ISessionImplementor session)
+ {
+ session.Batcher.ExecuteNonQuery(insert);
+ return ((IDbDataParameter)insert.Parameters[driveGeneratedParamName]).Value;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Id/Insert/ReturningIdentifierInsert.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/Insert/ReturningIdentifierInsert.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Id/Insert/ReturningIdentifierInsert.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -0,0 +1,30 @@
+using NHibernate.Engine;
+using NHibernate.SqlCommand;
+
+namespace NHibernate.Id.Insert
+{
+ /// <summary>
+ /// Specialized IdentifierGeneratingInsert which appends the database
+ /// specific clause which signifies to return generated identifier values
+ /// to the end of the insert statement.
+ /// </summary>
+ /// <remarks>
+ /// </remarks>
+ public class ReturningIdentifierInsert : NoCommentsInsert
+ {
+ private readonly string identifierColumnName;
+ private readonly string returnParameterName;
+
+ public ReturningIdentifierInsert(ISessionFactoryImplementor factory, string identifierColumnName,
+ string returnParameterName) : base(factory)
+ {
+ this.returnParameterName = returnParameterName;
+ this.identifierColumnName = identifierColumnName;
+ }
+
+ public override SqlString ToSqlString()
+ {
+ return Dialect.AddIdentifierOutParameterToInsert(base.ToSqlString(), identifierColumnName, returnParameterName);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -52,6 +52,11 @@
private SqlString sql;
private string parameters;
+ public string SequenceName
+ {
+ get { return sequenceName; }
+ }
+
#region IConfigurable Members
/// <summary>
Added: trunk/nhibernate/src/NHibernate/Id/SequenceIdentityGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/SequenceIdentityGenerator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Id/SequenceIdentityGenerator.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -0,0 +1,55 @@
+using NHibernate.Engine;
+using NHibernate.Id.Insert;
+
+namespace NHibernate.Id
+{
+ /// <summary>
+ /// A generator which combines sequence generation with immediate retrieval
+ /// by attaching a output parameter to the SQL command
+ /// In this respect it works much like ANSI-SQL IDENTITY generation.
+ /// </summary>
+ public class SequenceIdentityGenerator : SequenceGenerator, IPostInsertIdentifierGenerator
+ {
+ #region IPostInsertIdentifierGenerator Members
+
+ public override object Generate(ISessionImplementor session, object obj)
+ {
+ return IdentifierGeneratorFactory.PostInsertIndicator;
+ }
+
+ #endregion
+
+ #region Implementation of IPostInsertIdentifierGenerator
+
+ public IInsertGeneratedIdentifierDelegate GetInsertGeneratedIdentifierDelegate(IPostInsertIdentityPersister persister,
+ ISessionFactoryImplementor factory,
+ bool isGetGeneratedKeysEnabled)
+ {
+ return new SequenceIdentityDelegate(persister, factory, SequenceName);
+ }
+
+ #endregion
+
+ #region Nested type: SequenceIdentityDelegate
+
+ public class SequenceIdentityDelegate : OutputParamReturningDelegate
+ {
+ private readonly string sequenceNextValFragment;
+
+ public SequenceIdentityDelegate(IPostInsertIdentityPersister persister, ISessionFactoryImplementor factory,
+ string sequenceName) : base(persister, factory)
+ {
+ sequenceNextValFragment = factory.Dialect.GetSelectSequenceNextValString(sequenceName);
+ }
+
+ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert()
+ {
+ IdentifierGeneratingInsert insert = base.PrepareIdentifierGeneratingInsert();
+ insert.AddColumn(Persister.RootTableKeyColumnNames[0], sequenceNextValFragment);
+ return insert;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-06 20:28:16 UTC (rev 4062)
@@ -465,8 +465,11 @@
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
<Compile Include="Id\Insert\NoCommentsInsert.cs" />
+ <Compile Include="Id\Insert\ReturningIdentifierInsert.cs" />
+ <Compile Include="Id\Insert\OutputParamReturningDelegate.cs" />
<Compile Include="Id\NativeGuidGenerator.cs" />
<Compile Include="Id\SelectGenerator.cs" />
+ <Compile Include="Id\SequenceIdentityGenerator.cs" />
<Compile Include="IFutureValue.cs" />
<Compile Include="Impl\DelayedEnumerator.cs" />
<Compile Include="Impl\FutureQueryBatch.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs 2009-02-06 18:25:52 UTC (rev 4061)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs 2009-02-06 20:28:16 UTC (rev 4062)
@@ -3,7 +3,7 @@
namespace NHibernate.Test.Generatedkeys.Seqidentity
{
- [TestFixture, Ignore("Solution not implemented yet.")]
+ [TestFixture]
public class SequenceIdentityFixture : TestCase
{
protected override IList Mappings
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-07 04:24:32
|
Revision: 4063
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4063&view=rev
Author: fabiomaulo
Date: 2009-02-07 04:24:29 +0000 (Sat, 07 Feb 2009)
Log Message:
-----------
- Fix NH-1176
- Fix NH-1664
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/GeneratedIdentityFixture.cs
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.cs
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.cs
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/SimpleIdentityGeneratedFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-02-06 20:28:16 UTC (rev 4062)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -2069,6 +2069,32 @@
return insertString;
}
+ /// <summary>
+ /// The class (which implements <see cref="NHibernate.Id.IIdentifierGenerator"/>)
+ /// which acts as this dialects identity-style generation strategy.
+ /// </summary>
+ /// <returns> The native generator class. </returns>
+ /// <remarks>
+ /// Comes into play whenever the user specifies the "identity" generator.
+ /// </remarks>
+ public virtual System.Type IdentityStyleIdentifierGeneratorClass
+ {
+ get
+ {
+ if (SupportsIdentityColumns)
+ {
+ return typeof(IdentityGenerator);
+ }
+ else if (SupportsSequences)
+ {
+ return typeof(SequenceIdentityGenerator);
+ }
+ else
+ {
+ return typeof(TriggerIdentityGenerator);
+ }
+ }
+ }
#endregion
}
}
Modified: trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs 2009-02-06 20:28:16 UTC (rev 4062)
+++ trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -79,7 +79,7 @@
/// </remarks>
public sealed class IdentifierGeneratorFactory
{
- private static readonly ILog log = LogManager.GetLogger(typeof(IdentifierGeneratorFactory));
+ private static readonly ILog log = LogManager.GetLogger(typeof (IdentifierGeneratorFactory));
/// <summary> Get the generated identifier when using identity columns</summary>
/// <param name="rs">The <see cref="IDataReader"/> to read the identifier value from.</param>
@@ -101,7 +101,6 @@
return id;
}
-
/// <summary>
/// Gets the value of the identifier from the <see cref="IDataReader"/> and
/// ensures it is the correct <see cref="System.Type"/>.
@@ -142,7 +141,7 @@
/// has already been saved.
/// </summary>
/// <value>
- /// <see cref="String.Empty">String.Empty</see>
+ /// <see cref="string.Empty">String.Empty</see>
/// </value>
public static readonly object ShortCircuitIndicator = new object();
@@ -156,22 +155,22 @@
/// </summary>
static IdentifierGeneratorFactory()
{
- idgenerators.Add("uuid.hex", typeof(UUIDHexGenerator));
- idgenerators.Add("uuid.string", typeof(UUIDStringGenerator));
- idgenerators.Add("hilo", typeof(TableHiLoGenerator));
- idgenerators.Add("assigned", typeof(Assigned));
- idgenerators.Add("counter", typeof(CounterGenerator));
- idgenerators.Add("identity", typeof(IdentityGenerator));
- idgenerators.Add("increment", typeof(IncrementGenerator));
- idgenerators.Add("sequence", typeof(SequenceGenerator));
- idgenerators.Add("seqhilo", typeof(SequenceHiLoGenerator));
- idgenerators.Add("vm", typeof(CounterGenerator));
- idgenerators.Add("foreign", typeof(ForeignGenerator));
- idgenerators.Add("guid", typeof(GuidGenerator));
- idgenerators.Add("guid.comb", typeof(GuidCombGenerator));
- idgenerators.Add("guid.native", typeof(NativeGuidGenerator));
- idgenerators.Add("select", typeof(SelectGenerator));
- idgenerators.Add("sequence-identity", typeof(SequenceIdentityGenerator));
+ idgenerators.Add("uuid.hex", typeof (UUIDHexGenerator));
+ idgenerators.Add("uuid.string", typeof (UUIDStringGenerator));
+ idgenerators.Add("hilo", typeof (TableHiLoGenerator));
+ idgenerators.Add("assigned", typeof (Assigned));
+ idgenerators.Add("counter", typeof (CounterGenerator));
+ idgenerators.Add("increment", typeof (IncrementGenerator));
+ idgenerators.Add("sequence", typeof (SequenceGenerator));
+ idgenerators.Add("seqhilo", typeof (SequenceHiLoGenerator));
+ idgenerators.Add("vm", typeof (CounterGenerator));
+ idgenerators.Add("foreign", typeof (ForeignGenerator));
+ idgenerators.Add("guid", typeof (GuidGenerator));
+ idgenerators.Add("guid.comb", typeof (GuidCombGenerator));
+ idgenerators.Add("guid.native", typeof (NativeGuidGenerator));
+ idgenerators.Add("select", typeof (SelectGenerator));
+ idgenerators.Add("sequence-identity", typeof (SequenceIdentityGenerator));
+ idgenerators.Add("trigger-identity", typeof (TriggerIdentityGenerator));
}
private IdentifierGeneratorFactory()
@@ -196,15 +195,18 @@
/// <exception cref="MappingException">
/// Thrown if there are any exceptions while creating the <see cref="IIdentifierGenerator"/>.
/// </exception>
- public static IIdentifierGenerator Create(string strategy, IType type, IDictionary<string, string> parms, Dialect.Dialect dialect)
+ public static IIdentifierGenerator Create(string strategy, IType type, IDictionary<string, string> parms,
+ Dialect.Dialect dialect)
{
try
{
System.Type clazz = GetIdentifierGeneratorClass(strategy, dialect);
- IIdentifierGenerator idgen = (IIdentifierGenerator)Activator.CreateInstance(clazz);
- IConfigurable conf = idgen as IConfigurable;
+ var idgen = (IIdentifierGenerator) Activator.CreateInstance(clazz);
+ var conf = idgen as IConfigurable;
if (conf != null)
+ {
conf.Configure(type, parms, dialect);
+ }
return idgen;
}
catch (IdentifierGenerationException)
@@ -226,47 +228,47 @@
/// The identifier value converted to the <see cref="System.Type"/>.
/// </returns>
/// <exception cref="IdentifierGenerationException">
- /// The <c>type</c> parameter must be an <see cref="Int16"/>, <see cref="Int32"/>,
- /// or <see cref="Int64"/>.
+ /// The <c>type</c> parameter must be an <see cref="short"/>, <see cref="int"/>,
+ /// or <see cref="long"/>.
/// </exception>
public static object CreateNumber(long value, System.Type type)
{
// Convert.ChangeType would be better here, but it fails if the value does not fit
// in the destination type, while we need the value to be truncated in this case.
- if (type == typeof(byte))
+ if (type == typeof (byte))
{
return (byte) value;
}
- else if (type == typeof(sbyte))
+ else if (type == typeof (sbyte))
{
return (sbyte) value;
}
- else if (type == typeof(short))
+ else if (type == typeof (short))
{
return (short) value;
}
- else if (type == typeof(ushort))
+ else if (type == typeof (ushort))
{
return (ushort) value;
}
- else if (type == typeof(int))
+ else if (type == typeof (int))
{
return (int) value;
}
- else if (type == typeof(uint))
+ else if (type == typeof (uint))
{
return (uint) value;
}
- else if (type == typeof(long))
+ else if (type == typeof (long))
{
return value;
}
- else if (type == typeof(ulong))
+ else if (type == typeof (ulong))
{
return (ulong) value;
}
- else if (type == typeof(decimal))
+ else if (type == typeof (decimal))
{
return (decimal) value;
}
@@ -286,13 +288,24 @@
public static System.Type GetIdentifierGeneratorClass(string strategy, Dialect.Dialect dialect)
{
System.Type clazz;
- idgenerators.TryGetValue(strategy, out clazz);
if ("native".Equals(strategy))
+ {
clazz = dialect.NativeIdentifierGeneratorClass;
+ }
+ else if ("identity".Equals(strategy))
+ {
+ clazz = dialect.IdentityStyleIdentifierGeneratorClass;
+ }
+ else
+ {
+ idgenerators.TryGetValue(strategy, out clazz);
+ }
try
{
if (clazz == null)
+ {
clazz = ReflectHelper.ClassForName(strategy);
+ }
}
catch (Exception)
{
Added: trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,18 @@
+using NHibernate.Engine;
+using NHibernate.Id.Insert;
+
+namespace NHibernate.Id
+{
+ public class TriggerIdentityGenerator : AbstractPostInsertGenerator
+ {
+ #region Overrides of AbstractPostInsertGenerator
+
+ public override IInsertGeneratedIdentifierDelegate GetInsertGeneratedIdentifierDelegate(
+ IPostInsertIdentityPersister persister, ISessionFactoryImplementor factory, bool isGetGeneratedKeysEnabled)
+ {
+ return new OutputParamReturningDelegate(persister, factory);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-06 20:28:16 UTC (rev 4062)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-07 04:24:29 UTC (rev 4063)
@@ -464,6 +464,7 @@
<Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" />
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
+ <Compile Include="Id\TriggerIdentityGenerator.cs" />
<Compile Include="Id\Insert\NoCommentsInsert.cs" />
<Compile Include="Id\Insert\ReturningIdentifierInsert.cs" />
<Compile Include="Id\Insert\OutputParamReturningDelegate.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/GeneratedIdentityFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/GeneratedIdentityFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/GeneratedIdentityFixture.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,41 @@
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.Generatedkeys.ByTrigger
+{
+ [TestFixture]
+ public class GeneratedIdentityFixture : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "Generatedkeys.ByTrigger.MyEntity.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is Dialect.Oracle8iDialect;
+ }
+
+ [Test]
+ public void GetGeneratedKeysSupport()
+ {
+ ISession session = OpenSession();
+ session.BeginTransaction();
+
+ var e = new MyEntity { Name = "entity-1" };
+ session.Save(e);
+
+ // this insert should happen immediately!
+ Assert.AreEqual(1, e.Id, "id not generated through forced insertion");
+
+ session.Delete(e);
+ session.Transaction.Commit();
+ session.Close();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,9 @@
+namespace NHibernate.Test.Generatedkeys.ByTrigger
+{
+ public class MyEntity
+ {
+ public virtual int Id { get; private set; }
+
+ public virtual string Name { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/ByTrigger/MyEntity.hbm.xml 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Generatedkeys.ByTrigger"
+ default-access="backfield">
+
+ <class name="MyEntity" table="my_entity">
+ <id name="Id">
+ <generator class="trigger-identity"/>
+ </id>
+ <property name="Name"/>
+ </class>
+
+ <database-object>
+ <create>
+ <![CDATA[CREATE SEQUENCE NH_SEQ START WITH 1 CACHE 20]]>
+ </create>
+ <drop>
+ <![CDATA[DROP SEQUENCE NH_SEQ]]>
+ </drop>
+ <dialect-scope name="NHibernate.Dialect.Oracle8iDialect"/>
+ <dialect-scope name="NHibernate.Dialect.Oracle9iDialect"/>
+ <dialect-scope name="NHibernate.Dialect.Oracle10gDialect"/>
+ </database-object>
+
+ <database-object>
+ <create>
+ <![CDATA[CREATE OR REPLACE TRIGGER T_BI_my_entity
+ BEFORE INSERT ON my_entity
+ FOR EACH ROW
+ BEGIN
+ select NH_SEQ.nextval into :new.ID from DUAL;
+ END;]]>
+ </create>
+ <drop>
+ <![CDATA[DROP TRIGGER T_BI_my_entity]]>
+ </drop>
+ <dialect-scope name="NHibernate.Dialect.Oracle8iDialect"/>
+ <dialect-scope name="NHibernate.Dialect.Oracle9iDialect"/>
+ <dialect-scope name="NHibernate.Dialect.Oracle10gDialect"/>
+ </database-object>
+
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,19 @@
+namespace NHibernate.Test.Generatedkeys.Identity
+{
+ public class MyEntityIdentity
+ {
+ private int id;
+ private string name;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Generatedkeys.Identity"
+ default-access="field">
+
+ <class name="MyEntityIdentity" table="my_entity">
+ <id name="id">
+ <generator class="identity"/>
+ </id>
+ <natural-id>
+ <property name="name"/>
+ </natural-id>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/SimpleIdentityGeneratedFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/SimpleIdentityGeneratedFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/SimpleIdentityGeneratedFixture.cs 2009-02-07 04:24:29 UTC (rev 4063)
@@ -0,0 +1,39 @@
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.Generatedkeys.Identity
+{
+ [TestFixture]
+ public class SimpleIdentityGeneratedFixture : TestCase
+ {
+ // This test is to check the support of identity generator
+ // NH should choose one of the identity-style generation where the Dialect are supporting one of them
+ // as identity, sequence-identity (identity.sequence), generated (identity.sequence)
+ protected override IList Mappings
+ {
+ get { return new[] { "Generatedkeys.Identity.MyEntityIdentity.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ [Test]
+ public void SequenceIdentityGenerator()
+ {
+ ISession session = OpenSession();
+ session.BeginTransaction();
+
+ var e = new MyEntityIdentity { Name = "entity-1" };
+ session.Save(e);
+
+ // this insert should happen immediately!
+ Assert.AreEqual(1, e.Id, "id not generated through forced insertion");
+
+ session.Delete(e);
+ session.Transaction.Commit();
+ session.Close();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-06 20:28:16 UTC (rev 4062)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 04:24:29 UTC (rev 4063)
@@ -244,10 +244,14 @@
<Compile Include="FilterTest\Product.cs" />
<Compile Include="FilterTest\Salesperson.cs" />
<Compile Include="FilterTest\TestClass.cs" />
+ <Compile Include="Generatedkeys\ByTrigger\GeneratedIdentityFixture.cs" />
+ <Compile Include="Generatedkeys\ByTrigger\MyEntity.cs" />
<Compile Include="Generatedkeys\Identity\IdentityGeneratedKeysTest.cs" />
<Compile Include="Generatedkeys\Identity\MyChild.cs" />
<Compile Include="Generatedkeys\Identity\MyEntity.cs" />
+ <Compile Include="Generatedkeys\Identity\MyEntityIdentity.cs" />
<Compile Include="Generatedkeys\Identity\MySibling.cs" />
+ <Compile Include="Generatedkeys\Identity\SimpleIdentityGeneratedFixture.cs" />
<Compile Include="Generatedkeys\Select\MyEntity.cs" />
<Compile Include="Generatedkeys\Select\SelectGeneratorTest.cs" />
<Compile Include="Generatedkeys\Seqidentity\MyEntity.cs" />
@@ -1645,6 +1649,8 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="Generatedkeys\ByTrigger\MyEntity.hbm.xml" />
+ <EmbeddedResource Include="Generatedkeys\Identity\MyEntityIdentity.hbm.xml" />
<EmbeddedResource Include="SessionFactoryTest\Item.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1289\Mappings.hbm.xml" />
<EmbeddedResource Include="TypesTest\TimeSpanClass.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-07 05:00:02
|
Revision: 4065
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4065&view=rev
Author: fabiomaulo
Date: 2009-02-07 04:59:58 +0000 (Sat, 07 Feb 2009)
Log Message:
-----------
Fix NH-1660
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs
Added: trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs 2009-02-07 04:59:58 UTC (rev 4065)
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+
+namespace NHibernate
+{
+ public class EntityModeEqualityComparer : IEqualityComparer<EntityMode>
+ {
+ public bool Equals(EntityMode x, EntityMode y)
+ {
+ return x == y;
+ }
+
+ public int GetHashCode(EntityMode obj)
+ {
+ return (int) obj;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-07 04:34:49 UTC (rev 4064)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-07 04:59:58 UTC (rev 4065)
@@ -460,6 +460,7 @@
<Compile Include="Dialect\SybaseASA9Dialect.cs" />
<Compile Include="Driver\IfxDriver.cs" />
<Compile Include="Driver\OracleLiteDataClientDriver.cs" />
+ <Compile Include="EntityModeEqualityComparer.cs" />
<Compile Include="Event\IDestructible.cs" />
<Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" />
<Compile Include="Exceptions\SqlStateExtracter.cs" />
Modified: trunk/nhibernate/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs 2009-02-07 04:34:49 UTC (rev 4064)
+++ trunk/nhibernate/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs 2009-02-07 04:59:58 UTC (rev 4065)
@@ -8,8 +8,9 @@
[Serializable]
public abstract class EntityModeToTuplizerMapping
{
- // map of EntityMode -> Tuplizer
- private readonly IDictionary<EntityMode, ITuplizer> tuplizers = new LinkedHashMap<EntityMode, ITuplizer>();
+ // NH-1660
+ private readonly IDictionary<EntityMode, ITuplizer> tuplizers
+ = new LinkedHashMap<EntityMode, ITuplizer>(5, new EntityModeEqualityComparer());
protected internal void AddTuplizer(EntityMode entityMode, ITuplizer tuplizer)
{
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs 2009-02-07 04:59:58 UTC (rev 4065)
@@ -0,0 +1,93 @@
+using System;
+using System.Diagnostics;
+using NHibernate.Tuple;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.EntityModeToTuplizerPerf
+{
+ [TestFixture]
+ public class Fixture
+ {
+ private TargetClazz target;
+
+ [SetUp]
+ public void Setup()
+ {
+ target = new TargetClazz();
+ }
+
+ [Test]
+ public void VerifyEntityModeNotFound()
+ {
+ Assert.IsNull(target.GetTuplizerOrNull(EntityMode.Xml));
+ }
+
+ [Test]
+ public void VerifyEntityModeFound()
+ {
+ ITuplizer tuplizer = new TuplizerStub();
+ target.Add(EntityMode.Map, tuplizer);
+ Assert.AreSame(tuplizer, target.GetTuplizerOrNull(EntityMode.Map));
+ }
+
+ [Test, Explicit("To the commiter - run before and after")]
+ public void RemoveThisTest_JustToShowPerfDifference()
+ {
+ const int loop = 1000000;
+ target.Add(EntityMode.Map, new TuplizerStub());
+ target.Add(EntityMode.Poco, new TuplizerStub());
+ target.Add(EntityMode.Xml, new TuplizerStub());
+
+ var watch = new Stopwatch();
+ watch.Start();
+ for (int i = 0; i < loop; i++)
+ {
+ target.GetTuplizerOrNull(EntityMode.Map);
+ target.GetTuplizerOrNull(EntityMode.Poco);
+ }
+ watch.Stop();
+ Console.WriteLine(watch.ElapsedMilliseconds);
+ }
+
+ private class TargetClazz : EntityModeToTuplizerMapping
+ {
+ public void Add(EntityMode eMode, ITuplizer tuplizer)
+ {
+ AddTuplizer(eMode, tuplizer);
+ }
+ }
+
+ private class TuplizerStub : ITuplizer
+ {
+ public System.Type MappedClass
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public object[] GetPropertyValues(object entity)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetPropertyValues(object entity, object[] values)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object GetPropertyValue(object entity, int i)
+ {
+ throw new NotImplementedException();
+ }
+
+ public object Instantiate()
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool IsInstance(object obj)
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 04:34:49 UTC (rev 4064)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 04:59:58 UTC (rev 4065)
@@ -394,6 +394,7 @@
<Compile Include="NHSpecificTest\Dates\FixtureBase.cs" />
<Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
<Compile Include="NHSpecificTest\Dates\DateTimeAssert.cs" />
+ <Compile Include="NHSpecificTest\EntityModeToTuplizerPerf\Fixture.cs" />
<Compile Include="NHSpecificTest\FileStreamSql2008\VendorCatalog.cs" />
<Compile Include="NHSpecificTest\FileStreamSql2008\Fixture.cs" />
<Compile Include="NHSpecificTest\FileStreamSql2008\Convert.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-07 16:44:12
|
Revision: 4066
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4066&view=rev
Author: fabiomaulo
Date: 2009-02-07 16:44:07 +0000 (Sat, 07 Feb 2009)
Log Message:
-----------
Fix NH-1665
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs
trunk/nhibernate/src/NHibernate/Util/StringHelper.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/MyEntity.cs
Modified: trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs 2009-02-07 04:59:58 UTC (rev 4065)
+++ trunk/nhibernate/src/NHibernate/Id/SequenceGenerator.cs 2009-02-07 16:44:07 UTC (rev 4066)
@@ -68,7 +68,10 @@
/// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param>
public virtual void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect dialect)
{
- sequenceName = PropertiesHelper.GetString(Sequence, parms, "hibernate_sequence");
+ var nativeSequenceName = PropertiesHelper.GetString(Sequence, parms, "hibernate_sequence");
+ nativeSequenceName = StringHelper.Unqualify(nativeSequenceName);
+ nativeSequenceName = StringHelper.PurgeBackticksEnclosing(nativeSequenceName);
+ sequenceName = dialect.QuoteForTableName(nativeSequenceName);
string schemaName;
string catalogName;
parms.TryGetValue(Parameters, out parameters);
Modified: trunk/nhibernate/src/NHibernate/Util/StringHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2009-02-07 04:59:58 UTC (rev 4065)
+++ trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2009-02-07 16:44:07 UTC (rev 4066)
@@ -708,5 +708,19 @@
{
return str == null ? null : str.ToLowerInvariant();
}
+
+ public static bool IsBackticksEnclosed(string identifier)
+ {
+ return !string.IsNullOrEmpty(identifier) && identifier.StartsWith("`") && identifier.EndsWith("`");
+ }
+
+ public static string PurgeBackticksEnclosing(string identifier)
+ {
+ if (IsBackticksEnclosed(identifier))
+ {
+ return identifier.Substring(1, identifier.Length - 2);
+ }
+ return identifier;
+ }
}
}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Fixture.cs 2009-02-07 16:44:07 UTC (rev 4066)
@@ -0,0 +1,28 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1665
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect.SupportsSequences;
+ }
+
+ [Test]
+ public void SupportsHibernateQuotingSequenceName()
+ {
+ ISession session = OpenSession();
+ session.BeginTransaction();
+
+ var e = new MyEntity { Name = "entity-1" };
+ session.Save(e);
+ Assert.AreEqual(1, (int)session.GetIdentifier(e));
+
+ session.Delete(e);
+ session.Transaction.Commit();
+ session.Close();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/Mappings.hbm.xml 2009-02-07 16:44:07 UTC (rev 4066)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1665"
+ default-access="backfield">
+
+ <class name="MyEntity">
+ <id type="int">
+ <generator class="sequence">
+ <param name="sequence">`Emp_Seq`</param>
+ </generator>
+ </id>
+ <property name="Name"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/MyEntity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/MyEntity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/MyEntity.cs 2009-02-07 16:44:07 UTC (rev 4066)
@@ -0,0 +1,7 @@
+namespace NHibernate.Test.NHSpecificTest.NH1665
+{
+ public class MyEntity
+ {
+ public virtual string Name { 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-02-07 04:59:58 UTC (rev 4065)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 16:44:07 UTC (rev 4066)
@@ -414,6 +414,8 @@
<Compile Include="NHSpecificTest\NH1289\PurchaseItem.cs" />
<Compile Include="NHSpecificTest\NH1289\PurchaseOrder.cs" />
<Compile Include="NHSpecificTest\NH1289\WorkflowItem.cs" />
+ <Compile Include="NHSpecificTest\NH1665\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1665\MyEntity.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1521\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1549\CategoryWithInheritedId.cs" />
@@ -1650,6 +1652,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1665\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\ByTrigger\MyEntity.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Identity\MyEntityIdentity.hbm.xml" />
<EmbeddedResource Include="SessionFactoryTest\Item.hbm.xml" />
Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs 2009-02-07 04:59:58 UTC (rev 4065)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs 2009-02-07 16:44:07 UTC (rev 4066)
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using NHibernate.Util;
using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
namespace NHibernate.Test.UtilityTest
{
@@ -120,5 +121,22 @@
Assert.AreEqual(expected, StringHelper.GetClassname(typeName));
}
+ [Test]
+ public void IsBackticksEnclosed()
+ {
+ Assert.That(!StringHelper.IsBackticksEnclosed(null));
+ Assert.That(!StringHelper.IsBackticksEnclosed("`something"));
+ Assert.That(!StringHelper.IsBackticksEnclosed("something`"));
+ Assert.That(StringHelper.IsBackticksEnclosed("`something`"));
+ }
+
+ [Test]
+ public void PurgeBackticksEnclosing()
+ {
+ Assert.That(StringHelper.PurgeBackticksEnclosing(null), Is.Null);
+ Assert.That(StringHelper.PurgeBackticksEnclosing("`something"), Is.EqualTo("`something"));
+ Assert.That(StringHelper.PurgeBackticksEnclosing("something`"), Is.EqualTo("something`"));
+ Assert.That(StringHelper.PurgeBackticksEnclosing("`something`"), Is.EqualTo("something"));
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2009-02-08 19:50:48
|
Revision: 4074
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4074&view=rev
Author: davybrion
Date: 2009-02-08 19:50:43 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
Added some tests for custom SQL and stored procedures with MySQL
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-02-08 16:11:27 UTC (rev 4073)
+++ trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-02-08 19:50:43 UTC (rev 4074)
@@ -2,7 +2,7 @@
namespace NHibernate.Dialect
{
- internal class MySQL5Dialect : MySQLDialect
+ public class MySQL5Dialect : MySQLDialect
{
//Reference 5.x
//Numeric:
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 16:11:27 UTC (rev 4073)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 19:50:43 UTC (rev 4074)
@@ -933,6 +933,7 @@
<Compile Include="SessionFactoryTest\SessionFactorySerializationFixture.cs" />
<Compile Include="SqlTest\Custom\CustomSQLSupportTest.cs" />
<Compile Include="SqlTest\Custom\CustomStoredProcSupportTest.cs" />
+ <Compile Include="SqlTest\Custom\MySQL\MySQLTest.cs" />
<Compile Include="SqlTest\Custom\Oracle\OracleCustomSQLFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" />
@@ -1656,6 +1657,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="SqlTest\Custom\MySQL\MySQLEmployment.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\Oracle\Mappings.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\Oracle\StoredProcedures.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1619\Mappings.hbm.xml" />
Copied: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLEmployment.hbm.xml (from rev 4072, trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLEmployment.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLEmployment.hbm.xml 2009-02-08 19:50:43 UTC (rev 4074)
@@ -0,0 +1,217 @@
+<?xml version="1.0"?>
+<!--
+
+ This mapping demonstrates the use of Hibernate with
+ all-handwritten SQL!
+
+ This version is for Sybase/mssql
+-->
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.SqlTest"
+ default-access="field.camelcase">
+
+ <class name="Organization" table="ORGANIZATION">
+ <id name="Id" unsaved-value="0" column="ORGID">
+ <generator class="increment"/>
+ </id>
+ <property name="Name" not-null="true" column="NAME"/>
+ <set name="Employments"
+ inverse="true"
+ order-by="DUMMY">
+ <key column="EMPLOYER"/>
+ <!-- only needed for DDL generation -->
+ <one-to-many class="Employment"/>
+ <loader query-ref="organizationEmployments"/>
+ </set>
+ <!-- query-list name="currentEmployments"
+ query-ref="organizationCurrentEmployments"-->
+ <loader query-ref="organization"/>
+ <sql-insert>INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE ORGANIZATION SET NAME=UPPER(?) WHERE ORGID=?</sql-update>
+ <sql-delete>DELETE FROM ORGANIZATION WHERE ORGID=?</sql-delete>
+ </class>
+
+ <class name="Person" table="PERSON">
+ <id name="Id" unsaved-value="0" column="PERID">
+ <generator class="increment"/>
+ </id>
+ <property name="Name" not-null="true" column="NAME"/>
+ <loader query-ref="person"/>
+ <sql-insert>INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update>
+ <sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete>
+ </class>
+
+ <class name="Employment" table="EMPLOYMENT">
+ <id name="employmentId" unsaved-value="0" column="EMPID">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="Employee" column="EMPLOYEE" not-null="true" update="false"/>
+ <many-to-one name="Employer" column="EMPLOYER" not-null="true" update="false"/>
+ <property name="StartDate" column="STARTDATE" not-null="true" update="false" insert="false"/>
+ <property name="EndDate" column="ENDDATE" insert="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test"/>
+ <property name="RegionCode" column="REGIONCODE" update="false"/>
+ <property name="Salary" type="NHibernate.Test.SqlTest.MonetaryAmountUserType, NHibernate.Test">
+ <column name="VALUE" sql-type="float"/>
+ <column name="CURRENCY"/>
+ </property>
+ <loader query-ref="employment"/>
+ <sql-insert>
+ INSERT INTO EMPLOYMENT
+ (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID)
+ VALUES (?, ?, now(), UPPER(?), ?, ?, ?)
+ </sql-insert>
+ <sql-update>UPDATE EMPLOYMENT SET ENDDATE=?, VALUE=?, CURRENCY=? WHERE EMPID=?</sql-update>
+ <sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
+ </class>
+
+ <resultset name="org-emp-regionCode">
+ <return-scalar column="regionCode" type="string"/>
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ </resultset>
+
+ <resultset name="org-emp-person">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ <return-join alias="pers" property="emp.Employee"/>
+ </resultset>
+
+ <sql-query name="person">
+ <return alias="p" class="Person" lock-mode="upgrade"/>
+ SELECT NAME AS {p.Name}, PERID AS {p.Id} FROM PERSON WHERE PERID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ SELECT {org.*}, {emp.*}
+ FROM ORGANIZATION org
+ LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
+ WHERE org.ORGID=?
+ </sql-query>
+
+
+ <!--sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ SELECT NAME AS {org.name}, ORGID AS {org.id} FROM ORGANIZATION
+ WHERE ORGID=?
+ </sql-query-->
+
+ <sql-query name="allOrganizationsWithEmployees">
+ <!-- TODO H3: add flush-mode="never" -->
+ <return alias="org" class="Organization"/>
+ SELECT DISTINCT org.NAME AS {org.Name}, org.ORGID AS {org.Id}
+ FROM ORGANIZATION org
+ INNER JOIN EMPLOYMENT e ON e.EMPLOYER = org.ORGID
+ </sql-query>
+
+ <sql-query name="employment">
+ <return alias="emp" class="Employment"/>
+ SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer},
+ STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate},
+ REGIONCODE as {emp.RegionCode}, EMPID AS {emp.employmentId}
+ FROM EMPLOYMENT
+ WHERE EMPID = ?
+ </sql-query>
+
+ <sql-query name="organizationEmployments">
+ <load-collection alias="empcol" role="Organization.Employments"/>
+ SELECT {empcol.*}
+ FROM EMPLOYMENT empcol
+ WHERE EMPLOYER = :id
+ ORDER BY STARTDATE ASC, EMPLOYEE ASC
+ </sql-query>
+
+
+ <sql-query name="organizationCurrentEmployments">
+ <return alias="emp" class="Employment">
+ <return-property name="Salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ <!-- Here we are remapping endDate. Notice that we can still use {emp.EndDate} in the SQL. -->
+ <return-property name="EndDate" column="myEndDate"/>
+ </return>
+ <synchronize table="EMPLOYMENT"/>
+ SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer},
+ STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate},
+ REGIONCODE as {emp.RegionCode}, EMPID AS {emp.employmentId}, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ WHERE EMPLOYER = :id AND ENDDATE IS NULL
+ ORDER BY STARTDATE ASC
+ </sql-query>
+
+ <sql-query name="simpleScalar">
+ <return-scalar column="name" type="string"/>
+ <return-scalar column="value" type="long"/>
+ call simpleScalar(:number)
+ </sql-query>
+
+ <sql-query name="paramhandling">
+ <return-scalar column="value" type="long"/>
+ <return-scalar column="value2" type="long"/>
+ call paramHandling(?,?)
+ </sql-query>
+
+ <sql-query name="paramhandling_mixed">
+ <return-scalar column="value" type="long" />
+ <return-scalar column="value2" type="long" />
+ call paramHandling(?,:second)
+ </sql-query>
+
+ <sql-query name="selectAllEmployments">
+ <return class="Employment">
+ <return-property name="Employee" column="EMPLOYEE"/>
+ <return-property name="Employer" column="EMPLOYER"/>
+ <return-property name="StartDate" column="STARTDATE"/>
+ <return-property name="EndDate" column="ENDDATE"/>
+ <return-property name="RegionCode" column="REGIONCODE"/>
+ <return-property name="id" column="EMPID"/>
+ <return-property name="Salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ </return>
+ call selectAllEmployments()
+ </sql-query>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE selectAllEmployments ()
+ SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE,
+ REGIONCODE, EMPID, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ </create>
+ <drop>
+ DROP PROCEDURE selectAllEmployments
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE paramHandling (j int, i int)
+ SELECT j AS value, i AS value2
+ </create>
+ <drop>
+ DROP PROCEDURE paramHandling
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE simpleScalar (number int)
+ SELECT number AS value, 'getAll' AS name
+ </create>
+ <drop>
+ DROP PROCEDURE simpleScalar
+ </drop>
+ </database-object>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs 2009-02-08 19:50:43 UTC (rev 4074)
@@ -0,0 +1,20 @@
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.SqlTest.Custom.MySQL
+{
+ [TestFixture]
+ public class MySQLTest : CustomStoredProcSupportTest
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "SqlTest.Custom.MySQL.MySQLEmployment.hbm.xml" }; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MySQL5Dialect || dialect is MySQLDialect;
+ }
+ }
+}
\ 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-02-20 19:48:13
|
Revision: 4089
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4089&view=rev
Author: fabiomaulo
Date: 2009-02-20 19:48:11 +0000 (Fri, 20 Feb 2009)
Log Message:
-----------
Fix NH-1679
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs
trunk/nhibernate/src/NHibernate/Criterion/PropertyProjection.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1679/Fixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Criterion/IPropertyProjection.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2009-02-19 09:55:56 UTC (rev 4088)
+++ trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2009-02-20 19:48:11 UTC (rev 4089)
@@ -101,11 +101,13 @@
params object[] values)
{
List<TypedValue> types = new List<TypedValue>();
- if (projection == null)
+ var propertyProjection = projection as IPropertyProjection;
+ if (projection == null || propertyProjection != null)
{
+ var pn = propertyProjection != null ? propertyProjection.PropertyName : propertyName;
foreach (object value in values)
{
- TypedValue typedValue = criteriaQuery.GetTypedValue(criteria, propertyName, value);
+ TypedValue typedValue = criteriaQuery.GetTypedValue(criteria, pn, value);
types.Add(typedValue);
}
}
Added: trunk/nhibernate/src/NHibernate/Criterion/IPropertyProjection.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/IPropertyProjection.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Criterion/IPropertyProjection.cs 2009-02-20 19:48:11 UTC (rev 4089)
@@ -0,0 +1,7 @@
+namespace NHibernate.Criterion
+{
+ public interface IPropertyProjection
+ {
+ string PropertyName { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Criterion/PropertyProjection.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/PropertyProjection.cs 2009-02-19 09:55:56 UTC (rev 4088)
+++ trunk/nhibernate/src/NHibernate/Criterion/PropertyProjection.cs 2009-02-20 19:48:11 UTC (rev 4089)
@@ -10,7 +10,7 @@
/// A property value, or grouped property value
/// </summary>
[Serializable]
- public class PropertyProjection : SimpleProjection
+ public class PropertyProjection : SimpleProjection, IPropertyProjection
{
private string propertyName;
private bool grouped;
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-19 09:55:56 UTC (rev 4088)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-20 19:48:11 UTC (rev 4089)
@@ -447,6 +447,7 @@
<Compile Include="Bytecode\HibernateByteCodeException.cs" />
<Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" />
<Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" />
+ <Compile Include="Criterion\IPropertyProjection.cs" />
<Compile Include="Dialect\MsSql2008Dialect.cs" />
<Compile Include="Dialect\InformixDialect0940.cs" />
<Compile Include="Dialect\InformixDialect1000.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1679/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1679/Fixture.cs 2009-02-19 09:55:56 UTC (rev 4088)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1679/Fixture.cs 2009-02-20 19:48:11 UTC (rev 4089)
@@ -10,13 +10,13 @@
[Test]
public void UsingExpression()
{
- TestAction(criteria => { criteria.Add(Expression.Eq("alias.BooleanData", true)); });
+ TestAction(criteria => criteria.Add(Restrictions.Eq("alias.BooleanData", true)));
}
- [Test,Ignore]
+ [Test]
public void UsingExpressionProjection()
{
- TestAction(criteria => { criteria.Add(Expression.Eq(Projections.Property("alias.BooleanData"), true)); });
+ TestAction(criteria => criteria.Add(Restrictions.Eq(Projections.Property("alias.BooleanData"), true)));
}
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-02-21 03:05:30
|
Revision: 4091
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4091&view=rev
Author: fabiomaulo
Date: 2009-02-21 03:05:27 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Fix NH-1677
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-02-20 20:18:28 UTC (rev 4090)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-02-21 03:05:27 UTC (rev 4091)
@@ -583,26 +583,37 @@
public string[] GetImplementors(string className)
{
System.Type clazz = null;
- // NH Different implementation: we have better performance checking, first of all, if we know the class
- // and take the System.Type directly from the persister (className have high probability to be entityName)
- IEntityPersister checkPersister;
- if (entityPersisters.TryGetValue(className, out checkPersister))
- {
- clazz = checkPersister.GetMappedClass(EntityMode.Poco);
- }
- if (clazz == null)
+ // NH Different implementation for performance: a class without at least a namespace sure can't be found by reflection
+ if (className.IndexOf('.') > 0)
{
- try
+ IEntityPersister checkPersister;
+ // NH Different implementation: we have better performance checking, first of all, if we know the class
+ // and take the System.Type directly from the persister (className have high probability to be entityName)
+ if (entityPersisters.TryGetValue(className, out checkPersister))
{
- clazz = ReflectHelper.ClassForFullName(className);
+ // NH : take care with this because we are forcing the Poco EntityMode
+ clazz = checkPersister.GetMappedClass(EntityMode.Poco);
}
- catch (Exception)
+
+ if (clazz == null)
{
- return new string[] {className}; //for a dynamic-class
+ try
+ {
+ clazz = ReflectHelper.ClassForFullName(className);
+ }
+ catch (Exception)
+ {
+ clazz = null;
+ }
}
}
+ if (clazz == null)
+ {
+ return new[] {className}; //for a dynamic-class
+ }
+
List<string> results = new List<string>();
foreach (IEntityPersister p in entityPersisters.Values)
{
Modified: trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs 2009-02-20 20:18:28 UTC (rev 4090)
+++ trunk/nhibernate/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs 2009-02-21 03:05:27 UTC (rev 4091)
@@ -3,6 +3,7 @@
using NHibernate.Cfg;
using NHibernate.Engine;
using NUnit.Framework;
+using NHibernate.Criterion;
namespace NHibernate.Test.EntityModeTest.Map.Basic
{
@@ -24,13 +25,30 @@
configuration.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(EntityMode.Map));
}
+ public delegate IDictionary SingleCarQueryDelegate(ISession session);
+ public delegate IList AllModelQueryDelegate(ISession session);
+
[Test]
- public void TestLazyDynamicClass()
+ public void ShouldWorkWithHQL()
{
+ TestLazyDynamicClass(s => (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult(),
+ s => s.CreateQuery("from Model m").List());
+ }
+
+ [Test]
+ public void ShouldWorkWithCriteria()
+ {
+ TestLazyDynamicClass(
+ s => (IDictionary) s.CreateCriteria("ProductLine").AddOrder(Order.Asc("Description")).UniqueResult(),
+ s => s.CreateCriteria("Model").List());
+ }
+
+ public void TestLazyDynamicClass(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler)
+ {
ITransaction t;
- using(ISession s = OpenSession())
+ using (ISession s = OpenSession())
{
- ISessionImplementor si = (ISessionImplementor) s;
+ var si = (ISessionImplementor)s;
Assert.IsTrue(si.EntityMode == EntityMode.Map, "Incorrectly handled default_entity_mode");
ISession other = s.GetSession(EntityMode.Poco);
other.Close();
@@ -55,9 +73,7 @@
hsv["Name"] = "hsv";
hsv["Description"] = "Holden hsv";
- models = new List<IDictionary>();
- models.Add(monaro);
- models.Add(hsv);
+ models = new List<IDictionary> {monaro, hsv};
cars["Models"] = models;
@@ -68,19 +84,19 @@
using (ISession s = OpenSession())
{
t = s.BeginTransaction();
- cars = (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult();
- models = (IList) cars["Models"];
+ cars = singleCarQueryHandler(s);
+ models = (IList)cars["Models"];
Assert.IsFalse(NHibernateUtil.IsInitialized(models));
Assert.AreEqual(2, models.Count);
Assert.IsTrue(NHibernateUtil.IsInitialized(models));
s.Clear();
- IList list = s.CreateQuery("from Model m").List();
+ IList list = allModelQueryHandler(s);
foreach (IDictionary ht in list)
{
Assert.IsFalse(NHibernateUtil.IsInitialized(ht["ProductLine"]));
}
- IDictionary model = (IDictionary) list[0];
- Assert.IsTrue(((IList) ((IDictionary) model["ProductLine"])["Models"]).Contains(model));
+ var model = (IDictionary)list[0];
+ Assert.IsTrue(((IList)((IDictionary)model["ProductLine"])["Models"]).Contains(model));
s.Clear();
t.Commit();
@@ -89,7 +105,7 @@
using (ISession s = OpenSession())
{
t = s.BeginTransaction();
- cars = (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult();
+ cars = singleCarQueryHandler(s);
s.Delete(cars);
t.Commit();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-24 18:00:22
|
Revision: 4097
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4097&view=rev
Author: fabiomaulo
Date: 2009-02-24 18:00:18 +0000 (Tue, 24 Feb 2009)
Log Message:
-----------
Bug fix in SingletonEnumerable
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Util/SingletonEnumerable.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/UtilityTest/SingletonEnumerableFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Util/SingletonEnumerable.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/SingletonEnumerable.cs 2009-02-21 17:08:24 UTC (rev 4096)
+++ trunk/nhibernate/src/NHibernate/Util/SingletonEnumerable.cs 2009-02-24 18:00:18 UTC (rev 4097)
@@ -44,11 +44,7 @@
public T Current
{
- get
- {
- if (hasNext) hasNext = false;
- return current;
- }
+ get { return current; }
}
#endregion
@@ -65,7 +61,9 @@
public bool MoveNext()
{
- return hasNext;
+ var result = hasNext;
+ hasNext = false;
+ return result;
}
public void Reset()
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-21 17:08:24 UTC (rev 4096)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-24 18:00:18 UTC (rev 4097)
@@ -1100,6 +1100,7 @@
<Compile Include="UtilityTest\ReflectHelperFixture.cs" />
<Compile Include="UtilityTest\SafetyEnumerableFixture.cs" />
<Compile Include="UtilityTest\SequencedHashMapFixture.cs" />
+ <Compile Include="UtilityTest\SingletonEnumerableFixture.cs" />
<Compile Include="UtilityTest\StringHelperFixture.cs" />
<Compile Include="UtilityTest\StringTokenizerFixture.cs" />
<Compile Include="UtilityTest\ThreadSafeDictionaryFixture.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/UtilityTest/SingletonEnumerableFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/SingletonEnumerableFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/SingletonEnumerableFixture.cs 2009-02-24 18:00:18 UTC (rev 4097)
@@ -0,0 +1,50 @@
+using System.Collections;
+using NHibernate.Util;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.UtilityTest
+{
+ [TestFixture]
+ public class SingletonEnumerableFixture
+ {
+ [Test]
+ public void DifferentEnumeratorInEachRequest()
+ {
+ var obj = new object();
+ var se = new SingletonEnumerable<object>(obj);
+ Assert.That(!ReferenceEquals(se.GetEnumerator(), se.GetEnumerator()));
+
+ // with no generic enumerator
+ var see = (IEnumerable) se;
+ Assert.That(!ReferenceEquals(see.GetEnumerator(), see.GetEnumerator()));
+ }
+
+ [Test]
+ public void ShouldWorkInForeach()
+ {
+ var obj = new object();
+ var se = new SingletonEnumerable<object>(obj);
+ int i=0;
+ foreach (var o in se)
+ {
+ i++;
+ }
+ Assert.That(i, Is.EqualTo(1));
+ }
+
+ [Test]
+ public void ShouldWorkAsEnumerator()
+ {
+ var obj = new object();
+ var se = new SingletonEnumerable<object>(obj);
+ var enu = se.GetEnumerator();
+ int i = 0;
+ while (enu.MoveNext())
+ {
+ i++;
+ }
+ Assert.That(i, Is.EqualTo(1));
+ }
+ }
+}
\ 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: <te...@us...> - 2009-02-28 19:31:59
|
Revision: 4100
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4100&view=rev
Author: tehlike
Date: 2009-02-28 19:31:56 +0000 (Sat, 28 Feb 2009)
Log Message:
-----------
Fixing problem with accessing Entity method when access strategy is field-camelcase. Fix for NH-1689
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/DomainClass.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/SampleTest.cs
Modified: trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs 2009-02-24 19:34:25 UTC (rev 4099)
+++ trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs 2009-02-28 19:31:56 UTC (rev 4100)
@@ -92,7 +92,7 @@
{
return IdentityEqualityComparer.Equals(args[0], proxy);
}
- else if (method.Equals(setIdentifierMethod))
+ else if (setIdentifierMethod!=null&&method.Equals(setIdentifierMethod))
{
Initialize();
Identifier = args[0];
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/DomainClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/DomainClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/DomainClass.cs 2009-02-28 19:31:56 UTC (rev 4100)
@@ -0,0 +1,22 @@
+
+
+namespace NHibernate.Test.NHSpecificTest.NH1689
+{
+ using System.Collections.Generic;
+
+ public class DomainClass
+ {
+ private int id;
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual IList<TargetType> GetListOfTargetType<TargetType>(string someArg)
+ {
+ return new List<TargetType>();
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/Mappings.hbm.xml 2009-02-28 19:31:56 UTC (rev 4100)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1689" default-access="field.camelcase">
+ <class name="DomainClass">
+ <id name="Id">
+ <generator class="assigned" />
+ </id>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/SampleTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/SampleTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1689/SampleTest.cs 2009-02-28 19:31:56 UTC (rev 4100)
@@ -0,0 +1,47 @@
+namespace NHibernate.Test.NHSpecificTest.NH1689
+{
+ using System.Collections.Generic;
+ using Dialect;
+ using NUnit.Framework;
+
+ [TestFixture,Ignore]
+ public class SampleTest : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ base.OnSetUp();
+ using (ISession session = this.OpenSession())
+ {
+ DomainClass entity = new DomainClass();
+ entity.Id = 1;
+ session.Save(entity);
+ session.Flush();
+ session.Evict(entity);
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ base.OnTearDown();
+ using (ISession session = this.OpenSession())
+ {
+ string hql = "from System.Object";
+ session.Delete(hql);
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void ShouldBeAbleToCallGenericMethod()
+ {
+ using (ISession session = this.OpenSession())
+ {
+ DomainClass entity = session.Load<DomainClass>(1);
+
+ IList<string> inputStrings = entity.GetListOfTargetType<string>("arg");
+ Assert.That(inputStrings.Count == 0);
+ }
+ }
+ }
+
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-24 19:34:25 UTC (rev 4099)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-28 19:31:56 UTC (rev 4100)
@@ -632,6 +632,8 @@
<Compile Include="NHSpecificTest\NH1677\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1679\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH1679\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1689\DomainClass.cs" />
+ <Compile Include="NHSpecificTest\NH1689\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1666,6 +1668,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1689\Mappings.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\SimpleVersioned.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1675\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1677\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-03-01 14:23:33
|
Revision: 4102
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4102&view=rev
Author: fabiomaulo
Date: 2009-03-01 14:23:27 +0000 (Sun, 01 Mar 2009)
Log Message:
-----------
Fix NH-1691
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-02-28 19:42:24 UTC (rev 4101)
+++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-03-01 14:23:27 UTC (rev 4102)
@@ -1446,7 +1446,7 @@
if (type.IsComponentType)
{
- // NH-1612: Recursively add column aliases for nested components to support the selection
+ // NH-1612+NH-1691: Recursively add column aliases for nested components to support the selection
// of individual component properties in native SQL queries. This also seems to provide
// a more complete solution to HHH-1019 (http://opensource.atlassian.com/projects/hibernate/browse/HHH-1019)
// because it works for <load-collection> and <return-join>.
@@ -1458,10 +1458,10 @@
{
string name = propertyNames[propertyIndex];
IType propertyType = ct.Subtypes[propertyIndex];
- int propertyColSpan = propertyType.IsComponentType
- ? ((IAbstractComponentType) propertyType).PropertyNames.Length
- : 1;
+ int propertyColSpan = 0;
+ CalcPropertyColumnSpan(propertyType, ref propertyColSpan);
+
var propertyColumnAliases = new string[propertyColSpan];
var propertyColumnNames = new string[propertyColSpan];
System.Array.Copy(columnAliases, columnIndex, propertyColumnAliases, 0, propertyColSpan);
@@ -1473,6 +1473,22 @@
}
}
+ private static void CalcPropertyColumnSpan(IType propertyType, ref int count)
+ {
+ if (!propertyType.IsComponentType)
+ {
+ count++;
+ }
+ else
+ {
+ var componentType = (IAbstractComponentType) propertyType;
+ foreach (var subtype in componentType.Subtypes)
+ {
+ CalcPropertyColumnSpan(subtype, ref count);
+ }
+ }
+ }
+
public int GetSize(object key, ISessionImplementor session)
{
try
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Domain.cs 2009-03-01 14:23:27 UTC (rev 4102)
@@ -0,0 +1,35 @@
+using System.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH1691
+{
+ public class SubComponent
+ {
+ public string SubName { get; set; }
+ public string SubName1 { get; set; }
+ public SubComponent Nested { get; set; }
+ }
+
+ public class Component
+ {
+ public string Name { get; set; }
+ public SubComponent SubComponent { get; set; }
+ }
+
+ public class DeepComponent
+ {
+ public string Prop1 { get; set; }
+ public string Prop2 { get; set; }
+ public string Prop3 { get; set; }
+ public string Prop4 { get; set; }
+ public Component Component { get; set; }
+ }
+
+ public class Nest
+ {
+ public virtual Component Component { get; set; }
+ public virtual int Id { get; set; }
+ public string Name { get; set; }
+ public virtual IList Components { get; set; }
+ public virtual IList ComplexComponents { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs 2009-03-01 14:23:27 UTC (rev 4102)
@@ -0,0 +1,115 @@
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1691
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ private static Component GetInitializedComponent()
+ {
+ var component = new Component();
+ var sub1 = new SubComponent();
+ var sub2 = new SubComponent();
+ component.Name = "Comp1";
+ sub1.SubName = "Sub1";
+ sub1.SubName1 = "Sub1x";
+
+ sub2.SubName = "Sub2";
+ sub2.SubName1 = "Sub2x";
+
+ sub1.Nested = sub2;
+
+ component.SubComponent = sub1;
+ return component;
+ }
+
+ [Test]
+ public void ComplexNest()
+ {
+ Component comp1 = GetInitializedComponent();
+ var nest = new Nest {Name = "NAME", Components = new ArrayList {comp1}};
+ var deep1 = new DeepComponent {Prop1 = "PROP1", Prop2 = "PROP2", Prop3 = "PROP3", Prop4 = "PROP4"};
+ Component innerComp = GetInitializedComponent();
+ deep1.Component = innerComp;
+ Component innerComp2 = GetInitializedComponent();
+ var deep2 = new DeepComponent
+ {Prop1 = "PROP1", Prop2 = "PROP2", Prop3 = "PROP3", Prop4 = "PROP4", Component = innerComp2};
+
+ nest.ComplexComponents = new ArrayList {deep1, deep2};
+
+ object nestId;
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ session.Save(nest);
+ transaction.Commit();
+ nestId = nest.Id;
+ }
+ }
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ var loadedNest = session.Load<Nest>(nestId);
+ transaction.Commit();
+
+ Assert.AreEqual(2, loadedNest.ComplexComponents.Count);
+ Assert.IsNotNull(((DeepComponent) loadedNest.ComplexComponents[0]).Component.SubComponent.Nested.SubName1);
+ Assert.IsNull(((DeepComponent) loadedNest.ComplexComponents[0]).Component.SubComponent.SubName1);
+ }
+ }
+
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Delete("from Nest");
+ t.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void NestedComponentCollection()
+ {
+ var nest = new Nest {Name = "NAME"};
+ Component comp1 = GetInitializedComponent();
+
+ nest.Components = new ArrayList {comp1};
+
+ object nestId;
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ session.Save(nest);
+ transaction.Commit();
+ nestId = nest.Id;
+ }
+ }
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ var nest2 = session.Load<Nest>(nestId);
+ transaction.Commit();
+
+ Assert.IsNotNull(((Component) nest2.Components[0]).SubComponent.Nested.SubName);
+ }
+ }
+
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Delete("from Nest");
+ t.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Mappings.hbm.xml 2009-03-01 14:23:27 UTC (rev 4102)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1691"
+ assembly="NHibernate.Test"
+ default-lazy="false">
+ <class name="Nest">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <bag name="Components"
+ access="property"
+ table="Nest_Components"
+ cascade="all-delete-orphan"
+ lazy="false">
+ <key column="NestId"/>
+ <composite-element class="Component">
+ <property name="Name" column="Component_Name" />
+ <nested-composite-element name="SubComponent" access="property" class="SubComponent">
+ <property name="SubName" column="Component_SubComponent_SubName" />
+ <property name="SubName1" column="Component_SubComponent_SubName1" />
+ <nested-composite-element name="Nested" access="property" class="SubComponent">
+ <property name="SubName" column="Component_SubComponent_Nested_SubName" />
+ <property name="SubName1" column="Component_SubComponent_Nested_SubName1" />
+ </nested-composite-element>
+ </nested-composite-element>
+ </composite-element>
+ </bag>
+
+ <bag name="ComplexComponents"
+ access="property"
+ table="Nest_DeepComponents"
+ cascade="all-delete-orphan"
+ lazy="false">
+ <key column="NestId"/>
+ <composite-element class="DeepComponent">
+ <property name="Prop1" column="DeepComponent_Prop1" />
+ <property name="Prop2" column="DeepComponent_Prop2" />
+ <property name="Prop3" column="DeepComponent_Prop3" />
+ <property name="Prop4" column="DeepComponent_Prop4" />
+ <nested-composite-element name="Component" class="Component">
+ <property name="Name" column="Component_Name" />
+ <nested-composite-element name="SubComponent" access="property" class="SubComponent">
+ <property name="SubName" column="Component_SubComponent_SubName" />
+ <nested-composite-element name="Nested" access="property" class="SubComponent">
+ <property name="SubName" column="Component_SubComponent_Nested_SubName" />
+ <property name="SubName1" column="Component_SubComponent_Nested_SubName1" />
+ </nested-composite-element>
+ </nested-composite-element>
+ </nested-composite-element>
+
+ </composite-element>
+ </bag>
+
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-28 19:42:24 UTC (rev 4101)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-01 14:23:27 UTC (rev 4102)
@@ -634,6 +634,8 @@
<Compile Include="NHSpecificTest\NH1679\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1689\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH1689\SampleTest.cs" />
+ <Compile Include="NHSpecificTest\NH1691\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1691\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1668,6 +1670,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1691\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1689\Mappings.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\SimpleVersioned.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1675\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-03-02 19:46:46
|
Revision: 4104
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4104&view=rev
Author: tehlike
Date: 2009-03-02 19:46:38 +0000 (Mon, 02 Mar 2009)
Log Message:
-----------
Fixing a bug with one-to-many subclass. Fix for NH-1391
Some simplicifactions using automatic properties.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Company.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Product.cs
Modified: trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-03-01 23:14:40 UTC (rev 4103)
+++ trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -44,7 +44,7 @@
SqlString orderByString, string groupByString, SqlString havingString, LockMode lockMode)
{
WalkEntityTree(persister, Alias);
- Persisters = new ILoadable[0];
+ this.Persisters = new ILoadable[0];
InitStatementString(projectionString, whereString, orderByString, groupByString, havingString, lockMode);
}
@@ -57,12 +57,12 @@
SqlString orderBy,string groupBy, SqlString having, LockMode lockMode)
{
int joins = CountEntityPersisters(associations);
- Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
+ this.Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
JoinFragment ojf = MergeOuterJoins(associations);
SqlString selectClause = projection
??
- new SqlString(persister.SelectFragment(alias, Suffixes[joins]) + SelectString(associations));
+ new SqlString(persister.SelectFragment(alias, this.Suffixes[joins]) + SelectString(associations));
SqlSelectBuilder select = new SqlSelectBuilder(Factory)
.SetLockMode(lockMode)
Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs 2009-03-01 23:14:40 UTC (rev 4103)
+++ trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -40,8 +40,8 @@
{
int joins = CountEntityPersisters(associations);
int collectionJoins = CountCollectionPersisters(associations) + 1;
- Suffixes = BasicLoader.GenerateSuffixes(joins);
- CollectionSuffixes = BasicLoader.GenerateSuffixes(joins, collectionJoins);
+ this.Suffixes = BasicLoader.GenerateSuffixes(joins);
+ this.CollectionSuffixes = BasicLoader.GenerateSuffixes(joins, collectionJoins);
SqlStringBuilder whereString = WhereString(alias, collectionPersister.KeyColumnNames, subquery, batchSize);
@@ -72,7 +72,7 @@
SqlSelectBuilder select =
new SqlSelectBuilder(Factory)
- .SetSelectClause(collectionPersister.SelectFragment(alias, CollectionSuffixes[0])
+ .SetSelectClause(collectionPersister.SelectFragment(alias, this.CollectionSuffixes[0])
+ SelectString(associations))
.SetFromClause(collectionPersister.TableName, alias)
.SetWhereClause(whereString.ToSqlString())
Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs 2009-03-01 23:14:40 UTC (rev 4103)
+++ trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -45,26 +45,29 @@
private void InitStatementString(IOuterJoinLoadable elementPersister, string alias, int batchSize, SqlString subquery)
{
int joins = CountEntityPersisters(associations);
- Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
+ this.Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
int collectionJoins = CountCollectionPersisters(associations) + 1;
- CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collectionJoins);
+ this.CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collectionJoins);
SqlStringBuilder whereString = WhereString(alias, oneToManyPersister.KeyColumnNames, subquery, batchSize);
+
string filter = oneToManyPersister.FilterFragment(alias, EnabledFilters);
whereString.Insert(0, StringHelper.MoveAndToBeginning(filter));
-
+ whereString.Add(elementPersister.FilterFragment(alias, new CollectionHelper.EmptyMapClass<string, IFilter>()));
JoinFragment ojf = MergeOuterJoins(associations);
SqlSelectBuilder select =
- new SqlSelectBuilder(Factory).SetSelectClause(
- oneToManyPersister.SelectFragment(null, null, alias, Suffixes[joins], CollectionSuffixes[0], true)
- + SelectString(associations)).SetFromClause(elementPersister.FromTableFragment(alias)
- + elementPersister.FromJoinFragment(alias, true, true)).SetWhereClause(
- whereString.ToSqlString()).SetOuterJoins(ojf.ToFromFragmentString,
- ojf.ToWhereFragmentString
- + elementPersister.WhereJoinFragment(alias, true, true));
+ new SqlSelectBuilder(Factory)
+ .SetSelectClause(
+ oneToManyPersister.SelectFragment(null, null, alias, this.Suffixes[joins], this.CollectionSuffixes[0], true)
+ + SelectString(associations))
+ .SetFromClause(elementPersister.FromTableFragment(alias)
+ + elementPersister.FromJoinFragment(alias, true, true))
+ .SetWhereClause(whereString.ToSqlString())
+ .SetOuterJoins(ojf.ToFromFragmentString,
+ ojf.ToWhereFragmentString + elementPersister.WhereJoinFragment(alias, true, true))
+ .SetOrderByClause(OrderBy(associations, oneToManyPersister.GetSQLOrderByString(alias)));
- select.SetOrderByClause(OrderBy(associations, oneToManyPersister.GetSQLOrderByString(alias)));
if (Factory.Settings.IsCommentsEnabled)
{
Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-03-01 23:14:40 UTC (rev 4103)
+++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -19,77 +19,26 @@
private readonly ISet<AssociationKey> visitedAssociationKeys = new HashedSet<AssociationKey>();
private readonly IDictionary<string, IFilter> enabledFilters;
- private string[] suffixes;
- private string[] collectionSuffixes;
- private ILoadable[] persisters;
- private int[] owners;
- private EntityType[] ownerAssociationTypes;
- private ICollectionPersister[] collectionPersisters;
- private int[] collectionOwners;
- private string[] aliases;
- private LockMode[] lockModeArray;
- private SqlString sql;
+ public string[] CollectionSuffixes { get; set; }
- public string[] CollectionSuffixes
- {
- get { return collectionSuffixes; }
- set { collectionSuffixes = value; }
- }
+ public LockMode[] LockModeArray { get; set; }
- public LockMode[] LockModeArray
- {
- get { return lockModeArray; }
- set { lockModeArray = value; }
- }
+ public string[] Suffixes { get; set; }
- public string[] Suffixes
- {
- get { return suffixes; }
- set { suffixes = value; }
- }
+ public string[] Aliases { get; set; }
- public string[] Aliases
- {
- get { return aliases; }
- set { aliases = value; }
- }
+ public int[] CollectionOwners { get; set; }
- public int[] CollectionOwners
- {
- get { return collectionOwners; }
- set { collectionOwners = value; }
- }
+ public ICollectionPersister[] CollectionPersisters { get; set; }
- public ICollectionPersister[] CollectionPersisters
- {
- get { return collectionPersisters; }
- set { collectionPersisters = value; }
- }
+ public EntityType[] OwnerAssociationTypes { get; set; }
- public EntityType[] OwnerAssociationTypes
- {
- get { return ownerAssociationTypes; }
- set { ownerAssociationTypes = value; }
- }
+ public int[] Owners { get; set; }
- public int[] Owners
- {
- get { return owners; }
- set { owners = value; }
- }
+ public ILoadable[] Persisters { get; set; }
- public ILoadable[] Persisters
- {
- get { return persisters; }
- set { persisters = value; }
- }
+ public SqlString SqlString { get; set; }
- public SqlString SqlString
- {
- get { return sql; }
- set { sql = value; }
- }
-
protected ISessionFactoryImplementor Factory
{
get { return factory; }
@@ -708,15 +657,15 @@
int joins = CountEntityPersisters(associations);
int collections = CountCollectionPersisters(associations);
- collectionOwners = collections == 0 ? null : new int[collections];
- collectionPersisters = collections == 0 ? null : new ICollectionPersister[collections];
- collectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collections);
+ this.CollectionOwners = collections == 0 ? null : new int[collections];
+ this.CollectionPersisters = collections == 0 ? null : new ICollectionPersister[collections];
+ this.CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collections);
- persisters = new ILoadable[joins];
- aliases = new String[joins];
- owners = new int[joins];
- ownerAssociationTypes = new EntityType[joins];
- lockModeArray = ArrayHelper.FillArray(lockMode, joins);
+ this.Persisters = new ILoadable[joins];
+ this.Aliases = new String[joins];
+ this.Owners = new int[joins];
+ this.OwnerAssociationTypes = new EntityType[joins];
+ this.LockModeArray = ArrayHelper.FillArray(lockMode, joins);
int i = 0;
int j = 0;
@@ -725,10 +674,10 @@
{
if (!oj.IsCollection)
{
- persisters[i] = (ILoadable)oj.Joinable;
- aliases[i] = oj.RHSAlias;
- owners[i] = oj.GetOwner(associations);
- ownerAssociationTypes[i] = (EntityType)oj.JoinableType;
+ this.Persisters[i] = (ILoadable)oj.Joinable;
+ this.Aliases[i] = oj.RHSAlias;
+ this.Owners[i] = oj.GetOwner(associations);
+ this.OwnerAssociationTypes[i] = (EntityType)oj.JoinableType;
i++;
}
else
@@ -738,25 +687,25 @@
if (oj.JoinType == JoinType.LeftOuterJoin)
{
//it must be a collection fetch
- collectionPersisters[j] = collPersister;
- collectionOwners[j] = oj.GetOwner(associations);
+ this.CollectionPersisters[j] = collPersister;
+ this.CollectionOwners[j] = oj.GetOwner(associations);
j++;
}
if (collPersister.IsOneToMany)
{
- persisters[i] = (ILoadable)collPersister.ElementPersister;
- aliases[i] = oj.RHSAlias;
+ this.Persisters[i] = (ILoadable)collPersister.ElementPersister;
+ this.Aliases[i] = oj.RHSAlias;
i++;
}
}
}
- if (ArrayHelper.IsAllNegative(owners))
- owners = null;
+ if (ArrayHelper.IsAllNegative(this.Owners))
+ this.Owners = null;
- if (collectionOwners != null && ArrayHelper.IsAllNegative(collectionOwners))
- collectionOwners = null;
+ if (this.CollectionOwners != null && ArrayHelper.IsAllNegative(this.CollectionOwners))
+ this.CollectionOwners = null;
}
/// <summary>
@@ -782,11 +731,11 @@
OuterJoinableAssociation next = (i == associations.Count - 1) ? null : associations[i + 1];
IJoinable joinable = join.Joinable;
- string entitySuffix = (suffixes == null || entityAliasCount >= suffixes.Length) ? null : suffixes[entityAliasCount];
+ string entitySuffix = (this.Suffixes == null || entityAliasCount >= this.Suffixes.Length) ? null : this.Suffixes[entityAliasCount];
- string collectionSuffix = (collectionSuffixes == null || collectionAliasCount >= collectionSuffixes.Length)
+ string collectionSuffix = (this.CollectionSuffixes == null || collectionAliasCount >= this.CollectionSuffixes.Length)
? null
- : collectionSuffixes[collectionAliasCount];
+ : this.CollectionSuffixes[collectionAliasCount];
string selectFragment =
joinable.SelectFragment(next == null ? null : next.Joinable, next == null ? null : next.RHSAlias, join.RHSAlias,
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Company.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Company.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Company.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1391
+{
+ public class Company
+ {
+ public virtual int Id { get; set; }
+ public virtual IList<ProductA> Products { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Fixture.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+namespace NHibernate.Test.NHSpecificTest.NH1391
+{
+ [TestFixture]
+ public class Fixture:BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using(var session=OpenSession())
+ using(var tran=session.BeginTransaction())
+ {
+ var producta = new ProductA {Name = "producta"};
+ var productb = new ProductB {Name = "productb"};
+ var company = new Company { Products = new List<ProductA>() };
+ company.Products.Add(producta);
+ producta.Company = company;
+ productb.Company = company;
+ session.Save(company);
+ session.Save(productb);
+ session.Save(producta);
+ tran.Commit();
+ }
+ }
+ protected override void OnTearDown()
+ {
+ using (var session = OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ session.Delete("from Product");
+ session.Delete("from Company");
+ tran.Commit();
+ }
+ }
+
+
+ [Test]
+ public void Can_discriminate_subclass_on_list_with_lazy_loading()
+ {
+ using (var session = OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ var company = session.Get<Company>(1);
+ Assert.That(company, Is.Not.Null);
+ Assert.That(company.Products, Has.Count(1));
+ Assert.That(company.Products[0], Is.AssignableFrom(typeof (ProductA)));
+ tran.Commit();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml 2009-03-02 19:46:38 UTC (rev 4104)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1391">
+
+ <class name="Product" discriminator-value="0">
+ <id name="Id" type="int">
+ <generator class="native"/>
+ </id>
+ <discriminator column="ProdType" type="int"/>
+ <property name="Name" type="string"/>
+ <many-to-one name="Company" column="CompanyId" not-null="true"/>
+ <subclass name="ProductA" discriminator-value="10"/>
+ <subclass name="ProductB" discriminator-value="20"/>
+ </class>
+ <class name="Company">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <bag name="Products" lazy="true"
+ inverse="true">
+ <key column="CompanyId" />
+ <one-to-many class="ProductA"/>
+ </bag>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Product.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Product.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/Product.cs 2009-03-02 19:46:38 UTC (rev 4104)
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1391
+{
+ public class Product
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual Company Company { get; set; }
+ }
+ public class ProductA:Product
+ {
+
+ }
+ public class ProductB:Product
+ {
+
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-01 23:14:40 UTC (rev 4103)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-02 19:46:38 UTC (rev 4104)
@@ -416,6 +416,9 @@
<Compile Include="NHSpecificTest\NH1289\PurchaseItem.cs" />
<Compile Include="NHSpecificTest\NH1289\PurchaseOrder.cs" />
<Compile Include="NHSpecificTest\NH1289\WorkflowItem.cs" />
+ <Compile Include="NHSpecificTest\NH1391\Company.cs" />
+ <Compile Include="NHSpecificTest\NH1391\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1391\Product.cs" />
<Compile Include="NHSpecificTest\NH1665\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1665\MyEntity.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
@@ -1670,6 +1673,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1391\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1691\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1689\Mappings.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\SimpleVersioned.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-03-03 07:06:26
|
Revision: 4105
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4105&view=rev
Author: tehlike
Date: 2009-03-03 07:06:19 +0000 (Tue, 03 Mar 2009)
Log Message:
-----------
Reverting rev 4104 for further investigation
Revision Links:
--------------
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4104&view=rev
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1391/
Property Changed:
----------------
trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs
trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithNothing.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1587/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/IdentityInsertWithStoredProcsTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/MSSQLIdentityInsertWithStoredProcs.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/MSSQLIdentityInsertWithStoredProcsTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/Item.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/Item.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/NativeSQLQueries.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/NativeSQLQueriesFixture.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/SelfReferencingCollectionLoadTest.cs
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/
trunk/nhibernate/src/NHibernate.Test/TypesTest/GenericEnumStringClass.hbm.xml
trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs
trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.cs
trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.hbm.xml
Property changes on: trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate/Id/TriggerIdentityGenerator.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Modified: trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
+++ trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-03-03 07:06:19 UTC (rev 4105)
@@ -44,7 +44,7 @@
SqlString orderByString, string groupByString, SqlString havingString, LockMode lockMode)
{
WalkEntityTree(persister, Alias);
- this.Persisters = new ILoadable[0];
+ Persisters = new ILoadable[0];
InitStatementString(projectionString, whereString, orderByString, groupByString, havingString, lockMode);
}
@@ -57,12 +57,12 @@
SqlString orderBy,string groupBy, SqlString having, LockMode lockMode)
{
int joins = CountEntityPersisters(associations);
- this.Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
+ Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
JoinFragment ojf = MergeOuterJoins(associations);
SqlString selectClause = projection
??
- new SqlString(persister.SelectFragment(alias, this.Suffixes[joins]) + SelectString(associations));
+ new SqlString(persister.SelectFragment(alias, Suffixes[joins]) + SelectString(associations));
SqlSelectBuilder select = new SqlSelectBuilder(Factory)
.SetLockMode(lockMode)
Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
+++ trunk/nhibernate/src/NHibernate/Loader/Collection/BasicCollectionJoinWalker.cs 2009-03-03 07:06:19 UTC (rev 4105)
@@ -40,8 +40,8 @@
{
int joins = CountEntityPersisters(associations);
int collectionJoins = CountCollectionPersisters(associations) + 1;
- this.Suffixes = BasicLoader.GenerateSuffixes(joins);
- this.CollectionSuffixes = BasicLoader.GenerateSuffixes(joins, collectionJoins);
+ Suffixes = BasicLoader.GenerateSuffixes(joins);
+ CollectionSuffixes = BasicLoader.GenerateSuffixes(joins, collectionJoins);
SqlStringBuilder whereString = WhereString(alias, collectionPersister.KeyColumnNames, subquery, batchSize);
@@ -72,7 +72,7 @@
SqlSelectBuilder select =
new SqlSelectBuilder(Factory)
- .SetSelectClause(collectionPersister.SelectFragment(alias, this.CollectionSuffixes[0])
+ .SetSelectClause(collectionPersister.SelectFragment(alias, CollectionSuffixes[0])
+ SelectString(associations))
.SetFromClause(collectionPersister.TableName, alias)
.SetWhereClause(whereString.ToSqlString())
Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
+++ trunk/nhibernate/src/NHibernate/Loader/Collection/OneToManyJoinWalker.cs 2009-03-03 07:06:19 UTC (rev 4105)
@@ -45,29 +45,26 @@
private void InitStatementString(IOuterJoinLoadable elementPersister, string alias, int batchSize, SqlString subquery)
{
int joins = CountEntityPersisters(associations);
- this.Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
+ Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
int collectionJoins = CountCollectionPersisters(associations) + 1;
- this.CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collectionJoins);
+ CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collectionJoins);
SqlStringBuilder whereString = WhereString(alias, oneToManyPersister.KeyColumnNames, subquery, batchSize);
-
string filter = oneToManyPersister.FilterFragment(alias, EnabledFilters);
whereString.Insert(0, StringHelper.MoveAndToBeginning(filter));
- whereString.Add(elementPersister.FilterFragment(alias, new CollectionHelper.EmptyMapClass<string, IFilter>()));
+
JoinFragment ojf = MergeOuterJoins(associations);
SqlSelectBuilder select =
- new SqlSelectBuilder(Factory)
- .SetSelectClause(
- oneToManyPersister.SelectFragment(null, null, alias, this.Suffixes[joins], this.CollectionSuffixes[0], true)
- + SelectString(associations))
- .SetFromClause(elementPersister.FromTableFragment(alias)
- + elementPersister.FromJoinFragment(alias, true, true))
- .SetWhereClause(whereString.ToSqlString())
- .SetOuterJoins(ojf.ToFromFragmentString,
- ojf.ToWhereFragmentString + elementPersister.WhereJoinFragment(alias, true, true))
- .SetOrderByClause(OrderBy(associations, oneToManyPersister.GetSQLOrderByString(alias)));
+ new SqlSelectBuilder(Factory).SetSelectClause(
+ oneToManyPersister.SelectFragment(null, null, alias, Suffixes[joins], CollectionSuffixes[0], true)
+ + SelectString(associations)).SetFromClause(elementPersister.FromTableFragment(alias)
+ + elementPersister.FromJoinFragment(alias, true, true)).SetWhereClause(
+ whereString.ToSqlString()).SetOuterJoins(ojf.ToFromFragmentString,
+ ojf.ToWhereFragmentString
+ + elementPersister.WhereJoinFragment(alias, true, true));
+ select.SetOrderByClause(OrderBy(associations, oneToManyPersister.GetSQLOrderByString(alias)));
if (Factory.Settings.IsCommentsEnabled)
{
Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-03-02 19:46:38 UTC (rev 4104)
+++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-03-03 07:06:19 UTC (rev 4105)
@@ -19,26 +19,77 @@
private readonly ISet<AssociationKey> visitedAssociationKeys = new HashedSet<AssociationKey>();
private readonly IDictionary<string, IFilter> enabledFilters;
- public string[] CollectionSuffixes { get; set; }
+ private string[] suffixes;
+ private string[] collectionSuffixes;
+ private ILoadable[] persisters;
+ private int[] owners;
+ private EntityType[] ownerAssociationTypes;
+ private ICollectionPersister[] collectionPersisters;
+ private int[] collectionOwners;
+ private string[] aliases;
+ private LockMode[] lockModeArray;
+ private SqlString sql;
- public LockMode[] LockModeArray { get; set; }
+ public string[] CollectionSuffixes
+ {
+ get { return collectionSuffixes; }
+ set { collectionSuffixes = value; }
+ }
- public string[] Suffixes { get; set; }
+ public LockMode[] LockModeArray
+ {
+ get { return lockModeArray; }
+ set { lockModeArray = value; }
+ }
- public string[] Aliases { get; set; }
+ public string[] Suffixes
+ {
+ get { return suffixes; }
+ set { suffixes = value; }
+ }
- public int[] CollectionOwners { get; set; }
+ public string[] Aliases
+ {
+ get { return aliases; }
+ set { aliases = value; }
+ }
- public ICollectionPersister[] CollectionPersisters { get; set; }
+ public int[] CollectionOwners
+ {
+ get { return collectionOwners; }
+ set { collectionOwners = value; }
+ }
- public EntityType[] OwnerAssociationTypes { get; set; }
+ public ICollectionPersister[] CollectionPersisters
+ {
+ get { return collectionPersisters; }
+ set { collectionPersisters = value; }
+ }
- public int[] Owners { get; set; }
+ public EntityType[] OwnerAssociationTypes
+ {
+ get { return ownerAssociationTypes; }
+ set { ownerAssociationTypes = value; }
+ }
- public ILoadable[] Persisters { get; set; }
+ public int[] Owners
+ {
+ get { return owners; }
+ set { owners = value; }
+ }
- public SqlString SqlString { get; set; }
+ public ILoadable[] Persisters
+ {
+ get { return persisters; }
+ set { persisters = value; }
+ }
+ public SqlString SqlString
+ {
+ get { return sql; }
+ set { sql = value; }
+ }
+
protected ISessionFactoryImplementor Factory
{
get { return factory; }
@@ -657,15 +708,15 @@
int joins = CountEntityPersisters(associations);
int collections = CountCollectionPersisters(associations);
- this.CollectionOwners = collections == 0 ? null : new int[collections];
- this.CollectionPersisters = collections == 0 ? null : new ICollectionPersister[collections];
- this.CollectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collections);
+ collectionOwners = collections == 0 ? null : new int[collections];
+ collectionPersisters = collections == 0 ? null : new ICollectionPersister[collections];
+ collectionSuffixes = BasicLoader.GenerateSuffixes(joins + 1, collections);
- this.Persisters = new ILoadable[joins];
- this.Aliases = new String[joins];
- this.Owners = new int[joins];
- this.OwnerAssociationTypes = new EntityType[joins];
- this.LockModeArray = ArrayHelper.FillArray(lockMode, joins);
+ persisters = new ILoadable[joins];
+ aliases = new String[joins];
+ owners = new int[joins];
+ ownerAssociationTypes = new EntityType[joins];
+ lockModeArray = ArrayHelper.FillArray(lockMode, joins);
int i = 0;
int j = 0;
@@ -674,10 +725,10 @@
{
if (!oj.IsCollection)
{
- this.Persisters[i] = (ILoadable)oj.Joinable;
- this.Aliases[i] = oj.RHSAlias;
- this.Owners[i] = oj.GetOwner(associations);
- this.OwnerAssociationTypes[i] = (EntityType)oj.JoinableType;
+ persisters[i] = (ILoadable)oj.Joinable;
+ aliases[i] = oj.RHSAlias;
+ owners[i] = oj.GetOwner(associations);
+ ownerAssociationTypes[i] = (EntityType)oj.JoinableType;
i++;
}
else
@@ -687,25 +738,25 @@
if (oj.JoinType == JoinType.LeftOuterJoin)
{
//it must be a collection fetch
- this.CollectionPersisters[j] = collPersister;
- this.CollectionOwners[j] = oj.GetOwner(associations);
+ collectionPersisters[j] = collPersister;
+ collectionOwners[j] = oj.GetOwner(associations);
j++;
}
if (collPersister.IsOneToMany)
{
- this.Persisters[i] = (ILoadable)collPersister.ElementPersister;
- this.Aliases[i] = oj.RHSAlias;
+ persisters[i] = (ILoadable)collPersister.ElementPersister;
+ aliases[i] = oj.RHSAlias;
i++;
}
}
}
- if (ArrayHelper.IsAllNegative(this.Owners))
- this.Owners = null;
+ if (ArrayHelper.IsAllNegative(owners))
+ owners = null;
- if (this.CollectionOwners != null && ArrayHelper.IsAllNegative(this.CollectionOwners))
- this.CollectionOwners = null;
+ if (collectionOwners != null && ArrayHelper.IsAllNegative(collectionOwners))
+ collectionOwners = null;
}
/// <summary>
@@ -731,11 +782,11 @@
OuterJoinableAssociation next = (i == associations.Count - 1) ? null : associations[i + 1];
IJoinable joinable = join.Joinable;
- string entitySuffix = (this.Suffixes == null || entityAliasCount >= this.Suffixes.Length) ? null : this.Suffixes[entityAliasCount];
+ string entitySuffix = (suffixes == null || entityAliasCount >= suffixes.Length) ? null : suffixes[entityAliasCount];
- string collectionSuffix = (this.CollectionSuffixes == null || collectionAliasCount >= this.CollectionSuffixes.Length)
+ string collectionSuffix = (collectionSuffixes == null || collectionAliasCount >= collectionSuffixes.Length)
? null
- : this.CollectionSuffixes[collectionAliasCount];
+ : collectionSuffixes[collectionAliasCount];
string selectFragment =
joinable.SelectFragment(next == null ? null : next.Joinable, next == null ? null : next.RHSAlias, join.RHSAlias,
Property changes on: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Identity/MyEntityIdentity.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithNothing.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1587/Mappings.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1665
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1691/Fixture.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-02 19:46:38 UTC (rev 4104)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-03 07:06:19 UTC (rev 4105)
@@ -416,9 +416,6 @@
<Compile Include="NHSpecificTest\NH1289\PurchaseItem.cs" />
<Compile Include="NHSpecificTest\NH1289\PurchaseOrder.cs" />
<Compile Include="NHSpecificTest\NH1289\WorkflowItem.cs" />
- <Compile Include="NHSpecificTest\NH1391\Company.cs" />
- <Compile Include="NHSpecificTest\NH1391\Fixture.cs" />
- <Compile Include="NHSpecificTest\NH1391\Product.cs" />
<Compile Include="NHSpecificTest\NH1665\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1665\MyEntity.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
@@ -1673,7 +1670,6 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
- <EmbeddedResource Include="NHSpecificTest\NH1391\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1691\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1689\Mappings.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\SimpleVersioned.hbm.xml" />
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLTest.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLEmployment.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/IdentityInsertWithStoredProcsTest.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/MSSQLIdentityInsertWithStoredProcs.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/MSSQLIdentityInsertWithStoredProcsTest.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/Item.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/Item.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/NativeSQLQueries.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/NativeSQLQueriesFixture.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/SelfReferencingCollectionLoadTest.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/TypesTest/GenericEnumStringClass.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.cs
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/SimpleVersioned.hbm.xml
___________________________________________________________________
Deleted: svn:mergeinfo
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-03-04 16:45:09
|
Revision: 4109
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4109&view=rev
Author: fabiomaulo
Date: 2009-03-04 16:45:01 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
Fix NH-1416
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.cs
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTagFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-03-04 04:39:58 UTC (rev 4108)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-03-04 16:45:01 UTC (rev 4109)
@@ -1075,6 +1075,12 @@
XmlAttribute lengthNode = node.Attributes["length"];
if (lengthNode != null)
model.Length = int.Parse(lengthNode.Value);
+ XmlAttribute scaleNode = node.Attributes["scale"];
+ if (scaleNode != null)
+ model.Scale = int.Parse(scaleNode.Value);
+ XmlAttribute precNode = node.Attributes["precision"];
+ if (precNode != null)
+ model.Precision = int.Parse(precNode.Value);
XmlAttribute nullNode = node.Attributes["not-null"];
model.IsNullable = (nullNode != null) ? !StringHelper.BooleanValue(nullNode.Value) : isNullable;
@@ -1087,6 +1093,9 @@
XmlAttribute typeNode = node.Attributes["sql-type"];
model.SqlType = (typeNode == null) ? null : typeNode.Value;
+
+ XmlAttribute defaAttribute = node.Attributes["default"];
+ model.DefaultValue = (defaAttribute == null) ? null : defaAttribute.Value;
}
protected static void BindIndex(XmlAttribute indexAttribute, Table table, Column column)
@@ -1292,11 +1301,18 @@
{
if (columnSchema.length != null)
column.Length = int.Parse(columnSchema.length);
+ if (columnSchema.scale != null)
+ column.Scale = int.Parse(columnSchema.scale);
+ if (columnSchema.precision != null)
+ column.Precision = int.Parse(columnSchema.precision);
column.IsNullable = columnSchema.notnullSpecified ? !columnSchema.notnull : isNullable;
column.IsUnique = columnSchema.uniqueSpecified && columnSchema.unique;
column.CheckConstraint = columnSchema.check ?? string.Empty;
column.SqlType = columnSchema.sqltype;
+ column.DefaultValue = columnSchema.@default;
+ if (columnSchema.comment != null)
+ column.Comment = string.Concat(columnSchema.comment.Text).Trim();
}
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-04 04:39:58 UTC (rev 4108)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-04 16:45:01 UTC (rev 4109)
@@ -944,6 +944,8 @@
<Compile Include="SqlTest\Custom\CustomStoredProcSupportTest.cs" />
<Compile Include="SqlTest\Custom\MySQL\MySQLTest.cs" />
<Compile Include="SqlTest\Custom\Oracle\OracleCustomSQLFixture.cs" />
+ <Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.cs" />
+ <Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTagFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" />
<Compile Include="SecondLevelCacheTest\AnotherItem.cs" />
@@ -1670,6 +1672,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1691\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1689\Mappings.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\SimpleVersioned.hbm.xml" />
Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.cs 2009-03-04 16:45:01 UTC (rev 4109)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.Tools.hbm2ddl.SchemaExportTests
+{
+ public class WithColumnTag
+ {
+ public string WithServerFuction { get; set; }
+ public int WithSimpleValue { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml 2009-03-04 16:45:01 UTC (rev 4109)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.Tools.hbm2ddl.SchemaExportTests"
+ assembly="NHibernate.Test">
+
+ <class name="WithColumnTag">
+ <id type="int"/>
+ <property name="WithServerFuction">
+ <column name="created_by" length="50" default="SYSTEM_USER"/>
+ </property>
+ <property name="WithSimpleValue">
+ <column name="my_value" default="77"/>
+ </property>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTagFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTagFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTagFixture.cs 2009-03-04 16:45:01 UTC (rev 4109)
@@ -0,0 +1,30 @@
+using System.IO;
+using System.Reflection;
+using System.Text;
+using NHibernate.Cfg;
+using NHibernate.Tool.hbm2ddl;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.Tools.hbm2ddl.SchemaExportTests
+{
+ [TestFixture]
+ public class WithColumnTagFixture
+ {
+ [Test]
+ public void ShouldCreateSchemaWithDefaultClause()
+ {
+ var script = new StringBuilder();
+ const string mapping = "NHibernate.Test.Tools.hbm2ddl.SchemaExportTests.WithColumnTag.hbm.xml";
+
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(mapping))
+ cfg.AddInputStream(stream);
+ new SchemaExport(cfg).Execute(s => script.AppendLine(s), false, false, false);
+
+ string wholeScript = script.ToString();
+ Assert.That(wholeScript, Text.Contains("default SYSTEM_USER"));
+ Assert.That(wholeScript, Text.Contains("default 77"));
+ }
+ }
+}
\ 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-03-04 18:47:07
|
Revision: 4110
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4110&view=rev
Author: fabiomaulo
Date: 2009-03-04 18:47:03 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
Fix of NH-1687 and NH-1685
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-03-04 16:45:01 UTC (rev 4109)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-03-04 18:47:03 UTC (rev 4110)
@@ -1297,8 +1297,10 @@
}
}
- protected static void BindColumn(HbmColumn columnSchema, Column column, bool isNullable)
+ protected void BindColumn(HbmColumn columnSchema, Column column, bool isNullable)
{
+ column.Name = mappings.NamingStrategy.ColumnName(columnSchema.name);
+
if (columnSchema.length != null)
column.Length = int.Parse(columnSchema.length);
if (columnSchema.scale != null)
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-03-04 16:45:01 UTC (rev 4109)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-03-04 18:47:03 UTC (rev 4110)
@@ -213,11 +213,9 @@
private void BindColumns(HbmVersion versionSchema, SimpleValue model, bool isNullable, string propertyPath)
{
Table table = model.Table;
-
if (versionSchema.column1 != null)
{
- Column col = new Column();
- col.Value = model;
+ var col = new Column {Value = model};
BindColumn(col, isNullable);
col.Name = mappings.NamingStrategy.ColumnName(versionSchema.column1);
@@ -226,11 +224,22 @@
model.AddColumn(col);
}
+ else if (versionSchema.column != null)
+ {
+ foreach (HbmColumn hbmColumn in versionSchema.column)
+ {
+ var col = new Column {Value = model};
+ BindColumn(hbmColumn, col, isNullable);
+ if (table != null)
+ table.AddColumn(col);
+ model.AddColumn(col);
+ }
+ }
+
if (model.ColumnSpan == 0)
{
- Column col = new Column();
- col.Value = model;
+ var col = new Column {Value = model};
BindColumn(col, isNullable);
col.Name = mappings.NamingStrategy.PropertyToColumnName(propertyPath);
model.Table.AddColumn(col);
Modified: trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs 2009-03-04 16:45:01 UTC (rev 4109)
+++ trunk/nhibernate/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs 2009-03-04 18:47:03 UTC (rev 4110)
@@ -7,7 +7,7 @@
{
// related issues NH-1687, NH-1685
- [TestFixture, Ignore("Not fixed yet.")]
+ [TestFixture]
public class GeneratedBinaryVersionFixture : TestCase
{
protected override IList Mappings
@@ -28,6 +28,8 @@
[Test]
public void ShouldRetrieveVersionAfterFlush()
{
+ // Note : if you are using identity-style strategy the value of version
+ // is available inmediately after save.
var e = new SimpleVersioned {Something = "something"};
using (ISession s = OpenSession())
{
@@ -42,5 +44,78 @@
}
}
}
+
+ [Test]
+ public void ShouldChangeAfterUpdate()
+ {
+ object savedId = PersistANewSomething();
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var fetched = s.Get<SimpleVersioned>(savedId);
+ var freshVersion = fetched.LastModified;
+ fetched.Something = "make it dirty";
+ s.Update(fetched);
+ s.Flush(); // force flush to hit DB
+ Assert.That(fetched.LastModified, Is.Not.SameAs(freshVersion));
+ s.Delete(fetched);
+ tx.Commit();
+ }
+ }
+ }
+
+ private object PersistANewSomething()
+ {
+ object savedId;
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var e = new SimpleVersioned {Something = "something"};
+ savedId = s.Save(e);
+ tx.Commit();
+ }
+ }
+ return savedId;
+ }
+
+ [Test]
+ public void ShouldCheckStaleState()
+ {
+ var versioned = new SimpleVersioned {Something = "original string"};
+
+ try
+ {
+ using (ISession session = OpenSession())
+ {
+ session.Save(versioned);
+ session.Flush();
+
+ using (ISession concurrentSession = OpenSession())
+ {
+ var sameVersioned = concurrentSession.Get<SimpleVersioned>(versioned.Id);
+ sameVersioned.Something = "another string";
+ concurrentSession.Flush();
+ }
+
+ versioned.Something = "new string";
+ session.Flush();
+ }
+ Assert.Fail("Expected exception was not thrown");
+ }
+ catch (StaleObjectStateException)
+ {
+ // as expected
+ }
+ finally
+ {
+ using (ISession session = OpenSession())
+ {
+ session.Delete("from SimpleVersioned");
+ session.Flush();
+ }
+ }
+ }
}
}
\ 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-03-04 21:13:54
|
Revision: 4112
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4112&view=rev
Author: fabiomaulo
Date: 2009-03-04 21:13:53 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
Reverted target fw to .NET2.0
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Property Changed:
----------------
trunk/nhibernate/src/NHibernate/
Property changes on: trunk/nhibernate/src/NHibernate
___________________________________________________________________
Modified: svn:ignore
- obj
.#*
*.user
*.xsx
AssemblyInfo.cs
*.aps
*.eto
[Bb]in
[Dd]ebug
[Rr]elease
+ obj
.#*
*.user
*.xsx
AssemblyInfo.cs
*.aps
*.eto
[Bb]in
[Dd]ebug
[Rr]elease
*resharper*
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-04 19:34:04 UTC (rev 4111)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-04 21:13:53 UTC (rev 4112)
@@ -14,7 +14,9 @@
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <TargetFrameworkSubset>
+ </TargetFrameworkSubset>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -51,9 +53,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Transactions" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2009-03-06 11:54:16
|
Revision: 4118
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4118&view=rev
Author: davybrion
Date: 2009-03-06 11:54:11 +0000 (Fri, 06 Mar 2009)
Log Message:
-----------
applying patch from Ivan Goryaev for NH-1695
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Dialect/Schema/MySQLMetaData.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs 2009-03-05 13:06:45 UTC (rev 4117)
+++ trunk/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs 2009-03-06 11:54:11 UTC (rev 4118)
@@ -1,6 +1,8 @@
using System;
using System.Data;
+using System.Data.Common;
using System.Text;
+using NHibernate.Dialect.Schema;
using NHibernate.SqlCommand;
using NHibernate.Util;
using Environment=NHibernate.Cfg.Environment;
@@ -158,6 +160,11 @@
get { return true; }
}
+ public override IDataBaseSchema GetDataBaseSchema(DbConnection connection)
+ {
+ return new MySQLDataBaseSchema(connection);
+ }
+
public override bool SupportsSubSelects
{
get { return false; }
Modified: trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs 2009-03-05 13:06:45 UTC (rev 4117)
+++ trunk/nhibernate/src/NHibernate/Dialect/Schema/AbstractDataBaseSchema.cs 2009-03-06 11:54:11 UTC (rev 4118)
@@ -87,9 +87,14 @@
public virtual DataTable GetForeignKeys(string catalog, string schema, string table)
{
var restrictions = new[] {catalog, schema, table, null};
- return connection.GetSchema("ForeignKeys", restrictions);
+ return connection.GetSchema(ForeignKeysSchemaName, restrictions);
}
+ protected virtual string ForeignKeysSchemaName
+ {
+ get { return "ForeignKeys"; }
+ }
+
#endregion
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Dialect/Schema/MySQLMetaData.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Schema/MySQLMetaData.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/Schema/MySQLMetaData.cs 2009-03-06 11:54:11 UTC (rev 4118)
@@ -0,0 +1,108 @@
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace NHibernate.Dialect.Schema
+{
+ public class MySQLDataBaseSchema : AbstractDataBaseSchema
+ {
+ public MySQLDataBaseSchema(DbConnection connection) : base(connection)
+ {
+ }
+
+ public override ITableMetadata GetTableMetadata(DataRow rs, bool extras)
+ {
+ return new MySQLTableMetadata(rs, this, extras);
+ }
+
+ protected override string ForeignKeysSchemaName
+ {
+ get { return "Foreign Keys"; }
+ }
+ }
+
+ public class MySQLTableMetadata : AbstractTableMetadata
+ {
+ public MySQLTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras)
+ {
+ }
+
+ protected override void ParseTableInfo(DataRow rs)
+ {
+ Catalog = Convert.ToString(rs["TABLE_CATALOG"]);
+ Schema = Convert.ToString(rs["TABLE_SCHEMA"]);
+ if (string.IsNullOrEmpty(Catalog)) Catalog = null;
+ if (string.IsNullOrEmpty(Schema)) Schema = null;
+ Name = Convert.ToString(rs["TABLE_NAME"]);
+ }
+
+ protected override string GetConstraintName(DataRow rs)
+ {
+ return Convert.ToString(rs["CONSTRAINT_NAME"]);
+ }
+
+ protected override string GetColumnName(DataRow rs)
+ {
+ return Convert.ToString(rs["COLUMN_NAME"]);
+ }
+
+ protected override string GetIndexName(DataRow rs)
+ {
+ return Convert.ToString(rs["INDEX_NAME"]);
+ }
+
+ protected override IColumnMetadata GetColumnMetadata(DataRow rs)
+ {
+ return new MySQLColumnMetadata(rs);
+ }
+
+ protected override IForeignKeyMetadata GetForeignKeyMetadata(DataRow rs)
+ {
+ return new MySQLForeignKeyMetadata(rs);
+ }
+
+ protected override IIndexMetadata GetIndexMetadata(DataRow rs)
+ {
+ return new MySQLIndexMetadata(rs);
+ }
+ }
+
+ public class MySQLColumnMetadata : AbstractColumnMetaData
+ {
+ public MySQLColumnMetadata(DataRow rs)
+ : base(rs)
+ {
+ Name = Convert.ToString(rs["COLUMN_NAME"]);
+ object aValue;
+
+ aValue = rs["CHARACTER_MAXIMUM_LENGTH"];
+ if (aValue != DBNull.Value)
+ ColumnSize = Convert.ToInt32(aValue);
+
+ aValue = rs["NUMERIC_PRECISION"];
+ if (aValue != DBNull.Value)
+ NumericalPrecision = Convert.ToInt32(aValue);
+
+ Nullable = Convert.ToString(rs["IS_NULLABLE"]);
+ TypeName = Convert.ToString(rs["DATA_TYPE"]);
+ }
+ }
+
+ public class MySQLIndexMetadata : AbstractIndexMetadata
+ {
+ public MySQLIndexMetadata(DataRow rs)
+ : base(rs)
+ {
+ Name = Convert.ToString(rs["INDEX_NAME"]);
+ }
+ }
+
+ public class MySQLForeignKeyMetadata : AbstractForeignKeyMetadata
+ {
+ public MySQLForeignKeyMetadata(DataRow rs)
+ : base(rs)
+ {
+ Name = Convert.ToString(rs["CONSTRAINT_NAME"]);
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-05 13:06:45 UTC (rev 4117)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-06 11:54:11 UTC (rev 4118)
@@ -454,6 +454,7 @@
<Compile Include="Dialect\Oracle8iDialect.cs" />
<Compile Include="Dialect\Oracle9iDialect.cs" />
<Compile Include="Dialect\OracleLiteDialect.cs" />
+ <Compile Include="Dialect\Schema\MySQLMetaData.cs" />
<Compile Include="Dialect\Schema\SQLiteMetaData.cs" />
<Compile Include="Dialect\Schema\SybaseAnywhereMetaData.cs" />
<Compile Include="Dialect\SybaseASA10Dialect.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-03-10 17:54:07
|
Revision: 4121
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4121&view=rev
Author: tehlike
Date: 2009-03-10 17:54:00 +0000 (Tue, 10 Mar 2009)
Log Message:
-----------
Marking SqlFunctions serializable. This is necessary for making Configuration serializable as it is possible to add custom sql functions.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiExtractFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiSubstringFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/CharIndexFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAggregateFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAvgFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicCountFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicSumFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/CommonGrammar.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/NoArgSQLFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/NvlFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/PositionSubstringFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/SQLFunctionTemplate.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSQLFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSafeSQLFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/VarArgsSQLFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/DialectTest/FunctionTests/
trunk/nhibernate/src/NHibernate.Test/DialectTest/FunctionTests/SerializableTypesFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -1952,7 +1952,7 @@
#endregion
#region Agregate function redefinition
-
+ [Serializable]
protected class CountQueryFunctionInfo : ClassicAggregateFunction
{
public CountQueryFunctionInfo() : base("count",true)
@@ -1964,7 +1964,7 @@
return NHibernateUtil.Int64;
}
}
-
+ [Serializable]
protected class AvgQueryFunctionInfo : ClassicAggregateFunction
{
public AvgQueryFunctionInfo() : base("avg",false)
@@ -1994,7 +1994,8 @@
return NHibernateUtil.Double;
}
}
-
+
+ [Serializable]
protected class SumQueryFunctionInfo : ClassicAggregateFunction
{
public SumQueryFunctionInfo() : base("sum",false)
Modified: trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -7,7 +7,8 @@
using NHibernate.Engine;
using NHibernate.Type;
using System.Data.Common;
-
+using System;
+using Environment = NHibernate.Cfg.Environment;
namespace NHibernate.Dialect
{
/// <summary>
@@ -214,6 +215,7 @@
return -1;
}
+ [Serializable]
private class CastedFunction : NoArgSQLFunction
{
public CastedFunction(string name, IType returnType)
@@ -233,6 +235,7 @@
}
}
+ [Serializable]
private class CurrentTimeStamp : NoArgSQLFunction
{
public CurrentTimeStamp()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiExtractFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiExtractFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiExtractFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -27,6 +27,7 @@
/// TIMEZONE_MINUTE
/// ]]>
/// </remarks>
+ [Serializable]
public class AnsiExtractFunction: SQLFunctionTemplate, IFunctionGrammar
{
public AnsiExtractFunction()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiSubstringFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiSubstringFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiSubstringFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -21,6 +21,7 @@
/// [ FOR <string length> ] <right paren>
///]]>
/// </remarks>
+ [Serializable]
public class AnsiSubstringFunction : ISQLFunction
{
#region ISQLFunction Members
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimEmulationFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -17,6 +17,7 @@
/// which it uses in various combinations to emulate the desired ANSI trim()
/// functionality.
/// </summary>
+ [Serializable]
public class AnsiTrimEmulationFunction : ISQLFunction, IFunctionGrammar
{
private static readonly ISQLFunction LeadingSpaceTrim = new SQLFunctionTemplate(NHibernateUtil.String, "ltrim( ?1 )");
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/AnsiTrimFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -3,6 +3,7 @@
namespace NHibernate.Dialect.Function
{
+ [Serializable]
public class AnsiTrimFunction : SQLFunctionTemplate, IFunctionGrammar
{
public AnsiTrimFunction()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -10,6 +10,7 @@
/// <summary>
/// ANSI-SQL style cast(foo as type) where the type is a NHibernate type
/// </summary>
+ [Serializable]
public class CastFunction : ISQLFunction, IFunctionGrammar
{
#region ISQLFunction Members
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CharIndexFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/CharIndexFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/CharIndexFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -10,6 +10,7 @@
/// <summary>
/// Emulation of locate() on Sybase
/// </summary>
+ [Serializable]
public class CharIndexFunction : ISQLFunction
{
public CharIndexFunction()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAggregateFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAggregateFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAggregateFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -8,6 +8,7 @@
namespace NHibernate.Dialect.Function
{
+ [Serializable]
public class ClassicAggregateFunction : ISQLFunction, IFunctionGrammar
{
private IType returnType = null;
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAvgFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAvgFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicAvgFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -9,6 +9,7 @@
/// <summary>
/// Classic AVG sqlfunction that return types as it was done in Hibernate 3.1
/// </summary>
+ [Serializable]
public class ClassicAvgFunction : ClassicAggregateFunction
{
public ClassicAvgFunction() : base("avg", false)
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicCountFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicCountFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicCountFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -7,6 +7,7 @@
/// <summary>
/// Classic COUNT sqlfunction that return types as it was done in Hibernate 3.1
/// </summary>
+ [Serializable]
public class ClassicCountFunction : ClassicAggregateFunction
{
public ClassicCountFunction() : base("count", true)
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicSumFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicSumFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/ClassicSumFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -5,6 +5,7 @@
/// <summary>
/// Classic SUM sqlfunction that return types as it was done in Hibernate 3.1
/// </summary>
+ [Serializable]
public class ClassicSumFunction : ClassicAggregateFunction
{
public ClassicSumFunction() : base("sum", false)
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CommonGrammar.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/CommonGrammar.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/CommonGrammar.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -3,6 +3,7 @@
namespace NHibernate.Dialect.Function
{
+ [Serializable]
public class CommonGrammar: IFunctionGrammar
{
#region IFunctionGrammar Members
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/NoArgSQLFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/NoArgSQLFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/NoArgSQLFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -2,12 +2,14 @@
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.Type;
+using System;
namespace NHibernate.Dialect.Function
{
/// <summary>
/// Summary description for NoArgSQLFunction.
/// </summary>
+ [Serializable]
public class NoArgSQLFunction : ISQLFunction
{
public NoArgSQLFunction(string name, IType returnType)
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/NvlFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/NvlFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/NvlFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -9,6 +9,7 @@
/// <summary>
/// Emulation of coalesce() on Oracle, using multiple nvl() calls
/// </summary>
+ [Serializable]
public class NvlFunction : ISQLFunction
{
public NvlFunction()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/PositionSubstringFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/PositionSubstringFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/PositionSubstringFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -10,6 +10,7 @@
/// <summary>
/// Emulation of locate() on PostgreSQL
/// </summary>
+ [Serializable]
public class PositionSubstringFunction : ISQLFunction
{
public PositionSubstringFunction()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/SQLFunctionTemplate.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/SQLFunctionTemplate.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/SQLFunctionTemplate.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -5,6 +5,7 @@
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.Type;
+using System;
namespace NHibernate.Dialect.Function
{
@@ -16,6 +17,7 @@
/// Each dialect will define a template as a string (exactly like above) marking function
/// parameters with '?' followed by parameter's index (first index is 1).
/// </summary>
+ [Serializable]
public class SQLFunctionTemplate : ISQLFunction
{
private const int InvalidArgumentIndex = -1;
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSQLFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSQLFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSQLFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -3,6 +3,7 @@
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.Type;
+using System;
namespace NHibernate.Dialect.Function
{
@@ -14,6 +15,7 @@
/// The Dialect and its sub-classes use this class to provide details required
/// for processing of the associated function.
/// </remarks>
+ [Serializable]
public class StandardSQLFunction : ISQLFunction
{
private IType returnType = null;
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSafeSQLFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSafeSQLFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/StandardSafeSQLFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -14,6 +14,7 @@
/// The Dialect and its sub-classes use this class to provide details required
/// for processing of the associated function.
/// </remarks>
+ [Serializable]
public class StandardSafeSQLFunction : StandardSQLFunction
{
private int allowedArgsCount = 1;
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/VarArgsSQLFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/VarArgsSQLFunction.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/VarArgsSQLFunction.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -11,6 +11,7 @@
/// Support for slightly more general templating than StandardSQLFunction,
/// with an unlimited number of arguments.
/// </summary>
+ [Serializable]
public class VarArgsSQLFunction : ISQLFunction
{
private readonly string begin;
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -430,7 +430,7 @@
string selectExistingObject = GetSelectExistingObject(name, table);
return string.Format(@"if not exists ({0})", selectExistingObject);
}
-
+ [Serializable]
protected class CountBigQueryFunction : ClassicAggregateFunction
{
public CountBigQueryFunction()
Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -445,7 +445,7 @@
#endregion
#region Functions
-
+ [Serializable]
private class CurrentTimeStamp : NoArgSQLFunction
{
public CurrentTimeStamp() : base("current_timestamp", NHibernateUtil.DateTime, true) {}
@@ -455,7 +455,7 @@
return new SqlString(Name);
}
}
-
+ [Serializable]
private class LocateFunction : ISQLFunction
{
private static readonly ISQLFunction LocateWith2Params = new SQLFunctionTemplate(NHibernateUtil.Int32,
Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -254,6 +254,7 @@
return new OracleDataBaseSchema(connection);
}
+ [Serializable]
private class CurrentTimeStamp : NoArgSQLFunction
{
public CurrentTimeStamp()
Added: trunk/nhibernate/src/NHibernate.Test/DialectTest/FunctionTests/SerializableTypesFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/DialectTest/FunctionTests/SerializableTypesFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/DialectTest/FunctionTests/SerializableTypesFixture.cs 2009-03-10 17:54:00 UTC (rev 4121)
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NHibernate.Dialect.Function;
+using System.Reflection;
+
+namespace NHibernate.Test.DialectTest.FunctionTests
+{
+ [TestFixture]
+ public class SerializableTypesFixture
+ {
+ [Test]
+ public void AllEmbeddedTypesAreMarkedSerializable()
+ {
+ NHAssert.InheritedAreMarkedSerializable(typeof(ISQLFunction));
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-09 22:16:12 UTC (rev 4120)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-10 17:54:00 UTC (rev 4121)
@@ -140,6 +140,7 @@
<Compile Include="DialectTest\DB2DialectFixture.cs" />
<Compile Include="DialectTest\DialectFixture.cs" />
<Compile Include="DialectTest\FirebirdDialectFixture.cs" />
+ <Compile Include="DialectTest\FunctionTests\SerializableTypesFixture.cs" />
<Compile Include="DialectTest\MsSql2005DialectFixture.cs" />
<Compile Include="DialectTest\MsSqlDialectFixture.cs" />
<Compile Include="DialectTest\SqlCEDialectFixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-03-10 22:43:24
|
Revision: 4122
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4122&view=rev
Author: tehlike
Date: 2009-03-10 22:43:13 +0000 (Tue, 10 Mar 2009)
Log Message:
-----------
Making Configuration Serializable.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/AdoNet/Expectations.cs
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Cfg/DefaultNamingStrategy.cs
trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs
trunk/nhibernate/src/NHibernate/Engine/Query/Sql/NativeSQLQueryScalarReturn.cs
trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs
trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs
trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
trunk/nhibernate/src/NHibernate/LockMode.cs
trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs
trunk/nhibernate/src/NHibernate/Tuple/Component/PocoComponentTuplizer.cs
trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs
trunk/nhibernate/src/NHibernate/Type/AbstractType.cs
trunk/nhibernate/src/NHibernate/Type/ForeignKeyDirection.cs
trunk/nhibernate/src/NHibernate/Type/OneToOneType.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs
trunk/nhibernate/src/NHibernate.Test/EngineTest/NativeSqlQueryReturnTest.cs
Modified: trunk/nhibernate/src/NHibernate/AdoNet/Expectations.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/Expectations.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/AdoNet/Expectations.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -81,11 +81,11 @@
public static IExpectation AppropriateExpectation(ExecuteUpdateResultCheckStyle style)
{
- if (style == ExecuteUpdateResultCheckStyle.None)
+ if (style.Equals(ExecuteUpdateResultCheckStyle.None))
{
return None;
}
- else if (style == ExecuteUpdateResultCheckStyle.Count)
+ else if (style.Equals(ExecuteUpdateResultCheckStyle.Count))
{
return Basic;
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -26,6 +26,7 @@
using NHibernate.Type;
using NHibernate.Util;
using Array=System.Array;
+using System.Runtime.Serialization;
namespace NHibernate.Cfg
{
@@ -44,7 +45,8 @@
/// is immutable and does not retain any association back to the <see cref="Configuration" />
/// </para>
/// </remarks>
- public class Configuration
+ [Serializable]
+ public class Configuration:ISerializable
{
/// <summary>The XML Namespace for the nhibernate-mapping</summary>
public const string MappingSchemaXMLNS = "urn:nhibernate-mapping-2.2";
@@ -74,8 +76,89 @@
private static readonly ILog log = LogManager.GetLogger(typeof (Configuration));
+
protected internal SettingsFactory settingsFactory;
+ #region ISerializable Members
+ public Configuration(SerializationInfo info, StreamingContext context)
+ {
+ this.Reset();
+
+ this.EntityNotFoundDelegate = GetSerialedObject<IEntityNotFoundDelegate>(info, "entityNotFoundDelegate");
+
+
+ this.auxiliaryDatabaseObjects = GetSerialedObject<IList<IAuxiliaryDatabaseObject>>(info, "auxiliaryDatabaseObjects");
+ this.classes = GetSerialedObject<IDictionary<string, PersistentClass>>(info, "classes");
+ this.collections = GetSerialedObject<IDictionary<string, NHibernate.Mapping.Collection>>(info, "collections");
+
+ this.columnNameBindingPerTable = GetSerialedObject<IDictionary<Table, Mappings.ColumnNames>>(info,
+ "columnNameBindingPerTable");
+ this.defaultAssembly = GetSerialedObject<string>(info, "defaultAssembly");
+ this.defaultNamespace = GetSerialedObject<string>(info, "defaultNamespace");
+ this.eventListeners = GetSerialedObject<EventListeners>(info, "eventListeners");
+ //this.extendsQueue = GetSerialedObject<ISet<ExtendsQueueEntry>>(info, "extendsQueue");
+ this.FilterDefinitions = GetSerialedObject<IDictionary<string, FilterDefinition>>(info, "filterDefinitions");
+ this.Imports = GetSerialedObject<IDictionary<string, string>>(info, "imports");
+ this.interceptor = GetSerialedObject<IInterceptor>(info, "interceptor");
+ this.mapping = GetSerialedObject<IMapping>(info, "mapping");
+ this.NamedQueries = GetSerialedObject<IDictionary<string, NamedQueryDefinition>>(info, "namedQueries");
+ this.NamedSQLQueries = GetSerialedObject<IDictionary<string, NamedSQLQueryDefinition>>(info, "namedSqlQueries");
+ this.namingStrategy = GetSerialedObject<INamingStrategy>(info, "namingStrategy");
+ this.properties = GetSerialedObject<IDictionary<string, string>>(info, "properties");
+ this.propertyReferences = GetSerialedObject<IList<Mappings.PropertyReference>>(info, "propertyReferences");
+ this.settingsFactory = GetSerialedObject<SettingsFactory>(info, "settingsFactory");
+ this.SqlFunctions = GetSerialedObject<IDictionary<string, ISQLFunction>>(info, "sqlFunctions");
+ this.SqlResultSetMappings = GetSerialedObject<IDictionary<string, ResultSetMappingDefinition>>(info, "sqlResultSetMappings");
+ this.tableNameBinding = GetSerialedObject<IDictionary<string, Mappings.TableDescription>>(info, "tableNameBinding");
+ this.tables = GetSerialedObject<IDictionary<string, Table>>(info, "tables");
+ this.typeDefs = GetSerialedObject<IDictionary<string, TypeDef>>(info, "typeDefs");
+
+
+
+
+
+
+ }
+ private T GetSerialedObject<T>(SerializationInfo info, string name)
+ {
+ return (T)info.GetValue(name, typeof(T));
+ }
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ ConfigureProxyFactoryFactory();
+ SecondPassCompile();
+ Validate();
+
+
+ info.AddValue("entityNotFoundDelegate", this.EntityNotFoundDelegate);
+
+
+ info.AddValue("auxiliaryDatabaseObjects", this.auxiliaryDatabaseObjects);
+ info.AddValue("classes", this.classes);
+ info.AddValue("collections", this.collections);
+ info.AddValue("columnNameBindingPerTable", this.columnNameBindingPerTable);
+ info.AddValue("defaultAssembly", this.defaultAssembly);
+ info.AddValue("defaultNamespace", this.defaultNamespace);
+ info.AddValue("eventListeners", this.eventListeners);
+ //info.AddValue("extendsQueue", this.extendsQueue);
+ info.AddValue("filterDefinitions", this.FilterDefinitions);
+ info.AddValue("imports", this.Imports);
+ info.AddValue("interceptor", this.interceptor);
+ info.AddValue("mapping", this.mapping);
+ info.AddValue("namedQueries", this.NamedQueries);
+ info.AddValue("namedSqlQueries", this.NamedSQLQueries);
+ info.AddValue("namingStrategy", this.namingStrategy);
+ info.AddValue("properties", this.properties);
+ info.AddValue("propertyReferences", this.propertyReferences);
+ info.AddValue("settingsFactory", this.settingsFactory);
+ info.AddValue("sqlFunctions", this.SqlFunctions);
+ info.AddValue("sqlResultSetMappings", this.SqlResultSetMappings);
+ info.AddValue("tableNameBinding", this.tableNameBinding);
+ info.AddValue("tables", this.tables);
+ info.AddValue("typeDefs", this.typeDefs);
+ }
+ #endregion
+
/// <summary>
/// Clear the internal state of the <see cref="Configuration"/> object.
/// </summary>
@@ -101,8 +184,9 @@
extendsQueue = new HashedSet<ExtendsQueueEntry>();
tableNameBinding = new Dictionary<string, Mappings.TableDescription>();
columnNameBindingPerTable = new Dictionary<Table, Mappings.ColumnNames>();
+
}
-
+ [Serializable]
private class Mapping : IMapping
{
private readonly Configuration configuration;
@@ -155,7 +239,7 @@
}
}
- [NonSerialized] private IMapping mapping;
+ private IMapping mapping;
protected Configuration(SettingsFactory settingsFactory)
{
@@ -969,13 +1053,7 @@
private string defaultAssembly;
private string defaultNamespace;
- /// <summary>
- /// Instantiate a new <see cref="ISessionFactory" />, using the properties and mappings in this
- /// configuration. The <see cref="ISessionFactory" /> will be immutable, so changes made to the
- /// configuration after building the <see cref="ISessionFactory" /> will not affect it.
- /// </summary>
- /// <returns>An <see cref="ISessionFactory" /> instance.</returns>
- public ISessionFactory BuildSessionFactory()
+ protected virtual void ConfigureProxyFactoryFactory()
{
#region Way for the user to specify their own ProxyFactory
@@ -990,7 +1068,17 @@
}
#endregion
+ }
+ /// <summary>
+ /// Instantiate a new <see cref="ISessionFactory" />, using the properties and mappings in this
+ /// configuration. The <see cref="ISessionFactory" /> will be immutable, so changes made to the
+ /// configuration after building the <see cref="ISessionFactory" /> will not affect it.
+ /// </summary>
+ /// <returns>An <see cref="ISessionFactory" /> instance.</returns>
+ public ISessionFactory BuildSessionFactory()
+ {
+ ConfigureProxyFactoryFactory();
SecondPassCompile();
Validate();
Environment.VerifyProperties(properties);
@@ -2056,5 +2144,7 @@
return generators.Values;
}
+
+
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/DefaultNamingStrategy.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/DefaultNamingStrategy.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Cfg/DefaultNamingStrategy.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -1,4 +1,5 @@
using NHibernate.Util;
+using System;
namespace NHibernate.Cfg
{
@@ -6,6 +7,7 @@
/// The default <cref name="INamingStrategy"/>
/// </summary>
/// <remarks>See <cref name="ImprovedNamingStrategy"/> for a better alternative</remarks>
+ [Serializable]
public class DefaultNamingStrategy : INamingStrategy
{
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -17,6 +17,7 @@
/// <summary>
/// Reads configuration properties and configures a <see cref="Settings"/> instance.
/// </summary>
+ [Serializable]
public sealed class SettingsFactory
{
private static readonly ILog log = LogManager.GetLogger(typeof(SettingsFactory));
Modified: trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -1,5 +1,6 @@
using System;
using NHibernate.SqlCommand;
+using System.Runtime.Serialization;
namespace NHibernate.Engine
{
@@ -44,7 +45,6 @@
}
return false;
}
-
public override int GetHashCode()
{
return name.GetHashCode();
Modified: trunk/nhibernate/src/NHibernate/Engine/Query/Sql/NativeSQLQueryScalarReturn.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Query/Sql/NativeSQLQueryScalarReturn.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Engine/Query/Sql/NativeSQLQueryScalarReturn.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -4,6 +4,7 @@
namespace NHibernate.Engine.Query.Sql
{
/// <summary> Describes a scalar return in a native SQL query. </summary>
+ [Serializable]
public class NativeSQLQueryScalarReturn : INativeSQLQueryReturn
{
private readonly string columnAlias;
Modified: trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using NHibernate.Engine.Query.Sql;
+using System;
namespace NHibernate.Engine
{
+ [Serializable]
public class ResultSetMappingDefinition
{
private readonly string name;
Modified: trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/EntityModeEqualityComparer.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -1,7 +1,9 @@
using System.Collections.Generic;
+using System;
namespace NHibernate
{
+ [Serializable]
public class EntityModeEqualityComparer : IEqualityComparer<EntityMode>
{
public bool Equals(EntityMode x, EntityMode y)
Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -341,7 +341,7 @@
{
object[] copiedValues;
- if (foreignKeyDirection == ForeignKeyDirection.ForeignKeyToParent)
+ if (foreignKeyDirection.Equals( ForeignKeyDirection.ForeignKeyToParent))
{
// this is the second pass through on a merge op, so here we limit the
// replacement to associations types (value types were already replaced
Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -464,7 +464,7 @@
string foreignKeyTable;
string[] foreignKeyColumns;
- if (type.ForeignKeyDirection == ForeignKeyDirection.ForeignKeyFromParent)
+ if (type.ForeignKeyDirection.Equals(ForeignKeyDirection.ForeignKeyFromParent))
{
foreignKeyTable = lhsTable;
foreignKeyColumns = lhsColumnNames;
Modified: trunk/nhibernate/src/NHibernate/LockMode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/LockMode.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/LockMode.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -101,6 +101,15 @@
/// </summary>
public static readonly LockMode Force = new LockMode(15, "Force");
+ public override bool Equals(object obj)
+ {
+ LockMode lm = obj as LockMode;
+ if(lm!=null)
+ {
+ return (lm.level == this.level) && (lm.name == this.name);
+ }
+ return base.Equals(obj);
+ }
//TODO: need to implement .NET equivalent of readResolve - believe it is
// the IObjectReference interface...
Modified: trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -160,6 +160,7 @@
/// <summary>
/// An <see cref="IGetter"/> for a Property <c>get</c>.
/// </summary>
+ [Serializable]
public sealed class BasicGetter : IGetter, IOptimizableGetter
{
private readonly System.Type clazz;
@@ -255,6 +256,7 @@
/// <summary>
/// An <see cref="ISetter"/> for a Property <c>set</c>.
/// </summary>
+ [Serializable]
public sealed class BasicSetter : ISetter, IOptimizableSetter
{
private readonly System.Type clazz;
Modified: trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -151,6 +151,7 @@
/// <summary>
/// An <see cref="IGetter"/> that uses a Field instead of the Property <c>get</c>.
/// </summary>
+ [Serializable]
public sealed class FieldGetter : IGetter, IOptimizableGetter
{
private readonly FieldInfo field;
@@ -234,6 +235,7 @@
/// <summary>
/// An <see cref="IGetter"/> that uses a Field instead of the Property <c>set</c>.
/// </summary>
+ [Serializable]
public sealed class FieldSetter : ISetter, IOptimizableSetter
{
private readonly FieldInfo field;
Modified: trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -1,7 +1,7 @@
using System.Collections;
using System.Reflection;
using NHibernate.Engine;
-
+using System;
namespace NHibernate.Properties
{
public class MapAccessor : IPropertyAccessor
@@ -24,7 +24,7 @@
}
#endregion
-
+ [Serializable]
public sealed class MapSetter : ISetter
{
private readonly string name;
@@ -49,7 +49,7 @@
((IDictionary)target)[name] = value;
}
}
-
+ [Serializable]
public sealed class MapGetter : IGetter
{
private readonly string name;
Modified: trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -273,7 +273,7 @@
throw new MappingException("could not instantiate PropertyAccessor class: " + accessorName, e);
}
}
-
+ [NonSerialized]
private static readonly IPropertyAccessor MapAccessor = new MapAccessor();
public static IPropertyAccessor DynamicMapPropertyAccessor
{
Modified: trunk/nhibernate/src/NHibernate/Tuple/Component/PocoComponentTuplizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tuple/Component/PocoComponentTuplizer.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Tuple/Component/PocoComponentTuplizer.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -4,6 +4,8 @@
namespace NHibernate.Tuple.Component
{
+ using System.Runtime.Serialization;
+
/// <summary>
/// A <see cref="IComponentTuplizer"/> specific to the POCO entity mode.
/// </summary>
@@ -13,8 +15,15 @@
private readonly System.Type componentClass;
private readonly ISetter parentSetter;
private readonly IGetter parentGetter;
- private readonly IReflectionOptimizer optimizer;
+ [NonSerialized]
+ private IReflectionOptimizer optimizer;
+
+ [OnDeserialized]
+ internal void OnDeserialized(StreamingContext context)
+ {
+ this.optimizer = Cfg.Environment.BytecodeProvider.GetReflectionOptimizer(componentClass, getters, setters);
+ }
public PocoComponentTuplizer(Mapping.Component component) : base(component)
{
componentClass = component.ComponentClass;
Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -11,9 +11,11 @@
using NHibernate.Proxy;
using NHibernate.Type;
using NHibernate.Util;
+using System.Runtime.Serialization;
namespace NHibernate.Tuple.Entity
{
+
/// <summary> An <see cref="IEntityTuplizer"/> specific to the POCO entity mode. </summary>
public class PocoEntityTuplizer : AbstractEntityTuplizer
{
@@ -23,9 +25,23 @@
private readonly bool islifecycleImplementor;
private readonly bool isValidatableImplementor;
private readonly HashedSet<string> lazyPropertyNames = new HashedSet<string>();
- private readonly IReflectionOptimizer optimizer;
+ [NonSerialized]
+ private IReflectionOptimizer optimizer;
private readonly IProxyValidator proxyValidator;
+ [OnDeserialized]
+ internal void OnDeserialized(StreamingContext context)
+ {
+ SetReflectionOptimizer();
+ }
+ protected void SetReflectionOptimizer()
+ {
+ if (Cfg.Environment.UseReflectionOptimizer)
+ {
+ // NH different behavior fo NH-1587
+ optimizer = Cfg.Environment.BytecodeProvider.GetReflectionOptimizer(mappedClass, getters, setters);
+ }
+ }
public PocoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)
: base(entityMetamodel, mappedEntity)
{
@@ -39,12 +55,8 @@
if (property.IsLazy)
lazyPropertyNames.Add(property.Name);
}
+ SetReflectionOptimizer();
- if (Cfg.Environment.UseReflectionOptimizer)
- {
- // NH different behavior fo NH-1587
- optimizer = Cfg.Environment.BytecodeProvider.GetReflectionOptimizer(mappedClass, getters, setters);
- }
Instantiator = BuildInstantiator(mappedEntity);
if (hasCustomAccessors)
Modified: trunk/nhibernate/src/NHibernate/Type/AbstractType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/AbstractType.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Type/AbstractType.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -208,7 +208,7 @@
}
else
{
- include = ForeignKeyDirection.ForeignKeyFromParent == foreignKeyDirection;
+ include = ForeignKeyDirection.ForeignKeyFromParent.Equals(foreignKeyDirection);
}
return include ? Replace(original, target, session, owner, copyCache) : target;
}
Modified: trunk/nhibernate/src/NHibernate/Type/ForeignKeyDirection.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/ForeignKeyDirection.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Type/ForeignKeyDirection.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -3,6 +3,7 @@
namespace NHibernate.Type
{
using System;
+ using System.Runtime.Serialization;
/// <summary>
/// Represents directionality of the foreign key constraint
@@ -19,7 +20,10 @@
{
public override bool CascadeNow(CascadePoint cascadePoint)
{
- return cascadePoint != CascadePoint.BeforeInsertAfterDelete;
+ return cascadePoint != CascadePoint.BeforeInsertAfterDelete;}
+ public override bool Equals(object obj)
+ {
+ return obj is ForeignKeyToParentClass; ;
}
}
[Serializable]
@@ -29,6 +33,10 @@
{
return cascadePoint != CascadePoint.AfterInsertBeforeDelete;
}
+ public override bool Equals(object obj)
+ {
+ return obj is ForeignKeyFromParentClass; ;
+ }
}
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/Type/OneToOneType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/OneToOneType.cs 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate/Type/OneToOneType.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -113,7 +113,7 @@
public override bool IsNullable
{
- get { return foreignKeyDirection == ForeignKeyDirection.ForeignKeyToParent; }
+ get { return foreignKeyDirection.Equals(ForeignKeyDirection.ForeignKeyToParent); }
}
public override bool UseLHSPrimaryKey
Added: trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NHibernate.Cfg;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Reflection;
+using NHibernate.Tool.hbm2ddl;
+using NHibernate.DomainModel;
+using System.IO;
+using NUnit.Framework.SyntaxHelpers;
+namespace NHibernate.Test.CfgTest
+{
+ [TestFixture]
+ public class ConfigurationSerializationTests
+ {
+ [Test]
+ public void Configuration_should_be_serializable()
+ {
+ NHAssert.HaveSerializableAttribute(typeof (Configuration));
+ }
+
+ [Test]
+ public void Basic_CRUD_should_work()
+ {
+ Assembly assembly = Assembly.Load("NHibernate.DomainModel");
+ Configuration cfg = new Configuration();
+ cfg.AddResource("NHibernate.DomainModel.ParentChild.hbm.xml", assembly);
+
+ BinaryFormatter formatter = new BinaryFormatter();
+ var memoryStream = new MemoryStream();
+ formatter.Serialize(memoryStream, cfg);
+ memoryStream.Position = 0;
+ cfg = formatter.Deserialize(memoryStream) as Configuration;
+ SchemaExport export = new SchemaExport(cfg);
+ export.Execute(true, true, false, true);
+ var sf = cfg.BuildSessionFactory();
+ using(var session=sf.OpenSession())
+ using(var tran=session.BeginTransaction())
+ {
+ Parent parent = new Parent();
+ Child child = new Child();
+ parent.Child = child;
+ parent.X = 9;
+ parent.Count = 5;
+ child.Parent = parent;
+ child.Count = 3;
+ child.X = 4;
+ session.Save(parent);
+ session.Save(child);
+ tran.Commit();
+ }
+
+ using (var session = sf.OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ Parent parent = session.Get<Parent>(1L);
+ Assert.That(parent.Count, Is.EqualTo(5));
+ Assert.That(parent.X, Is.EqualTo(9));
+ Assert.That(parent.Child, Is.Not.Null);
+ Assert.That(parent.Child.X, Is.EqualTo(4));
+ Assert.That(parent.Child.Count, Is.EqualTo(3));
+ Assert.That(parent.Child.Parent, Is.EqualTo(parent));
+ }
+
+
+ using (var session = sf.OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ var p = session.Get<Parent>(1L);
+ var c = session.Get<Child>(1L);
+ session.Delete(c);
+ session.Delete(p);
+ tran.Commit();
+ }
+ using (var session = sf.OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ var p = session.Get<Parent>(1L);
+ Assert.That(p, Is.Null);
+ }
+ export.Drop(true, true);
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/EngineTest/NativeSqlQueryReturnTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/EngineTest/NativeSqlQueryReturnTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/EngineTest/NativeSqlQueryReturnTest.cs 2009-03-10 22:43:13 UTC (rev 4122)
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NHibernate.Engine.Query.Sql;
+
+namespace NHibernate.Test.EngineTest
+{
+ [TestFixture]
+ public class NativeSqlQueryReturnTest
+ {
+ [Test]
+ public void AllEmbeddedTypesAreMarkedSerializable()
+ {
+ NHAssert.InheritedAreMarkedSerializable(typeof(INativeSQLQueryReturn));
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-10 17:54:00 UTC (rev 4121)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-10 22:43:13 UTC (rev 4122)
@@ -91,6 +91,7 @@
<Compile Include="Cascade\RefreshFixture.cs" />
<Compile Include="CfgTest\ConfigurationFixture.cs" />
<Compile Include="CfgTest\ConfigurationSchemaFixture.cs" />
+ <Compile Include="CfgTest\ConfigurationSerializationTests.cs" />
<Compile Include="CfgTest\DefaultNsAssmFixture.cs" />
<Compile Include="CfgTest\HbmBinderFixture.cs" />
<Compile Include="CfgTest\HbmOrderingFixture.cs" />
@@ -161,6 +162,7 @@
<Compile Include="DynamicEntity\Tuplizer\MyEntityInstantiator.cs" />
<Compile Include="DynamicEntity\Tuplizer\MyEntityTuplizer.cs" />
<Compile Include="DynamicEntity\Tuplizer\TuplizerDynamicEntity.cs" />
+ <Compile Include="EngineTest\NativeSqlQueryReturnTest.cs" />
<Compile Include="EngineTest\TypedValueFixture.cs" />
<Compile Include="EntityModeTest\Map\Basic\DynamicClassFixture.cs" />
<Compile Include="EntityModeTest\Multi\MultiRepresentationFixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-03-11 04:21:04
|
Revision: 4123
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4123&view=rev
Author: darioquintana
Date: 2009-03-11 04:20:07 +0000 (Wed, 11 Mar 2009)
Log Message:
-----------
fix NH-645: support scalar function which don't return a value in a where clause (for example Sql Server functions: Contains and FreeText)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Classic/WhereParser.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/WhereParser.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Classic/WhereParser.cs 2009-03-10 22:43:13 UTC (rev 4122)
+++ trunk/nhibernate/src/NHibernate/Hql/Classic/WhereParser.cs 2009-03-11 04:20:07 UTC (rev 4123)
@@ -361,7 +361,13 @@
//unaryCounts.removeLast(); //check that its zero? (As an assertion)
SqlStringBuilder join = joins[joins.Count - 1];
joins.RemoveAt(joins.Count - 1);
- joins[joins.Count - 1].Add(join.ToSqlString());
+
+ //let special non-boolean-functions works like: "from Animal a where fx(a.Text,'x');"
+ //and 'fx' isn't a boolean function.
+ if (joins.Count == 0)
+ AppendToken(q, join.ToSqlString());
+ else
+ joins[joins.Count - 1].Add(join.ToSqlString());
}
bool lastNots = nots[nots.Count - 1];
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH645/HQLFunctionFixture.cs 2009-03-11 04:20:07 UTC (rev 4123)
@@ -0,0 +1,74 @@
+using System;
+using System.Collections;
+using NHibernate.Cfg;
+using NHibernate.Dialect;
+using NHibernate.Dialect.Function;
+using NUnit.Framework;
+using Environment=NHibernate.Cfg.Environment;
+
+namespace NHibernate.Test.NHSpecificTest.NH645
+{
+ [TestFixture]
+ public class HQLFunctionFixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override IList Mappings
+ {
+ get { return new[] {"HQL.Animal.hbm.xml", "HQL.MaterialResource.hbm.xml"}; }
+ }
+
+ protected override void Configure(Configuration configuration)
+ {
+ configuration.SetProperty(Environment.Dialect, typeof (CustomDialect).AssemblyQualifiedName);
+ }
+
+ /// <summary>
+ /// Just test the parser can compile, and SqlException is expected.
+ /// </summary>
+
+ [Test]
+ public void SimpleWhere()
+ {
+ Run("from Animal a where freetext(a.Description, 'hey apple car')");
+ }
+
+ [Test]
+ public void SimpleWhereWithAnotherClause()
+ {
+ Run("from Animal a where freetext(a.Description, 'hey apple car') AND 1 = 1");
+ }
+
+ [Test]
+ public void SimpleWhereWithAnotherClause2()
+ {
+ Run("from Animal a where freetext(a.Description, 'hey apple car') AND a.Description <> 'foo'");
+ }
+
+
+ public void Run(string hql)
+ {
+ using(ISession s = OpenSession())
+ try
+ {
+ s.CreateQuery(hql).List();
+ }
+ catch (Exception ex)
+ {
+ if (ex is QueryException)
+ Assert.Fail("The parser think that 'freetext' is a boolean function");
+ }
+ }
+ }
+
+ public class CustomDialect : MsSql2005Dialect
+ {
+ public CustomDialect()
+ {
+ RegisterFunction("freetext", new SQLFunctionTemplate(null, "freetext($1,$2)"));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-10 22:43:13 UTC (rev 4122)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-11 04:20:07 UTC (rev 4123)
@@ -292,6 +292,7 @@
<Compile Include="GenericTest\SetGeneric\SetGenericFixture.cs" />
<Compile Include="HQL\Animal.cs" />
<Compile Include="HQL\BaseFunctionFixture.cs" />
+ <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
<Compile Include="HQL\MaterialResource.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2009-03-11 21:26:12
|
Revision: 4124
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4124&view=rev
Author: davybrion
Date: 2009-03-11 21:26:06 +0000 (Wed, 11 Mar 2009)
Log Message:
-----------
applied patch from Robert Dusek for NH-1698
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/NonClusteredPrimaryKeyFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-03-11 04:20:07 UTC (rev 4123)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-03-11 21:26:06 UTC (rev 4124)
@@ -397,6 +397,14 @@
get { return String.Empty; }
}
+ /// <summary>
+ /// The keyword used to create a primary key constraint
+ /// </summary>
+ public virtual string PrimaryKeyString
+ {
+ get { return "primary key"; }
+ }
+
#region database type mapping support
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2009-03-11 04:20:07 UTC (rev 4123)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2009-03-11 21:26:06 UTC (rev 4124)
@@ -258,6 +258,14 @@
get { return false; }
}
+ /// <summary>
+ /// Sql Server 2005 defaults to creating a clustered primary key, which is typically undesirable.
+ /// </summary>
+ public override string PrimaryKeyString
+ {
+ get { return base.PrimaryKeyString + " nonclustered"; }
+ }
+
/// <summary>
/// This specialized string tokenizier will break a string to tokens, taking
/// into account single quotes, parenthesis and commas and [ ]
Modified: trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs 2009-03-11 04:20:07 UTC (rev 4123)
+++ trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs 2009-03-11 21:26:06 UTC (rev 4124)
@@ -20,7 +20,7 @@
/// </returns>
public string SqlConstraintString(Dialect.Dialect d, string defaultSchema)
{
- StringBuilder buf = new StringBuilder("primary key (");
+ StringBuilder buf = new StringBuilder(d.PrimaryKeyString + " (");
int i = 0;
foreach (Column col in ColumnIterator)
{
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-11 04:20:07 UTC (rev 4123)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-11 21:26:06 UTC (rev 4124)
@@ -948,6 +948,7 @@
<Compile Include="SqlTest\Custom\CustomStoredProcSupportTest.cs" />
<Compile Include="SqlTest\Custom\MySQL\MySQLTest.cs" />
<Compile Include="SqlTest\Custom\Oracle\OracleCustomSQLFixture.cs" />
+ <Compile Include="Tools\hbm2ddl\SchemaExportTests\NonClusteredPrimaryKeyFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.cs" />
<Compile Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTagFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/NonClusteredPrimaryKeyFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/NonClusteredPrimaryKeyFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/NonClusteredPrimaryKeyFixture.cs 2009-03-11 21:26:06 UTC (rev 4124)
@@ -0,0 +1,38 @@
+using System.IO;
+using System.Reflection;
+using System.Text;
+
+using NHibernate.Cfg;
+using NHibernate.Dialect;
+using NHibernate.Tool.hbm2ddl;
+
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.Tools.hbm2ddl.SchemaExportTests
+{
+ [TestFixture]
+ public class NonClusteredPrimaryKeyFixture
+ {
+ [Test]
+ public void ShouldCreateSchemaWithNonClusterdPrimaryKeyForMsSql2005Dialect()
+ {
+ var script = new StringBuilder();
+ const string mapping = "NHibernate.Test.Tools.hbm2ddl.SchemaExportTests.WithColumnTag.hbm.xml";
+
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+
+ if (cfg.Properties[Environment.Dialect] != typeof(MsSql2005Dialect).FullName)
+ {
+ Assert.Ignore("this test only applies for MsSql2005Dialect");
+ }
+
+ using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(mapping))
+ cfg.AddInputStream(stream);
+ new SchemaExport(cfg).Execute(s => script.AppendLine(s), false, false, false);
+
+ string wholeScript = script.ToString();
+ Assert.That(wholeScript, Text.Contains("primary key nonclustered (id)"));
+ }
+ }
+}
\ 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-03-14 04:36:09
|
Revision: 4128
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4128&view=rev
Author: fabiomaulo
Date: 2009-03-14 04:36:00 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
Fix NH-1702
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs
trunk/nhibernate/src/NHibernate/Transform/Transformers.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/TransformTests/
trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs
trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.cs
trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs 2009-03-14 04:05:26 UTC (rev 4127)
+++ trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs 2009-03-14 04:36:00 UTC (rev 4128)
@@ -62,7 +62,7 @@
}
}
}
- result = Activator.CreateInstance(resultClass);
+ result = Activator.CreateInstance(resultClass, true);
for (int i = 0; i < aliases.Length; i++)
{
Modified: trunk/nhibernate/src/NHibernate/Transform/Transformers.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Transform/Transformers.cs 2009-03-14 04:05:26 UTC (rev 4127)
+++ trunk/nhibernate/src/NHibernate/Transform/Transformers.cs 2009-03-14 04:36:00 UTC (rev 4128)
@@ -1,4 +1,3 @@
-using System;
using System.Collections;
namespace NHibernate.Transform
@@ -23,15 +22,20 @@
return new AliasToBeanResultTransformer(target);
}
- public static readonly IResultTransformer DistinctRootEntity = new DistinctRootEntityResultTransformer();
+ public static IResultTransformer AliasToBean<T>() where T: class
+ {
+ return AliasToBean(typeof (T));
+ }
- public static IResultTransformer AliasToBeanConstructor(System.Reflection.ConstructorInfo constructor)
- {
- return new AliasToBeanConstructorResultTransformer(constructor);
- }
+ public static readonly IResultTransformer DistinctRootEntity = new DistinctRootEntityResultTransformer();
- public static readonly IResultTransformer PassThrough = new PassThroughResultTransformer();
+ public static IResultTransformer AliasToBeanConstructor(System.Reflection.ConstructorInfo constructor)
+ {
+ return new AliasToBeanConstructorResultTransformer(constructor);
+ }
- public static readonly IResultTransformer RootEntity = new RootEntityResultTransformer();
+ public static readonly IResultTransformer PassThrough = new PassThroughResultTransformer();
+
+ public static readonly IResultTransformer RootEntity = new RootEntityResultTransformer();
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-14 04:05:26 UTC (rev 4127)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-14 04:36:00 UTC (rev 4128)
@@ -1023,6 +1023,8 @@
<Compile Include="Tools\hbm2ddl\SchemaValidator\Version.cs" />
<Compile Include="TransactionTest\TransactionFixture.cs" />
<Compile Include="TransactionTest\TransactionNotificationFixture.cs" />
+ <Compile Include="TransformTests\AliasToBeanResultTransformerFixture.cs" />
+ <Compile Include="TransformTests\Simple.cs" />
<Compile Include="TypeParameters\DefaultValueIntegerType.cs" />
<Compile Include="TypeParameters\TypeParameterTest.cs" />
<Compile Include="TypeParameters\Widget.cs" />
@@ -1679,6 +1681,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="TransformTests\Simple.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\ComplexVersioned.hbm.xml" />
<EmbeddedResource Include="Tools\hbm2ddl\SchemaExportTests\WithColumnTag.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1691\Mappings.hbm.xml" />
Added: trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs 2009-03-14 04:36:00 UTC (rev 4128)
@@ -0,0 +1,84 @@
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Transform;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.TransformTests
+{
+ [TestFixture]
+ public class AliasToBeanResultTransformerFixture : TestCase
+ {
+ public class WithOutPublicParameterLessCtor
+ {
+ private string something;
+ protected WithOutPublicParameterLessCtor() {}
+
+ public WithOutPublicParameterLessCtor(string something)
+ {
+ this.something = something;
+ }
+
+ public string Something
+ {
+ get { return something; }
+ }
+ }
+
+ #region Overrides of TestCase
+
+ protected override IList Mappings
+ {
+ get { return new[] {"TransformTests.Simple.hbm.xml"}; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ #endregion
+
+ [Test]
+ public void WorkWithOutPublicParameterLessCtor()
+ {
+ Setup();
+
+ using (ISession s = OpenSession())
+ {
+ IList<WithOutPublicParameterLessCtor> l =
+ s.CreateSQLQuery("select s.Name as something from Simple s").SetResultTransformer(
+ Transformers.AliasToBean<WithOutPublicParameterLessCtor>()).List<WithOutPublicParameterLessCtor>();
+ Assert.That(l.Count, Is.EqualTo(2));
+ Assert.That(l, Has.All.Not.Null);
+ }
+
+ Cleanup();
+ }
+
+ private void Cleanup()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (s.BeginTransaction())
+ {
+ s.Delete("from Simple");
+ s.Transaction.Commit();
+ }
+ }
+ }
+
+ private void Setup()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (s.BeginTransaction())
+ {
+ s.Save(new Simple {Name = "Name1"});
+ s.Save(new Simple {Name = "Name2"});
+ s.Transaction.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.cs 2009-03-14 04:36:00 UTC (rev 4128)
@@ -0,0 +1,7 @@
+namespace NHibernate.Test.TransformTests
+{
+ public class Simple
+ {
+ public virtual string Name { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TransformTests/Simple.hbm.xml 2009-03-14 04:36:00 UTC (rev 4128)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.TransformTests"
+ assembly="NHibernate.Test" >
+ <class name="Simple">
+ <id type="int">
+ <generator class="native" />
+ </id>
+ <property name="Name" type="string" length="40"/>
+ </class>
+</hibernate-mapping>
\ 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-03-14 05:09:49
|
Revision: 4129
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4129&view=rev
Author: fabiomaulo
Date: 2009-03-14 05:09:48 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
Fix NH-1704
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs
trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs 2009-03-14 04:36:00 UTC (rev 4128)
+++ trunk/nhibernate/src/NHibernate/Transform/AliasToBeanResultTransformer.cs 2009-03-14 05:09:48 UTC (rev 4129)
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Reflection;
using NHibernate.Properties;
namespace NHibernate.Transform
@@ -26,22 +27,32 @@
[Serializable]
public class AliasToBeanResultTransformer : IResultTransformer
{
+ private const BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
private readonly System.Type resultClass;
private ISetter[] setters;
- private IPropertyAccessor propertyAccessor;
+ private readonly IPropertyAccessor propertyAccessor;
+ private readonly ConstructorInfo constructor;
public AliasToBeanResultTransformer(System.Type resultClass)
{
if (resultClass == null)
+ {
throw new ArgumentNullException("resultClass");
+ }
this.resultClass = resultClass;
- propertyAccessor = new ChainedPropertyAccessor(
- new IPropertyAccessor[]
- {
- // TODO H3: PropertyAccessorFactory.GetPropertyAccessor(resultClass, null),
- PropertyAccessorFactory.GetPropertyAccessor(null),
- PropertyAccessorFactory.GetPropertyAccessor("field")
- });
+ constructor = resultClass.GetConstructor(flags, null, System.Type.EmptyTypes, null);
+ if (constructor == null)
+ {
+ throw new ArgumentException("The target class of a AliasToBeanResultTransformer need a parameter-less constructor",
+ "resultClass");
+ }
+
+ propertyAccessor =
+ new ChainedPropertyAccessor(new[]
+ {
+ PropertyAccessorFactory.GetPropertyAccessor(null),
+ PropertyAccessorFactory.GetPropertyAccessor("field")
+ });
}
public object TransformTuple(object[] tuple, String[] aliases)
@@ -62,7 +73,7 @@
}
}
}
- result = Activator.CreateInstance(resultClass, true);
+ result = constructor.Invoke(null);
for (int i = 0; i < aliases.Length; i++)
{
Modified: trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs 2009-03-14 04:36:00 UTC (rev 4128)
+++ trunk/nhibernate/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs 2009-03-14 05:09:48 UTC (rev 4129)
@@ -25,6 +25,17 @@
}
}
+ public class PublicParameterLessCtor
+ {
+ private string something;
+
+ public string Something
+ {
+ get { return something; }
+ set { something = value; }
+ }
+ }
+
#region Overrides of TestCase
protected override IList Mappings
@@ -56,6 +67,32 @@
Cleanup();
}
+ [Test]
+ public void WorkWithPublicParameterLessCtor()
+ {
+ Setup();
+
+ var queryString = "select s.Name as something from Simple s";
+ AssertAreWorking(queryString); // working for field access
+
+ queryString = "select s.Name as Something from Simple s";
+ AssertAreWorking(queryString); // working for property access
+
+ Cleanup();
+ }
+
+ private void AssertAreWorking(string queryString)
+ {
+ using (ISession s = OpenSession())
+ {
+ IList<PublicParameterLessCtor> l =
+ s.CreateSQLQuery(queryString).SetResultTransformer(
+ Transformers.AliasToBean<PublicParameterLessCtor>()).List<PublicParameterLessCtor>();
+ Assert.That(l.Count, Is.EqualTo(2));
+ Assert.That(l, Has.All.Not.Null);
+ }
+ }
+
private void Cleanup()
{
using (ISession s = OpenSession())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|