|
From: <dar...@us...> - 2009-02-02 20:29:16
|
Revision: 4011
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4011&view=rev
Author: darioquintana
Date: 2009-02-02 20:28:46 +0000 (Mon, 02 Feb 2009)
Log Message:
-----------
- MsSql2008Dialect added to support DateTime2 and DateTimeOffSet
- Changes in tests to support the new dialect and make them pass.
- Test for DateTime2 and DateTimeOffSet
(all tests green against MsSql2005 and MsSql2008)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs
trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs
trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml
trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml
trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs
Added: trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,13 @@
+using System.Data;
+
+namespace NHibernate.Dialect
+{
+ public class MsSql2008Dialect : MsSql2005Dialect
+ {
+ public MsSql2008Dialect()
+ {
+ RegisterColumnType(DbType.DateTime2, "DATETIME2");
+ RegisterColumnType(DbType.DateTimeOffset, "DATETIMEOFFSET");
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-02 20:28:46 UTC (rev 4011)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -14,6 +14,7 @@
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -50,6 +51,9 @@
</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" />
@@ -443,6 +447,7 @@
<Compile Include="Bytecode\HibernateByteCodeException.cs" />
<Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" />
<Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" />
+ <Compile Include="Dialect\MsSql2008Dialect.cs" />
<Compile Include="Dialect\InformixDialect0940.cs" />
<Compile Include="Dialect\InformixDialect1000.cs" />
<Compile Include="Dialect\OracleLiteDialect.cs" />
@@ -1074,9 +1079,11 @@
<Compile Include="Type\AnsiCharType.cs" />
<Compile Include="Type\AnyType.cs" />
<Compile Include="Type\AbstractCharType.cs" />
+ <Compile Include="Type\DateTime2Type.cs" />
<Compile Include="Type\ClassMetaType.cs" />
<Compile Include="Type\CollectionType.cs" />
<Compile Include="Type\CustomCollectionType.cs" />
+ <Compile Include="Type\DateTimeOffSetType.cs" />
<Compile Include="Type\EmbeddedComponentType.cs" />
<Compile Include="Type\EnumCharType.cs" />
<Compile Include="Type\GenericOrderedSetType.cs" />
Modified: trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -115,6 +115,16 @@
/// </summary>
public static readonly NullableType DateTime = new DateTimeType();
+ /// <summary>
+ /// NHibernate date type
+ /// </summary>
+ public static readonly NullableType DateTime2 = new DateTime2Type();
+
+ /// <summary>
+ /// NHibernate date type
+ /// </summary>
+ public static readonly NullableType DateTimeOffset = new DateTimeOffsetType();
+
/// <summary>
/// NHibernate date type
/// </summary>
Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -25,6 +25,8 @@
public static readonly SqlType Currency = new SqlType(DbType.Currency);
public static readonly SqlType Date = new SqlType(DbType.Date);
public static readonly SqlType DateTime = new SqlType(DbType.DateTime);
+ public static readonly SqlType DateTime2 = new SqlType(DbType.DateTime2);
+ public static readonly SqlType DateTimeOffSet = new SqlType(DbType.DateTimeOffset);
public static readonly SqlType Decimal = new SqlType(DbType.Decimal);
public static readonly SqlType Double = new SqlType(DbType.Double);
public static readonly SqlType Int16 = new SqlType(DbType.Int16);
Added: trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,23 @@
+using System;
+using System.Data;
+using NHibernate.SqlTypes;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// Maps a <see cref="System.DateTime" /> Property to a <see cref="DbType.DateTime"/>
+ /// </summary>
+ [Serializable]
+ public class DateTime2Type : DateTimeType
+ {
+ /// <summary></summary>
+ internal DateTime2Type() : base(SqlTypeFactory.DateTime2)
+ {
+ }
+
+ public override string Name
+ {
+ get { return "DateTime2"; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,124 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using NHibernate.SqlTypes;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// Maps a <see cref="System.DateTimeOffset" /> Property to a <see cref="DbType.DateTimeOffset"/>
+ /// </summary>
+ [Serializable]
+ public class DateTimeOffsetType : DateTimeType
+ {
+ /// <summary></summary>
+ public DateTimeOffsetType()
+ : base(SqlTypeFactory.DateTimeOffSet)
+ {
+ }
+
+ public override string Name
+ {
+ get { return "DateTimeOffset"; }
+ }
+
+ public override System.Type ReturnedClass
+ {
+ get
+ {
+ return typeof(DateTimeOffset);
+ }
+ }
+
+ public override System.Type PrimitiveClass
+ {
+ get { return typeof(DateTimeOffset); }
+ }
+
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ DateTimeOffset dateValue = (DateTimeOffset)value;
+ ((IDataParameter) st.Parameters[index]).Value =
+ new DateTimeOffset(dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second,dateValue.Offset);
+ }
+
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ DateTimeOffset dbValue = (DateTimeOffset)rs[index];;
+ return new DateTimeOffset(dbValue.Year, dbValue.Month, dbValue.Day, dbValue.Hour, dbValue.Minute, dbValue.Second,dbValue.Offset);
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
+ }
+ }
+
+ public override IComparer Comparator
+ {
+ get { return Comparer<DateTimeOffset>.Default; }
+ }
+
+ public override bool IsEqual(object x, object y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+
+ if (x == null || y == null)
+ {
+ return false;
+ }
+
+ DateTimeOffset date1 = (DateTimeOffset)x;
+ DateTimeOffset date2 = (DateTimeOffset)y;
+
+ if (date1.Equals(date2))
+ return true;
+
+ return (date1.Year == date2.Year &&
+ date1.Month == date2.Month &&
+ date1.Day == date2.Day &&
+ date1.Hour == date2.Hour &&
+ date1.Minute == date2.Minute &&
+ date1.Second == date2.Second &&
+ date1.Offset == date2.Offset);
+ }
+
+ public override int GetHashCode(object x, EntityMode entityMode)
+ {
+ // Custom hash code implementation because DateTimeType is only accurate
+ // up to seconds.
+ DateTimeOffset date = (DateTimeOffset)x;
+ int hashCode = 1;
+ unchecked
+ {
+ hashCode = 31 * hashCode + date.Second;
+ hashCode = 31 * hashCode + date.Minute;
+ hashCode = 31 * hashCode + date.Hour;
+ hashCode = 31 * hashCode + date.Day;
+ hashCode = 31 * hashCode + date.Month;
+ hashCode = 31 * hashCode + date.Year;
+ }
+ return hashCode;
+ }
+
+ public override string ToString(object val)
+ {
+ return ((DateTimeOffset)val).ToString();
+ }
+
+ public override object FromStringValue(string xml)
+ {
+ return DateTimeOffset.Parse(xml);
+ }
+
+ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
+ {
+ return "'" + ((DateTimeOffset)value) + "'";
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -22,10 +22,14 @@
private static readonly DateTime BaseDateValue = DateTime.MinValue;
/// <summary></summary>
- internal DateTimeType() : base(SqlTypeFactory.DateTime)
+ public DateTimeType() : base(SqlTypeFactory.DateTime)
{
}
+ public DateTimeType(SqlType sqlTypeDateTime) : base(sqlTypeDateTime)
+ {
+ }
+
/// <summary></summary>
public override string Name
{
@@ -100,7 +104,7 @@
date1.Second == date2.Second);
}
- public IComparer Comparator
+ public virtual IComparer Comparator
{
get { return Comparer<DateTime>.Default; }
}
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -108,7 +108,11 @@
RegisterType(typeof(Byte), NHibernateUtil.Byte, "byte");
RegisterType(typeof(Char), NHibernateUtil.Character, "character");
RegisterType(typeof(CultureInfo), NHibernateUtil.CultureInfo, "locale");
+ /*registering "datetime" after of "datetime2",
+ NH will choose "datetime" when no type is specified in the mapping*/
+ RegisterType(typeof(DateTime), NHibernateUtil.DateTime2, "datetime2");
RegisterType(typeof(DateTime), NHibernateUtil.DateTime, "datetime");
+ RegisterType(typeof(DateTimeOffset), NHibernateUtil.DateTimeOffset, "datetimeoffset");
RegisterType(typeof(Decimal), NHibernateUtil.Decimal, "big_decimal");
RegisterType(typeof(Double), NHibernateUtil.Double, "double");
RegisterType(typeof(Guid), NHibernateUtil.Guid, "guid");
Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Data;
+using NHibernate.Dialect;
using NHibernate.Exceptions;
using NHibernate.Util;
using NUnit.Framework;
@@ -22,7 +23,7 @@
protected override void Configure(Cfg.Configuration configuration)
{
- if((Dialect.GetType() == typeof(Dialect.MsSql2005Dialect)) || (Dialect.GetType() == typeof(Dialect.MsSql2000Dialect)))
+ if(Dialect is MsSql2000Dialect)
{
configuration.SetProperty(NHibernate.Cfg.Environment.SqlExceptionConverter,
typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName);
Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml 2009-02-02 20:28:46 UTC (rev 4011)
@@ -47,6 +47,7 @@
</drop>
<dialect-scope name="NHibernate.Dialect.MsSql2000Dialect"/>
<dialect-scope name="NHibernate.Dialect.MsSql2005Dialect"/>
+ <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect"/>
</database-object>
<database-object>
Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml 2009-02-02 20:28:46 UTC (rev 4011)
@@ -54,6 +54,7 @@
</drop>
<dialect-scope name="NHibernate.Dialect.MsSql2000Dialect"/>
<dialect-scope name="NHibernate.Dialect.MsSql2005Dialect"/>
+ <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect"/>
</database-object>
</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -18,11 +18,11 @@
static HQLFunctions()
{
notSupportedStandardFunction.Add("locate",
- new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(FirebirdDialect), typeof(PostgreSQLDialect) });
+ new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) });
notSupportedStandardFunction.Add("bit_length",
- new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect) });
+ new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) });
notSupportedStandardFunction.Add("extract",
- new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect) });
+ new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) });
}
private void IgnoreIfNotSupported(string functionName)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,15 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
+{
+ public class AllDates
+ {
+ public int Id { get; set; }
+
+ public DateTime Sql_datetime { get; set; }
+
+ public DateTime Sql_datetime2 { get; set; }
+
+ public DateTimeOffset Sql_datetimeoffset { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,86 @@
+using System;
+using System.Collections;
+using NHibernate.Dialect;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
+{
+ [TestFixture]
+ public class DateTime2AndDateTimeOffSetFixture : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "NHSpecificTest.DateTime2AndDateTimeOffSet.Mappings.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2008Dialect;
+ }
+
+
+ [Test]
+ public void Dates01()
+ {
+
+ var Now = DateTime.Now;
+ var NowOS = DateTimeOffset.Now;
+ var dates = new AllDates
+ {
+ Sql_datetime = Now,
+ Sql_datetime2 = DateTime.MinValue,
+ Sql_datetimeoffset = NowOS,
+ };
+
+ using(ISession s = OpenSession())
+ using(ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(dates);
+ tx.Commit();
+ }
+
+ using(ISession s = OpenSession())
+ using(ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+
+ DateTimeAssert.AreEqual(datesRecovered.Sql_datetime,Now);
+ DateTimeAssert.AreEqual(datesRecovered.Sql_datetime2, DateTime.MinValue);
+ DateTimeAssert.AreEqual(datesRecovered.Sql_datetimeoffset, NowOS);
+ }
+
+ using(ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+ s.Delete(datesRecovered);
+ tx.Commit();
+ }
+ }
+
+ public class DateTimeAssert
+ {
+ public static void AreEqual(DateTime dt1,DateTime dt2)
+ {
+ bool areEqual = new DateTimeType().IsEqual(dt1,dt2);
+
+ if(!areEqual)
+ Assert.Fail("Expected {0} but was {1}");
+ }
+
+ public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
+ {
+ bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
+
+ if (!areEqual)
+ Assert.Fail("Expected {0} but was {1}");
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.MsSql2008"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="identity"/>
+ </id>
+
+ <property name="Sql_datetime" />
+ <property name="Sql_datetime2" type="datetime2" />
+ <property name="Sql_datetimeoffset" type="datetimeoffset" />
+
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-01 20:55:26 UTC (rev 4010)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-02 20:28:46 UTC (rev 4011)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -14,6 +14,9 @@
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <TargetFrameworkSubset>
+ </TargetFrameworkSubset>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -377,6 +380,8 @@
<Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
<Compile Include="NHSpecificTest\Futures\Fixture.cs" />
<Compile Include="NHSpecificTest\Futures\Person.cs" />
+ <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\AllDates.cs" />
+ <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\DateTime2AndDateTimeOffSetFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
@@ -971,6 +976,7 @@
<Compile Include="TypesTest\BooleanTypeFixture.cs" />
<Compile Include="TypesTest\ByteClass.cs" />
<Compile Include="TypesTest\ByteTypeFixture.cs" />
+ <Compile Include="TypesTest\Decima2lTypeFixture.cs" />
<Compile Include="TypesTest\DateTimeTypeFixture.cs" />
<Compile Include="TypesTest\DecimalClass.cs" />
<Compile Include="TypesTest\DecimalTypeFixture.cs" />
@@ -1606,6 +1612,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\DateTime2AndDateTimeOffSet\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs (from rev 4005, trunk/nhibernate/src/NHibernate.Test/TypesTest/DecimalTypeFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs 2009-02-02 20:28:46 UTC (rev 4011)
@@ -0,0 +1,47 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.TypesTest
+{
+ /// <summary>
+ /// TestFixtures for the <see cref="DateTimeType"/>.
+ /// </summary>
+ [TestFixture]
+ public class DateTime2TypeFixture
+ {
+ [Test]
+ public void Next()
+ {
+ DateTimeType type = (DateTimeType)NHibernateUtil.DateTime2;
+ object current = DateTime.Parse("2004-01-01");
+ object next = type.Next(current, null);
+
+ Assert.IsTrue(next is DateTime, "Next should be DateTime");
+ Assert.IsTrue((DateTime)next > (DateTime)current,
+ "next should be greater than current (could be equal depending on how quickly this occurs)");
+ }
+
+ [Test]
+ public void Seed()
+ {
+ DateTimeType type = (DateTimeType)NHibernateUtil.DateTime;
+ Assert.IsTrue(type.Seed(null) is DateTime, "seed should be DateTime");
+ }
+
+ [Test]
+ public void DeepCopyNotNull()
+ {
+ NullableType type = NHibernateUtil.DateTime;
+
+ object value1 = DateTime.Now;
+ object value2 = type.DeepCopy(value1, EntityMode.Poco, null);
+
+ Assert.AreEqual(value1, value2, "Copies should be the same.");
+
+
+ value2 = ((DateTime)value2).AddHours(2);
+ Assert.IsFalse(value1 == value2, "value2 was changed, value1 should not have changed also.");
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|