|
From: <fab...@us...> - 2009-01-10 20:36:35
|
Revision: 3993
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3993&view=rev
Author: fabiomaulo
Date: 2009-01-10 20:36:28 +0000 (Sat, 10 Jan 2009)
Log Message:
-----------
Fix NH-1640
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-10 15:56:55 UTC (rev 3992)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-10 20:36:28 UTC (rev 3993)
@@ -48,13 +48,17 @@
{
CheckAndUpdateSessionStatus();
IEntityPersister persister = Factory.GetEntityPersister(entityName);
+ object loaded = temporaryPersistenceContext.GetEntity(new EntityKey(id, persister, EntityMode.Poco));
+ if(loaded != null)
+ {
+ return loaded;
+ }
if (!eager && persister.HasProxy)
{
return persister.CreateProxy(id, this);
}
- object loaded = temporaryPersistenceContext.GetEntity(new EntityKey(id, persister, EntityMode.Poco));
//TODO: if not loaded, throw an exception
- return loaded ?? Get(entityName, id);
+ return Get(entityName, id);
}
public override object ImmediateLoad(string entityName, object id)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs 2009-01-10 20:36:28 UTC (rev 3993)
@@ -0,0 +1,11 @@
+namespace NHibernate.Test.NHSpecificTest.NH1640
+{
+ public class Entity
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string Name { get; set; }
+
+ public virtual Entity Child { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs 2009-01-10 20:36:28 UTC (rev 3993)
@@ -0,0 +1,41 @@
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1640
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void FetchJoinShouldNotReturnProxyTest()
+ {
+ int savedId;
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ var sub = new Entity {Id = 2, Name = "Child 2"};
+ savedId = (int) session.Save(new Entity {Id = 1, Name = "Parent 1", Child = sub});
+ tx.Commit();
+ }
+ }
+
+ using (IStatelessSession session = sessions.OpenStatelessSession())
+ {
+ var parent =
+ session.CreateQuery("from Entity p join fetch p.Child where p.Id=:pId").SetInt32("pId", savedId).UniqueResult
+ <Entity>();
+ Assert.That(parent.Child,Is.TypeOf(typeof (Entity)));
+ }
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Entity");
+ tx.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml 2009-01-10 20:36:28 UTC (rev 3993)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1640">
+
+ <class name="Entity">
+ <id name="Id">
+ <generator class="assigned"/>
+ </id>
+ <property name="Name" />
+ <many-to-one name="Child" cascade="all"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 15:56:55 UTC (rev 3992)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 20:36:28 UTC (rev 3993)
@@ -576,6 +576,8 @@
<Compile Include="NHSpecificTest\NH1621\Model.cs" />
<Compile Include="NHSpecificTest\NH1632\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1632\Model.cs" />
+ <Compile Include="NHSpecificTest\NH1640\Entity.cs" />
+ <Compile Include="NHSpecificTest\NH1640\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1597,6 +1599,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1584\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1612\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-01-10 21:26:38
|
Revision: 3994
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3994&view=rev
Author: fabiomaulo
Date: 2009-01-10 21:26:34 +0000 (Sat, 10 Jan 2009)
Log Message:
-----------
Fix NH-1596 (Support Oracle Lite) by Alexandre Payment
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Dialect/OracleLiteDialect.cs
trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs
Added: trunk/nhibernate/src/NHibernate/Dialect/OracleLiteDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/OracleLiteDialect.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/OracleLiteDialect.cs 2009-01-10 21:26:34 UTC (rev 3994)
@@ -0,0 +1,121 @@
+using System.Data;
+using NHibernate.Dialect.Function;
+using NHibernate.SqlCommand;
+using Environment=NHibernate.Cfg.Environment;
+
+namespace NHibernate.Dialect
+{
+ /// <summary>
+ /// It's a immature version, it just work.
+ /// An SQL dialect for Oracle Lite
+ /// </summary>
+ /// <remarks>
+ /// The OracleLiteDialect defaults the following configuration properties:
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Property</term>
+ /// <description>Default Value</description>
+ /// </listheader>
+ /// <item>
+ /// <term>use_outer_join</term>
+ /// <description><see langword="true" /></description>
+ /// </item>
+ /// <item>
+ /// <term>connection.driver_class</term>
+ /// <description><see cref="NHibernate.Driver.OracleLiteDataClientDriver" /></description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ public class OracleLiteDialect : Oracle9Dialect
+ {
+ /// <summary></summary>
+ public OracleLiteDialect()
+ {
+ DefaultProperties[Environment.PrepareSql] = "false";
+ DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.OracleLiteDataClientDriver";
+
+ RegisterColumnType(DbType.AnsiStringFixedLength, "CHAR(255)");
+ RegisterColumnType(DbType.AnsiStringFixedLength, 2000, "CHAR($l)");
+ RegisterColumnType(DbType.AnsiString, "VARCHAR2(255)");
+ RegisterColumnType(DbType.AnsiString, 2000, "VARCHAR2($l)");
+ RegisterColumnType(DbType.AnsiString, 2147483647, "CLOB"); // should use the IType.ClobType
+ RegisterColumnType(DbType.Binary, "RAW(2000)");
+ RegisterColumnType(DbType.Binary, 2000, "RAW($l)");
+ RegisterColumnType(DbType.Binary, 2147483647, "BLOB");
+ RegisterColumnType(DbType.Boolean, "NUMBER(1,0)");
+ RegisterColumnType(DbType.Byte, "NUMBER(3,0)");
+ RegisterColumnType(DbType.Currency, "NUMBER(19,1)");
+ RegisterColumnType(DbType.Date, "DATE");
+ RegisterColumnType(DbType.DateTime, "TIMESTAMP(4)");
+ RegisterColumnType(DbType.Decimal, "NUMBER(19,5)");
+ RegisterColumnType(DbType.Decimal, 19, "NUMBER(19, $l)");
+ // having problems with both ODP and OracleClient from MS not being able
+ // to read values out of a field that is DOUBLE PRECISION
+ RegisterColumnType(DbType.Double, "DOUBLE PRECISION"); //"FLOAT(53)" );
+ //RegisterColumnType(DbType.Guid, "CHAR(38)");
+ RegisterColumnType(DbType.Int16, "NUMBER(5,0)");
+ RegisterColumnType(DbType.Int32, "NUMBER(10,0)");
+ RegisterColumnType(DbType.Int64, "NUMBER(20,0)");
+ RegisterColumnType(DbType.UInt16, "NUMBER(5,0)");
+ RegisterColumnType(DbType.UInt32, "NUMBER(10,0)");
+ RegisterColumnType(DbType.UInt64, "NUMBER(20,0)");
+ RegisterColumnType(DbType.Single, "FLOAT(24)");
+ RegisterColumnType(DbType.StringFixedLength, "NCHAR(255)");
+ RegisterColumnType(DbType.StringFixedLength, 2000, "NCHAR($l)");
+ RegisterColumnType(DbType.String, "VARCHAR2(255)");
+ RegisterColumnType(DbType.String, 2000, "VARCHAR2($l)");
+ RegisterColumnType(DbType.String, 1073741823, "CLOB");
+ RegisterColumnType(DbType.Time, "DATE");
+
+ RegisterFunction("stddev", new StandardSQLFunction("stddev", NHibernateUtil.Double));
+ RegisterFunction("variance", new StandardSQLFunction("variance", NHibernateUtil.Double));
+
+ RegisterFunction("round", new StandardSQLFunction("round"));
+ RegisterFunction("trunc", new StandardSQLFunction("trunc"));
+ RegisterFunction("ceil", new StandardSQLFunction("ceil"));
+ RegisterFunction("floor", new StandardSQLFunction("floor"));
+
+ RegisterFunction("chr", new StandardSQLFunction("chr", NHibernateUtil.Character));
+ RegisterFunction("initcap", new StandardSQLFunction("initcap"));
+ RegisterFunction("lower", new StandardSQLFunction("lower"));
+ RegisterFunction("ltrim", new StandardSQLFunction("ltrim"));
+ RegisterFunction("rtrim", new StandardSQLFunction("rtrim"));
+ RegisterFunction("upper", new StandardSQLFunction("upper"));
+ RegisterFunction("ascii", new StandardSQLFunction("ascii", NHibernateUtil.Int32));
+ RegisterFunction("length", new StandardSQLFunction("length", NHibernateUtil.Int64));
+
+ RegisterFunction("to_char", new StandardSQLFunction("to_char", NHibernateUtil.String));
+ RegisterFunction("to_date", new StandardSQLFunction("to_date", NHibernateUtil.Timestamp));
+
+ RegisterFunction("last_day", new StandardSQLFunction("last_day", NHibernateUtil.Date));
+ RegisterFunction("sysdate", new NoArgSQLFunction("sysdate", NHibernateUtil.Date, false));
+ RegisterFunction("user", new NoArgSQLFunction("user", NHibernateUtil.String, false));
+
+ // Multi-param string dialect functions...
+ RegisterFunction("concat", new StandardSQLFunction("concat", NHibernateUtil.String));
+ RegisterFunction("instr", new StandardSQLFunction("instr", NHibernateUtil.String));
+ RegisterFunction("instrb", new StandardSQLFunction("instrb", NHibernateUtil.String));
+ RegisterFunction("lpad", new StandardSQLFunction("lpad", NHibernateUtil.String));
+ RegisterFunction("replace", new StandardSQLFunction("replace", NHibernateUtil.String));
+ RegisterFunction("rpad", new StandardSQLFunction("rpad", NHibernateUtil.String));
+ RegisterFunction("substr", new StandardSQLFunction("substr", NHibernateUtil.String));
+ RegisterFunction("substrb", new StandardSQLFunction("substrb", NHibernateUtil.String));
+ RegisterFunction("translate", new StandardSQLFunction("translate", NHibernateUtil.String));
+
+ // Multi-param numeric dialect functions...
+ RegisterFunction("mod", new StandardSQLFunction("mod", NHibernateUtil.Int32));
+ RegisterFunction("nvl", new StandardSQLFunction("nvl"));
+
+ // Multi-param date dialect functions...
+ RegisterFunction("add_months", new StandardSQLFunction("add_months", NHibernateUtil.Date));
+ RegisterFunction("months_between", new StandardSQLFunction("months_between", NHibernateUtil.Single));
+ RegisterFunction("next_day", new StandardSQLFunction("next_day", NHibernateUtil.Date));
+ }
+
+ /// <summary></summary>
+ public override string GetCreateSequenceString(string sequenceName)
+ {
+ return "create sequence " + sequenceName + " INCREMENT BY 1 START WITH 1";
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs 2009-01-10 21:26:34 UTC (rev 3994)
@@ -0,0 +1,68 @@
+using System.Data;
+using NHibernate.AdoNet;
+using NHibernate.SqlTypes;
+
+namespace NHibernate.Driver
+{
+ /// <summary>
+ /// A NHibernate Driver for using the Oracle.DataAccess.Lite DataProvider
+ /// </summary>
+ public class OracleLiteDataClientDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
+ {
+ /// <summary>
+ /// Initializes a new instance of <see cref="OracleLiteDataClientDriver"/>.
+ /// </summary>
+ /// <exception cref="HibernateException">
+ /// Thrown when the <c>Oracle.DataAccess.Lite_w32</c> assembly can not be loaded.
+ /// </exception>
+ public OracleLiteDataClientDriver()
+ : base(
+ "Oracle.DataAccess.Lite_w32",
+ "Oracle.DataAccess.Lite.OracleConnection",
+ "Oracle.DataAccess.Lite.OracleCommand")
+ {
+ }
+
+ /// <summary></summary>
+ public override bool UseNamedPrefixInSql
+ {
+ get { return true; }
+ }
+
+ /// <summary></summary>
+ public override bool UseNamedPrefixInParameter
+ {
+ get { return true; }
+ }
+
+ /// <summary></summary>
+ public override string NamedPrefix
+ {
+ get { return ":"; }
+ }
+
+ /// <remarks>
+ /// This adds logic to ensure that a DbType.Boolean parameter is not created since
+ /// ODP.NET doesn't support it.
+ /// </remarks>
+ protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType)
+ {
+ // if the parameter coming in contains a boolean then we need to convert it
+ // to another type since ODP.NET doesn't support DbType.Boolean
+ if (sqlType.DbType == DbType.Boolean)
+ {
+ sqlType = SqlTypeFactory.Int16;
+ }
+ base.InitializeParameter(dbParam, name, sqlType);
+ }
+
+ #region IEmbeddedBatcherFactoryProvider Members
+
+ System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
+ {
+ get { return typeof (OracleDataClientBatchingBatcherFactory); }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-10 20:36:28 UTC (rev 3993)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-10 21:26:34 UTC (rev 3994)
@@ -445,11 +445,13 @@
<Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" />
<Compile Include="Dialect\InformixDialect0940.cs" />
<Compile Include="Dialect\InformixDialect1000.cs" />
+ <Compile Include="Dialect\OracleLiteDialect.cs" />
<Compile Include="Dialect\Schema\SQLiteMetaData.cs" />
<Compile Include="Dialect\Schema\SybaseAnywhereMetaData.cs" />
<Compile Include="Dialect\SybaseASA10Dialect.cs" />
<Compile Include="Dialect\SybaseASA9Dialect.cs" />
<Compile Include="Driver\IfxDriver.cs" />
+ <Compile Include="Driver\OracleLiteDataClientDriver.cs" />
<Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" />
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
@@ -1151,4 +1153,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
\ 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: <aye...@us...> - 2009-01-12 19:05:15
|
Revision: 3996
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3996&view=rev
Author: ayenderahien
Date: 2009-01-12 19:05:10 +0000 (Mon, 12 Jan 2009)
Log Message:
-----------
NH-1643 - Allowing to use more than just ISet<T> for <set>
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs
trunk/nhibernate/src/NHibernate.Test/App.config
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-12 19:05:10 UTC (rev 3996)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -1121,13 +1121,15 @@
<Compile Include="Util\XmlHelper.cs" />
<Compile Include="Properties\XmlAccessor.cs" />
<EmbeddedResource Include="nhibernate-configuration.xsd">
- <SubType>Designer</SubType>
+ <SubType>
+ </SubType>
</EmbeddedResource>
<None Include="nhibernate-configuration.xsx">
<DependentUpon>nhibernate-configuration.xsd</DependentUpon>
</None>
<EmbeddedResource Include="nhibernate-mapping.xsd">
- <SubType>Designer</SubType>
+ <SubType>
+ </SubType>
</EmbeddedResource>
<None Include="nhibernate-mapping.xsx">
<DependentUpon>nhibernate-mapping.xsd</DependentUpon>
Modified: trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -48,14 +48,22 @@
/// <param name="session">The <see cref="ISessionImplementor"/> for the collection to be a part of.</param>
/// <param name="collection">The unwrapped <see cref="IList{T}"/>.</param>
/// <returns>
- /// An <see cref="PersistentGenericSet<T>"/> that wraps the non NHibernate <see cref="IList<T>"/>.
+ /// An <see cref="PersistentGenericSet<T>"/> that wraps the non NHibernate <see cref="IList{T}"/>.
/// </returns>
public override IPersistentCollection Wrap(ISessionImplementor session, object collection)
{
- return new PersistentGenericSet<T>(session, (ISet<T>) collection);
+ var set = collection as ISet<T>;
+ if(set==null)
+ {
+ var stronglyTypedCollection = collection as ICollection<T>;
+ if(stronglyTypedCollection==null)
+ throw new HibernateException(Role + " must be an implementation of ISet<T> or ICollection<T>");
+ set = new HashedSet<T>(stronglyTypedCollection);
+ }
+ return new PersistentGenericSet<T>(session, set);
}
- public override object Instantiate(int anticipatedSize)
+ public override object Instantiate(int anticipatedSize)
{
return new HashedSet<T>();
}
Modified: trunk/nhibernate/src/NHibernate.Test/App.config
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-12 19:05:10 UTC (rev 3996)
@@ -58,7 +58,7 @@
<!-- This is the System.Data.dll provider for MSSQL Server -->
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">
- Server=(local);initial catalog=nhibernate;Integrated Security=SSPI
+ Server=(local)\sqlexpress;initial catalog=nhibernate;Integrated Security=SSPI
</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1643
+{
+ public class Department
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string Name { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1643
+{
+ public class Employee
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string FirstName { get; set; }
+
+ public virtual string LastName { get; set; }
+
+ private ICollection<Department> department = new List<Department>();
+
+ public virtual ICollection<Department> Departments
+ {
+ get { return department; }
+ set { department = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,61 @@
+using NHibernate.Cfg;
+using NUnit.Framework;
+using NHibernate.Stat;
+
+namespace NHibernate.Test.NHSpecificTest.NH1643
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "NH1643"; }
+ }
+
+ [Test]
+ public void Test()
+ {
+ int employeeId;
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ Department dept = new Department();
+ dept.Id = 11;
+ dept.Name = "Animal Testing";
+
+ sess.Save(dept);
+
+ Employee emp = new Employee();
+ emp.Id = 1;
+ emp.FirstName = "John";
+ emp.LastName = "Doe";
+ emp.Departments.Add(dept);
+
+ sess.Save(emp);
+
+ tx.Commit();
+
+ employeeId = emp.Id;
+ }
+
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ var load = sess.Load<Employee>(employeeId);
+ Assert.AreEqual(1, load.Departments.Count);
+
+ tx.Commit();
+ }
+
+
+
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ sess.Delete("from Employee");
+ sess.Delete("from Department");
+ tx.Commit();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1643"
+ assembly="NHibernate.Test">
+
+ <class name="Department" table="DEPARTMENTS">
+ <id name="Id" column="DEPARTMENT_ID" type="Int32">
+ <generator class="assigned" />
+ </id>
+ <property name="Name" column="DEPARTMENT_NAME" type="String" />
+ </class>
+
+ <class name="Employee" table="EMPLOYEES" >
+ <id name="Id" column="EMPLOYEE_ID" type="Int32">
+ <generator class="assigned" />
+ </id>
+
+ <property name="FirstName" column="FIRST_NAME" type="String" />
+ <property name="LastName" column="LAST_NAME" type="String" />
+
+ <set name="Departments">
+ <key column="Employee"/>
+ <one-to-many class="Department"/>
+ </set>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-12 19:05:10 UTC (rev 3996)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -578,6 +578,9 @@
<Compile Include="NHSpecificTest\NH1632\Model.cs" />
<Compile Include="NHSpecificTest\NH1640\Entity.cs" />
<Compile Include="NHSpecificTest\NH1640\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1643\Department.cs" />
+ <Compile Include="NHSpecificTest\NH1643\Employee.cs" />
+ <Compile Include="NHSpecificTest\NH1643\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1599,6 +1602,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1584\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-01-19 13:40:49
|
Revision: 3998
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3998&view=rev
Author: ayenderahien
Date: 2009-01-19 13:40:38 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
Adding support for ICriteria.Future<T>()
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
trunk/nhibernate/src/NHibernate/ICriteria.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Person.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -283,5 +283,7 @@
/// <summary> Execute a HQL update or delete query</summary>
int ExecuteUpdate(string query, QueryParameters queryParameters);
+
+ FutureCriteriaBatch FutureCriteriaBatch { get; }
}
}
Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -245,6 +245,14 @@
/// </exception>
object UniqueResult();
+ /// <summary>
+ /// Get a enumerable that when enumerated will execute
+ /// a batch of queries in a single database roundtrip
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns></returns>
+ IEnumerable<T> Future<T>();
+
#region NHibernate specific
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -128,8 +128,9 @@
public abstract IDbConnection Connection { get; }
public abstract int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters);
public abstract int ExecuteUpdate(string query, QueryParameters queryParameters);
+ public abstract FutureCriteriaBatch FutureCriteriaBatch { get; }
- public virtual IQuery GetNamedQuery(string queryName)
+ public virtual IQuery GetNamedQuery(string queryName)
{
CheckAndUpdateSessionStatus();
NamedQueryDefinition nqd = factory.GetNamedQuery(queryName);
Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -371,7 +371,13 @@
return new Subcriteria(this, this, associationPath, alias, joinType);
}
- public object UniqueResult()
+ public IEnumerable<T> Future<T>()
+ {
+ session.FutureCriteriaBatch.Add(this);
+ return session.FutureCriteriaBatch.GetEnumerator<T>();
+ }
+
+ public object UniqueResult()
{
return AbstractQueryImpl.UniqueElement(List());
}
@@ -681,7 +687,12 @@
return root.List();
}
- public void List(IList results)
+ public IEnumerable<T> Future<T>()
+ {
+ return root.Future<T>();
+ }
+
+ public void List(IList results)
{
root.List(results);
}
Added: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -0,0 +1,88 @@
+using System.Collections;
+using System.Collections.Generic;
+
+namespace NHibernate.Impl
+{
+ public class FutureCriteriaBatch
+ {
+ private readonly List<ICriteria> criterias = new List<ICriteria>();
+ private int index;
+ private IList results;
+ private readonly ISession session;
+
+ public FutureCriteriaBatch(ISession session)
+ {
+ this.session = session;
+ }
+
+ public IList Results
+ {
+ get
+ {
+ if (results == null)
+ {
+ var multiCriteria = session.CreateMultiCriteria();
+ foreach (var crit in criterias)
+ {
+ multiCriteria.Add(crit);
+ }
+ results = multiCriteria.List();
+ }
+ return results;
+ }
+ }
+
+ public void Add(ICriteria criteria)
+ {
+ criterias.Add(criteria);
+ index = criterias.Count - 1;
+ }
+
+ public IEnumerable<T> GetEnumerator<T>()
+ {
+ int currentIndex = index;
+ return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
+ }
+
+ #region Nested type: DelayedEnumerator
+
+ private class DelayedEnumerator<T> : IEnumerable<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult result;
+
+ public DelayedEnumerator(GetResult result)
+ {
+ this.result = result;
+ }
+
+ public IEnumerable<T> Enumerable
+ {
+ get
+ {
+ foreach (T item in result())
+ {
+ yield return item;
+ }
+ }
+ }
+
+ #region IEnumerable<T> Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable) Enumerable).GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return Enumerable.GetEnumerator();
+ }
+
+ #endregion
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -49,6 +49,8 @@
[NonSerialized] private readonly EntityMode entityMode = EntityMode.Poco;
+ [NonSerialized] private FutureCriteriaBatch futureCriteriaBatch;
+
[NonSerialized]
private readonly EventListeners listeners;
@@ -248,6 +250,16 @@
CheckAndUpdateSessionStatus();
}
+ public override FutureCriteriaBatch FutureCriteriaBatch
+ {
+ get
+ {
+ if (futureCriteriaBatch == null)
+ futureCriteriaBatch = new FutureCriteriaBatch(this);
+ return futureCriteriaBatch;
+ }
+ }
+
/// <summary></summary>
public override IBatcher Batcher
{
@@ -2212,6 +2224,7 @@
return result;
}
+
public override IEntityPersister GetEntityPersister(string entityName, object obj)
{
CheckAndUpdateSessionStatus();
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -813,7 +813,12 @@
return result;
}
- public override IEntityPersister GetEntityPersister(string entityName, object obj)
+ public override FutureCriteriaBatch FutureCriteriaBatch
+ {
+ get { throw new System.NotSupportedException("future queries are not supported for stateless session"); }
+ }
+
+ public override IEntityPersister GetEntityPersister(string entityName, object obj)
{
CheckAndUpdateSessionStatus();
if (entityName == null)
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-19 13:40:38 UTC (rev 3998)
@@ -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>
@@ -456,6 +456,7 @@
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
<Compile Include="Id\SelectGenerator.cs" />
+ <Compile Include="Impl\FutureCriteriaBatch.cs" />
<Compile Include="Properties\BackFieldStrategy.cs" />
<Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" />
<Compile Include="Bytecode\IAccessOptimizer.cs" />
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -0,0 +1,58 @@
+using NHibernate.Impl;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Futures
+{
+ using System.Collections;
+
+ [TestFixture]
+ public class Fixture : TestCase
+ {
+
+ protected override IList Mappings
+ {
+ get { return new string[] { "NHSpecificTest.Futures.Mappings.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ [Test]
+ public void CanUseFutureCriteria()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if(((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ var persons10 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(10)
+ .Future<Person>();
+ var persons5 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(5)
+ .Future<int>();
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ foreach (var person in persons5)
+ {
+
+ }
+
+ foreach (var person in persons10)
+ {
+
+ }
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(1, events.Length);
+ }
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Mappings.hbm.xml 2009-01-19 13:40:38 UTC (rev 3998)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Futures"
+ assembly="NHibernate.Test">
+
+ <class name="Person">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <many-to-one name="Parent" />
+ <list name="Children" cascade="all">
+ <key column="parent_id" />
+ <index column="child_index" />
+ <one-to-many class="Person" />
+ </list>
+ <list name="Friends" cascade="save-update">
+ <key column="friend_id" />
+ <index column="friend_index" />
+ <one-to-many class="Person" />
+ </list>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Person.cs 2009-01-19 13:40:38 UTC (rev 3998)
@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.Futures
+{
+ public class Person
+ {
+ private IList<Person> children = new List<Person>();
+ private IList<Person> friends = new List<Person>();
+ private int id;
+ private Person parent;
+
+ public virtual Person Parent
+ {
+ get { return parent; }
+ set { parent = value; }
+ }
+
+ public virtual IList<Person> Friends
+ {
+ get { return friends; }
+ set { friends = value; }
+ }
+
+ public virtual IList<Person> Children
+ {
+ get { return children; }
+ set { children = value; }
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-18 19:57:19 UTC (rev 3997)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-19 13:40:38 UTC (rev 3998)
@@ -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>
@@ -373,6 +373,8 @@
<Compile Include="NHSpecificTest\BasicTimeFixture.cs" />
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
+ <Compile Include="NHSpecificTest\Futures\Fixture.cs" />
+ <Compile Include="NHSpecificTest\Futures\Person.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
@@ -1602,6 +1604,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1584\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-01-23 07:13:20
|
Revision: 3999
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3999&view=rev
Author: ayenderahien
Date: 2009-01-23 07:13:16 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
applying patch from Ken Tong - NH 1645
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-23 07:13:16 UTC (rev 3999)
@@ -128,7 +128,7 @@
public abstract IDbConnection Connection { get; }
public abstract int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters);
public abstract int ExecuteUpdate(string query, QueryParameters queryParameters);
- public abstract FutureCriteriaBatch FutureCriteriaBatch { get; }
+ public abstract FutureCriteriaBatch FutureCriteriaBatch { get; internal set; }
public virtual IQuery GetNamedQuery(string queryName)
{
Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-19 13:40:38 UTC (rev 3998)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 07:13:16 UTC (rev 3999)
@@ -27,6 +27,7 @@
multiCriteria.Add(crit);
}
results = multiCriteria.List();
+ ((SessionImpl)session).FutureCriteriaBatch = null;
}
return results;
}
@@ -85,4 +86,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-23 07:13:16 UTC (rev 3999)
@@ -258,6 +258,10 @@
futureCriteriaBatch = new FutureCriteriaBatch(this);
return futureCriteriaBatch;
}
+ internal set
+ {
+ futureCriteriaBatch = value;
+ }
}
/// <summary></summary>
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-19 13:40:38 UTC (rev 3998)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-23 07:13:16 UTC (rev 3999)
@@ -816,6 +816,7 @@
public override FutureCriteriaBatch FutureCriteriaBatch
{
get { throw new System.NotSupportedException("future queries are not supported for stateless session"); }
+ internal set { throw new System.NotSupportedException("future queries are not supported for stateless session"); }
}
public override IEntityPersister GetEntityPersister(string entityName, object obj)
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-19 13:40:38 UTC (rev 3998)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-23 07:13:16 UTC (rev 3999)
@@ -54,5 +54,36 @@
}
}
}
+
+ [Test]
+ public void TwoFuturesRunInTwoRoundTrips()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ var persons10 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(10)
+ .Future<Person>();
+
+ foreach (var person in persons10) { } // fire first future round-trip
+
+ var persons5 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(5)
+ .Future<int>();
+
+ foreach (var person in persons5) { } // fire second future round-trip
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(2, events.Length);
+ }
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2009-01-25 19:31:51
|
Revision: 4000
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev
Author: davybrion
Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
implementation for FutureValue<T> method on ICriteria (very similar to the Future<T> implementation)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/ICriteria.cs
trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/IFutureValue.cs
Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 07:13:16 UTC (rev 3999)
+++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 19:31:49 UTC (rev 4000)
@@ -253,6 +253,16 @@
/// <returns></returns>
IEnumerable<T> Future<T>();
+ /// <summary>
+ /// Get an IFutureValue instance, whose value can be retrieved through
+ /// its Value property. The query is not executed until the Value property
+ /// is retrieved, which will execute other Future queries as well in a
+ /// single roundtrip
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns></returns>
+ IFutureValue<T> FutureValue<T>();
+
#region NHibernate specific
/// <summary>
Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IFutureValue.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 19:31:49 UTC (rev 4000)
@@ -0,0 +1,7 @@
+namespace NHibernate
+{
+ public interface IFutureValue<T>
+ {
+ T Value { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-23 07:13:16 UTC (rev 3999)
+++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-25 19:31:49 UTC (rev 4000)
@@ -371,6 +371,12 @@
return new Subcriteria(this, this, associationPath, alias, joinType);
}
+ public IFutureValue<T> FutureValue<T>()
+ {
+ session.FutureCriteriaBatch.Add(this);
+ return session.FutureCriteriaBatch.GetFutureValue<T>();
+ }
+
public IEnumerable<T> Future<T>()
{
session.FutureCriteriaBatch.Add(this);
@@ -687,6 +693,11 @@
return root.List();
}
+ public IFutureValue<T> FutureValue<T>()
+ {
+ return root.FutureValue<T>();
+ }
+
public IEnumerable<T> Future<T>()
{
return root.Future<T>();
Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 07:13:16 UTC (rev 3999)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-25 19:31:49 UTC (rev 4000)
@@ -3,87 +3,124 @@
namespace NHibernate.Impl
{
- public class FutureCriteriaBatch
- {
- private readonly List<ICriteria> criterias = new List<ICriteria>();
- private int index;
- private IList results;
- private readonly ISession session;
+ public class FutureCriteriaBatch
+ {
+ private readonly List<ICriteria> criterias = new List<ICriteria>();
+ private int index;
+ private IList results;
+ private readonly ISession session;
- public FutureCriteriaBatch(ISession session)
- {
- this.session = session;
- }
+ public FutureCriteriaBatch(ISession session)
+ {
+ this.session = session;
+ }
- public IList Results
- {
- get
- {
- if (results == null)
- {
- var multiCriteria = session.CreateMultiCriteria();
- foreach (var crit in criterias)
- {
- multiCriteria.Add(crit);
- }
- results = multiCriteria.List();
- ((SessionImpl)session).FutureCriteriaBatch = null;
- }
- return results;
- }
- }
+ public IList Results
+ {
+ get
+ {
+ if (results == null)
+ {
+ var multiCriteria = session.CreateMultiCriteria();
+ foreach (var crit in criterias)
+ {
+ multiCriteria.Add(crit);
+ }
+ results = multiCriteria.List();
+ ((SessionImpl)session).FutureCriteriaBatch = null;
+ }
+ return results;
+ }
+ }
- public void Add(ICriteria criteria)
- {
- criterias.Add(criteria);
- index = criterias.Count - 1;
- }
+ public void Add(ICriteria criteria)
+ {
+ criterias.Add(criteria);
+ index = criterias.Count - 1;
+ }
- public IEnumerable<T> GetEnumerator<T>()
- {
- int currentIndex = index;
- return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
- }
+ public IFutureValue<T> GetFutureValue<T>()
+ {
+ int currentIndex = index;
+ return new FutureValue<T>(() => (IList)Results[currentIndex]);
+ }
- #region Nested type: DelayedEnumerator
+ public IEnumerable<T> GetEnumerator<T>()
+ {
+ int currentIndex = index;
+ return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
+ }
- private class DelayedEnumerator<T> : IEnumerable<T>
- {
- public delegate IList GetResult();
+ #region Nested type: FutureValue
- private readonly GetResult result;
+ private class FutureValue<T> : IFutureValue<T>
+ {
+ public delegate IList GetResult();
- public DelayedEnumerator(GetResult result)
- {
- this.result = result;
- }
+ private readonly GetResult getResult;
- public IEnumerable<T> Enumerable
- {
- get
- {
- foreach (T item in result())
- {
- yield return item;
- }
- }
- }
+ public FutureValue(GetResult result)
+ {
+ getResult = result;
+ }
- #region IEnumerable<T> Members
+ public T Value
+ {
+ get
+ {
+ var result = getResult();
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable) Enumerable).GetEnumerator();
- }
+ if (result.Count == 0)
+ {
+ return default(T);
+ }
- public IEnumerator<T> GetEnumerator()
- {
- return Enumerable.GetEnumerator();
- }
+ return (T)result[0];
+ }
+ }
+ }
- #endregion
- }
+ #endregion
- #endregion
- }
+ #region Nested type: DelayedEnumerator
+
+ private class DelayedEnumerator<T> : IEnumerable<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult result;
+
+ public DelayedEnumerator(GetResult result)
+ {
+ this.result = result;
+ }
+
+ public IEnumerable<T> Enumerable
+ {
+ get
+ {
+ foreach (T item in result())
+ {
+ yield return item;
+ }
+ }
+ }
+
+ #region IEnumerable<T> Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)Enumerable).GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return Enumerable.GetEnumerator();
+ }
+
+ #endregion
+ }
+
+ #endregion
+ }
}
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 07:13:16 UTC (rev 3999)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 19:31:49 UTC (rev 4000)
@@ -456,6 +456,7 @@
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
<Compile Include="Id\SelectGenerator.cs" />
+ <Compile Include="IFutureValue.cs" />
<Compile Include="Impl\FutureCriteriaBatch.cs" />
<Compile Include="Properties\BackFieldStrategy.cs" />
<Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-23 07:13:16 UTC (rev 3999)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-25 19:31:49 UTC (rev 4000)
@@ -1,3 +1,4 @@
+using NHibernate.Criterion;
using NHibernate.Impl;
using NUnit.Framework;
@@ -85,5 +86,39 @@
}
}
}
+
+ [Test]
+ public void CanCombineSingleFutureValueWithEnumerableFutures()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ var persons = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(10)
+ .Future<Person>();
+
+ var personCount = s.CreateCriteria(typeof(Person))
+ .SetProjection(Projections.RowCount())
+ .FutureValue<int>();
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ int count = personCount.Value;
+
+ foreach (var person in persons)
+ {
+
+ }
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(1, events.Length);
+ }
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Tuna T. <te...@gm...> - 2009-01-25 19:49:40
|
Davy did you create a jira for this? Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: > Revision: 4000 > > http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev > Author: davybrion > Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) > > Log Message: > ----------- > implementation for FutureValue<T> method on ICriteria (very similar to the > Future<T> implementation) > > Modified Paths: > -------------- > trunk/nhibernate/src/NHibernate/ICriteria.cs > trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs > trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs > trunk/nhibernate/src/NHibernate/NHibernate.csproj > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > > Added Paths: > ----------- > trunk/nhibernate/src/NHibernate/IFutureValue.cs > > Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 07:13:16 > UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 19:31:49 > UTC (rev 4000) > @@ -253,6 +253,16 @@ > /// <returns></returns> > IEnumerable<T> Future<T>(); > > + /// <summary> > + /// Get an IFutureValue instance, whose value can be > retrieved through > + /// its Value property. The query is not executed until the > Value property > + /// is retrieved, which will execute other Future queries > as well in a > + /// single roundtrip > + /// </summary> > + /// <typeparam name="T"></typeparam> > + /// <returns></returns> > + IFutureValue<T> FutureValue<T>(); > + > #region NHibernate specific > > /// <summary> > > Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/IFutureValue.cs > (rev 0) > +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 19:31:49 > UTC (rev 4000) > @@ -0,0 +1,7 @@ > +namespace NHibernate > +{ > + public interface IFutureValue<T> > + { > + T Value { get; } > + } > +} > \ No newline at end of file > > Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-23 > 07:13:16 UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-25 > 19:31:49 UTC (rev 4000) > @@ -371,6 +371,12 @@ > return new Subcriteria(this, this, associationPath, > alias, joinType); > } > > + public IFutureValue<T> FutureValue<T>() > + { > + session.FutureCriteriaBatch.Add(this); > + return > session.FutureCriteriaBatch.GetFutureValue<T>(); > + } > + > public IEnumerable<T> Future<T>() > { > session.FutureCriteriaBatch.Add(this); > @@ -687,6 +693,11 @@ > return root.List(); > } > > + public IFutureValue<T> FutureValue<T>() > + { > + return root.FutureValue<T>(); > + } > + > public IEnumerable<T> Future<T>() > { > return root.Future<T>(); > > Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 > 07:13:16 UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-25 > 19:31:49 UTC (rev 4000) > @@ -3,87 +3,124 @@ > > namespace NHibernate.Impl > { > - public class FutureCriteriaBatch > - { > - private readonly List<ICriteria> criterias = new > List<ICriteria>(); > - private int index; > - private IList results; > - private readonly ISession session; > + public class FutureCriteriaBatch > + { > + private readonly List<ICriteria> criterias = new > List<ICriteria>(); > + private int index; > + private IList results; > + private readonly ISession session; > > - public FutureCriteriaBatch(ISession session) > - { > - this.session = session; > - } > + public FutureCriteriaBatch(ISession session) > + { > + this.session = session; > + } > > - public IList Results > - { > - get > - { > - if (results == null) > - { > - var multiCriteria = session.CreateMultiCriteria(); > - foreach (var crit in criterias) > - { > - multiCriteria.Add(crit); > - } > - results = multiCriteria.List(); > - ((SessionImpl)session).FutureCriteriaBatch = null; > - } > - return results; > - } > - } > + public IList Results > + { > + get > + { > + if (results == null) > + { > + var multiCriteria = > session.CreateMultiCriteria(); > + foreach (var crit in criterias) > + { > + multiCriteria.Add(crit); > + } > + results = multiCriteria.List(); > + > ((SessionImpl)session).FutureCriteriaBatch = null; > + } > + return results; > + } > + } > > - public void Add(ICriteria criteria) > - { > - criterias.Add(criteria); > - index = criterias.Count - 1; > - } > + public void Add(ICriteria criteria) > + { > + criterias.Add(criteria); > + index = criterias.Count - 1; > + } > > - public IEnumerable<T> GetEnumerator<T>() > - { > - int currentIndex = index; > - return new DelayedEnumerator<T>(() => > (IList)Results[currentIndex]); > - } > + public IFutureValue<T> GetFutureValue<T>() > + { > + int currentIndex = index; > + return new FutureValue<T>(() => > (IList)Results[currentIndex]); > + } > > - #region Nested type: DelayedEnumerator > + public IEnumerable<T> GetEnumerator<T>() > + { > + int currentIndex = index; > + return new DelayedEnumerator<T>(() => > (IList)Results[currentIndex]); > + } > > - private class DelayedEnumerator<T> : IEnumerable<T> > - { > - public delegate IList GetResult(); > + #region Nested type: FutureValue > > - private readonly GetResult result; > + private class FutureValue<T> : IFutureValue<T> > + { > + public delegate IList GetResult(); > > - public DelayedEnumerator(GetResult result) > - { > - this.result = result; > - } > + private readonly GetResult getResult; > > - public IEnumerable<T> Enumerable > - { > - get > - { > - foreach (T item in result()) > - { > - yield return item; > - } > - } > - } > + public FutureValue(GetResult result) > + { > + getResult = result; > + } > > - #region IEnumerable<T> Members > + public T Value > + { > + get > + { > + var result = getResult(); > > - IEnumerator IEnumerable.GetEnumerator() > - { > - return ((IEnumerable) Enumerable).GetEnumerator(); > - } > + if (result.Count == 0) > + { > + return default(T); > + } > > - public IEnumerator<T> GetEnumerator() > - { > - return Enumerable.GetEnumerator(); > - } > + return (T)result[0]; > + } > + } > + } > > - #endregion > - } > + #endregion > > - #endregion > - } > + #region Nested type: DelayedEnumerator > + > + private class DelayedEnumerator<T> : IEnumerable<T> > + { > + public delegate IList GetResult(); > + > + private readonly GetResult result; > + > + public DelayedEnumerator(GetResult result) > + { > + this.result = result; > + } > + > + public IEnumerable<T> Enumerable > + { > + get > + { > + foreach (T item in result()) > + { > + yield return item; > + } > + } > + } > + > + #region IEnumerable<T> Members > + > + IEnumerator IEnumerable.GetEnumerator() > + { > + return > ((IEnumerable)Enumerable).GetEnumerator(); > + } > + > + public IEnumerator<T> GetEnumerator() > + { > + return Enumerable.GetEnumerator(); > + } > + > + #endregion > + } > + > + #endregion > + } > } > > Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj > =================================================================== > --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 07:13:16 > UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 19:31:49 > UTC (rev 4000) > @@ -456,6 +456,7 @@ > <Compile Include="Exceptions\SqlStateExtracter.cs" /> > <Compile > Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> > <Compile Include="Id\SelectGenerator.cs" /> > + <Compile Include="IFutureValue.cs" /> > <Compile Include="Impl\FutureCriteriaBatch.cs" /> > <Compile Include="Properties\BackFieldStrategy.cs" /> > <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> > > Modified: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > 2009-01-23 07:13:16 UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > 2009-01-25 19:31:49 UTC (rev 4000) > @@ -1,3 +1,4 @@ > +using NHibernate.Criterion; > using NHibernate.Impl; > using NUnit.Framework; > > @@ -85,5 +86,39 @@ > } > } > } > + > + [Test] > + public void > CanCombineSingleFutureValueWithEnumerableFutures() > + { > + using (var s = sessions.OpenSession()) > + { > + if (((SessionFactoryImpl)sessions) > + > .ConnectionProvider.Driver.SupportsMultipleQueries == false) > + { > + Assert.Ignore("Not applicable for > dialects that do not support multiple queries"); > + } > + > + var persons = > s.CreateCriteria(typeof(Person)) > + .SetMaxResults(10) > + .Future<Person>(); > + > + var personCount = > s.CreateCriteria(typeof(Person)) > + > .SetProjection(Projections.RowCount()) > + .FutureValue<int>(); > + > + using (var logSpy = new SqlLogSpy()) > + { > + int count = personCount.Value; > + > + foreach (var person in persons) > + { > + > + } > + > + var events = > logSpy.Appender.GetEvents(); > + Assert.AreEqual(1, events.Length); > + } > + } > + } > } > } > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > |
|
From: Davy B. <ra...@da...> - 2009-01-25 20:23:52
|
nope sorry, i didn't think of it On Sun, Jan 25, 2009 at 8:49 PM, Tuna Toksoz <te...@gm...> wrote: > Davy did you create a jira for this? > > Tuna Toksöz > http://tunatoksoz.com > > Typos included to enhance the readers attention! > > > > > On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: > >> Revision: 4000 >> >> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev >> Author: davybrion >> Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) >> >> Log Message: >> ----------- >> implementation for FutureValue<T> method on ICriteria (very similar to the >> Future<T> implementation) >> >> Modified Paths: >> -------------- >> trunk/nhibernate/src/NHibernate/ICriteria.cs >> trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >> trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >> trunk/nhibernate/src/NHibernate/NHibernate.csproj >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> >> Added Paths: >> ----------- >> trunk/nhibernate/src/NHibernate/IFutureValue.cs >> >> Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -253,6 +253,16 @@ >> /// <returns></returns> >> IEnumerable<T> Future<T>(); >> >> + /// <summary> >> + /// Get an IFutureValue instance, whose value can be >> retrieved through >> + /// its Value property. The query is not executed until >> the Value property >> + /// is retrieved, which will execute other Future queries >> as well in a >> + /// single roundtrip >> + /// </summary> >> + /// <typeparam name="T"></typeparam> >> + /// <returns></returns> >> + IFutureValue<T> FutureValue<T>(); >> + >> #region NHibernate specific >> >> /// <summary> >> >> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/IFutureValue.cs >> (rev 0) >> +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -0,0 +1,7 @@ >> +namespace NHibernate >> +{ >> + public interface IFutureValue<T> >> + { >> + T Value { get; } >> + } >> +} >> \ No newline at end of file >> >> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -371,6 +371,12 @@ >> return new Subcriteria(this, this, associationPath, >> alias, joinType); >> } >> >> + public IFutureValue<T> FutureValue<T>() >> + { >> + session.FutureCriteriaBatch.Add(this); >> + return >> session.FutureCriteriaBatch.GetFutureValue<T>(); >> + } >> + >> public IEnumerable<T> Future<T>() >> { >> session.FutureCriteriaBatch.Add(this); >> @@ -687,6 +693,11 @@ >> return root.List(); >> } >> >> + public IFutureValue<T> FutureValue<T>() >> + { >> + return root.FutureValue<T>(); >> + } >> + >> public IEnumerable<T> Future<T>() >> { >> return root.Future<T>(); >> >> Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -3,87 +3,124 @@ >> >> namespace NHibernate.Impl >> { >> - public class FutureCriteriaBatch >> - { >> - private readonly List<ICriteria> criterias = new >> List<ICriteria>(); >> - private int index; >> - private IList results; >> - private readonly ISession session; >> + public class FutureCriteriaBatch >> + { >> + private readonly List<ICriteria> criterias = new >> List<ICriteria>(); >> + private int index; >> + private IList results; >> + private readonly ISession session; >> >> - public FutureCriteriaBatch(ISession session) >> - { >> - this.session = session; >> - } >> + public FutureCriteriaBatch(ISession session) >> + { >> + this.session = session; >> + } >> >> - public IList Results >> - { >> - get >> - { >> - if (results == null) >> - { >> - var multiCriteria = session.CreateMultiCriteria(); >> - foreach (var crit in criterias) >> - { >> - multiCriteria.Add(crit); >> - } >> - results = multiCriteria.List(); >> - ((SessionImpl)session).FutureCriteriaBatch = null; >> - } >> - return results; >> - } >> - } >> + public IList Results >> + { >> + get >> + { >> + if (results == null) >> + { >> + var multiCriteria = >> session.CreateMultiCriteria(); >> + foreach (var crit in criterias) >> + { >> + multiCriteria.Add(crit); >> + } >> + results = multiCriteria.List(); >> + >> ((SessionImpl)session).FutureCriteriaBatch = null; >> + } >> + return results; >> + } >> + } >> >> - public void Add(ICriteria criteria) >> - { >> - criterias.Add(criteria); >> - index = criterias.Count - 1; >> - } >> + public void Add(ICriteria criteria) >> + { >> + criterias.Add(criteria); >> + index = criterias.Count - 1; >> + } >> >> - public IEnumerable<T> GetEnumerator<T>() >> - { >> - int currentIndex = index; >> - return new DelayedEnumerator<T>(() => >> (IList)Results[currentIndex]); >> - } >> + public IFutureValue<T> GetFutureValue<T>() >> + { >> + int currentIndex = index; >> + return new FutureValue<T>(() => >> (IList)Results[currentIndex]); >> + } >> >> - #region Nested type: DelayedEnumerator >> + public IEnumerable<T> GetEnumerator<T>() >> + { >> + int currentIndex = index; >> + return new DelayedEnumerator<T>(() => >> (IList)Results[currentIndex]); >> + } >> >> - private class DelayedEnumerator<T> : IEnumerable<T> >> - { >> - public delegate IList GetResult(); >> + #region Nested type: FutureValue >> >> - private readonly GetResult result; >> + private class FutureValue<T> : IFutureValue<T> >> + { >> + public delegate IList GetResult(); >> >> - public DelayedEnumerator(GetResult result) >> - { >> - this.result = result; >> - } >> + private readonly GetResult getResult; >> >> - public IEnumerable<T> Enumerable >> - { >> - get >> - { >> - foreach (T item in result()) >> - { >> - yield return item; >> - } >> - } >> - } >> + public FutureValue(GetResult result) >> + { >> + getResult = result; >> + } >> >> - #region IEnumerable<T> Members >> + public T Value >> + { >> + get >> + { >> + var result = getResult(); >> >> - IEnumerator IEnumerable.GetEnumerator() >> - { >> - return ((IEnumerable) Enumerable).GetEnumerator(); >> - } >> + if (result.Count == 0) >> + { >> + return default(T); >> + } >> >> - public IEnumerator<T> GetEnumerator() >> - { >> - return Enumerable.GetEnumerator(); >> - } >> + return (T)result[0]; >> + } >> + } >> + } >> >> - #endregion >> - } >> + #endregion >> >> - #endregion >> - } >> + #region Nested type: DelayedEnumerator >> + >> + private class DelayedEnumerator<T> : IEnumerable<T> >> + { >> + public delegate IList GetResult(); >> + >> + private readonly GetResult result; >> + >> + public DelayedEnumerator(GetResult result) >> + { >> + this.result = result; >> + } >> + >> + public IEnumerable<T> Enumerable >> + { >> + get >> + { >> + foreach (T item in result()) >> + { >> + yield return item; >> + } >> + } >> + } >> + >> + #region IEnumerable<T> Members >> + >> + IEnumerator IEnumerable.GetEnumerator() >> + { >> + return >> ((IEnumerable)Enumerable).GetEnumerator(); >> + } >> + >> + public IEnumerator<T> GetEnumerator() >> + { >> + return Enumerable.GetEnumerator(); >> + } >> + >> + #endregion >> + } >> + >> + #endregion >> + } >> } >> >> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -456,6 +456,7 @@ >> <Compile Include="Exceptions\SqlStateExtracter.cs" /> >> <Compile >> Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> >> <Compile Include="Id\SelectGenerator.cs" /> >> + <Compile Include="IFutureValue.cs" /> >> <Compile Include="Impl\FutureCriteriaBatch.cs" /> >> <Compile Include="Properties\BackFieldStrategy.cs" /> >> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> >> >> Modified: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> 2009-01-23 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> 2009-01-25 19:31:49 UTC (rev 4000) >> @@ -1,3 +1,4 @@ >> +using NHibernate.Criterion; >> using NHibernate.Impl; >> using NUnit.Framework; >> >> @@ -85,5 +86,39 @@ >> } >> } >> } >> + >> + [Test] >> + public void >> CanCombineSingleFutureValueWithEnumerableFutures() >> + { >> + using (var s = sessions.OpenSession()) >> + { >> + if (((SessionFactoryImpl)sessions) >> + >> .ConnectionProvider.Driver.SupportsMultipleQueries == false) >> + { >> + Assert.Ignore("Not applicable for >> dialects that do not support multiple queries"); >> + } >> + >> + var persons = >> s.CreateCriteria(typeof(Person)) >> + .SetMaxResults(10) >> + .Future<Person>(); >> + >> + var personCount = >> s.CreateCriteria(typeof(Person)) >> + >> .SetProjection(Projections.RowCount()) >> + .FutureValue<int>(); >> + >> + using (var logSpy = new SqlLogSpy()) >> + { >> + int count = personCount.Value; >> + >> + foreach (var person in persons) >> + { >> + >> + } >> + >> + var events = >> logSpy.Appender.GetEvents(); >> + Assert.AreEqual(1, events.Length); >> + } >> + } >> + } >> } >> } >> >> >> This was sent by the SourceForge.net collaborative development platform, >> the world's largest Open Source development site. >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > -- Davy Brion http://davybrion.com |
|
From: Tuna T. <te...@gm...> - 2009-01-25 20:25:59
|
No problem =:) Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Sun, Jan 25, 2009 at 9:56 PM, Davy Brion <ra...@da...> wrote: > nope sorry, i didn't think of it > > > On Sun, Jan 25, 2009 at 8:49 PM, Tuna Toksoz <te...@gm...> wrote: > >> Davy did you create a jira for this? >> >> Tuna Toksöz >> http://tunatoksoz.com >> >> Typos included to enhance the readers attention! >> >> >> >> >> On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: >> >>> Revision: 4000 >>> >>> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev >>> Author: davybrion >>> Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) >>> >>> Log Message: >>> ----------- >>> implementation for FutureValue<T> method on ICriteria (very similar to >>> the Future<T> implementation) >>> >>> Modified Paths: >>> -------------- >>> trunk/nhibernate/src/NHibernate/ICriteria.cs >>> trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> >>> Added Paths: >>> ----------- >>> trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> >>> Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -253,6 +253,16 @@ >>> /// <returns></returns> >>> IEnumerable<T> Future<T>(); >>> >>> + /// <summary> >>> + /// Get an IFutureValue instance, whose value can be >>> retrieved through >>> + /// its Value property. The query is not executed until >>> the Value property >>> + /// is retrieved, which will execute other Future queries >>> as well in a >>> + /// single roundtrip >>> + /// </summary> >>> + /// <typeparam name="T"></typeparam> >>> + /// <returns></returns> >>> + IFutureValue<T> FutureValue<T>(); >>> + >>> #region NHibernate specific >>> >>> /// <summary> >>> >>> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> (rev 0) >>> +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -0,0 +1,7 @@ >>> +namespace NHibernate >>> +{ >>> + public interface IFutureValue<T> >>> + { >>> + T Value { get; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -371,6 +371,12 @@ >>> return new Subcriteria(this, this, >>> associationPath, alias, joinType); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + session.FutureCriteriaBatch.Add(this); >>> + return >>> session.FutureCriteriaBatch.GetFutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> session.FutureCriteriaBatch.Add(this); >>> @@ -687,6 +693,11 @@ >>> return root.List(); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + return root.FutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> return root.Future<T>(); >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -3,87 +3,124 @@ >>> >>> namespace NHibernate.Impl >>> { >>> - public class FutureCriteriaBatch >>> - { >>> - private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> - private int index; >>> - private IList results; >>> - private readonly ISession session; >>> + public class FutureCriteriaBatch >>> + { >>> + private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> + private int index; >>> + private IList results; >>> + private readonly ISession session; >>> >>> - public FutureCriteriaBatch(ISession session) >>> - { >>> - this.session = session; >>> - } >>> + public FutureCriteriaBatch(ISession session) >>> + { >>> + this.session = session; >>> + } >>> >>> - public IList Results >>> - { >>> - get >>> - { >>> - if (results == null) >>> - { >>> - var multiCriteria = session.CreateMultiCriteria(); >>> - foreach (var crit in criterias) >>> - { >>> - multiCriteria.Add(crit); >>> - } >>> - results = multiCriteria.List(); >>> - ((SessionImpl)session).FutureCriteriaBatch = null; >>> - } >>> - return results; >>> - } >>> - } >>> + public IList Results >>> + { >>> + get >>> + { >>> + if (results == null) >>> + { >>> + var multiCriteria = >>> session.CreateMultiCriteria(); >>> + foreach (var crit in criterias) >>> + { >>> + multiCriteria.Add(crit); >>> + } >>> + results = multiCriteria.List(); >>> + >>> ((SessionImpl)session).FutureCriteriaBatch = null; >>> + } >>> + return results; >>> + } >>> + } >>> >>> - public void Add(ICriteria criteria) >>> - { >>> - criterias.Add(criteria); >>> - index = criterias.Count - 1; >>> - } >>> + public void Add(ICriteria criteria) >>> + { >>> + criterias.Add(criteria); >>> + index = criterias.Count - 1; >>> + } >>> >>> - public IEnumerable<T> GetEnumerator<T>() >>> - { >>> - int currentIndex = index; >>> - return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> - } >>> + public IFutureValue<T> GetFutureValue<T>() >>> + { >>> + int currentIndex = index; >>> + return new FutureValue<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - #region Nested type: DelayedEnumerator >>> + public IEnumerable<T> GetEnumerator<T>() >>> + { >>> + int currentIndex = index; >>> + return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - private class DelayedEnumerator<T> : IEnumerable<T> >>> - { >>> - public delegate IList GetResult(); >>> + #region Nested type: FutureValue >>> >>> - private readonly GetResult result; >>> + private class FutureValue<T> : IFutureValue<T> >>> + { >>> + public delegate IList GetResult(); >>> >>> - public DelayedEnumerator(GetResult result) >>> - { >>> - this.result = result; >>> - } >>> + private readonly GetResult getResult; >>> >>> - public IEnumerable<T> Enumerable >>> - { >>> - get >>> - { >>> - foreach (T item in result()) >>> - { >>> - yield return item; >>> - } >>> - } >>> - } >>> + public FutureValue(GetResult result) >>> + { >>> + getResult = result; >>> + } >>> >>> - #region IEnumerable<T> Members >>> + public T Value >>> + { >>> + get >>> + { >>> + var result = getResult(); >>> >>> - IEnumerator IEnumerable.GetEnumerator() >>> - { >>> - return ((IEnumerable) Enumerable).GetEnumerator(); >>> - } >>> + if (result.Count == 0) >>> + { >>> + return default(T); >>> + } >>> >>> - public IEnumerator<T> GetEnumerator() >>> - { >>> - return Enumerable.GetEnumerator(); >>> - } >>> + return (T)result[0]; >>> + } >>> + } >>> + } >>> >>> - #endregion >>> - } >>> + #endregion >>> >>> - #endregion >>> - } >>> + #region Nested type: DelayedEnumerator >>> + >>> + private class DelayedEnumerator<T> : IEnumerable<T> >>> + { >>> + public delegate IList GetResult(); >>> + >>> + private readonly GetResult result; >>> + >>> + public DelayedEnumerator(GetResult result) >>> + { >>> + this.result = result; >>> + } >>> + >>> + public IEnumerable<T> Enumerable >>> + { >>> + get >>> + { >>> + foreach (T item in result()) >>> + { >>> + yield return item; >>> + } >>> + } >>> + } >>> + >>> + #region IEnumerable<T> Members >>> + >>> + IEnumerator IEnumerable.GetEnumerator() >>> + { >>> + return >>> ((IEnumerable)Enumerable).GetEnumerator(); >>> + } >>> + >>> + public IEnumerator<T> GetEnumerator() >>> + { >>> + return Enumerable.GetEnumerator(); >>> + } >>> + >>> + #endregion >>> + } >>> + >>> + #endregion >>> + } >>> } >>> >>> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -456,6 +456,7 @@ >>> <Compile Include="Exceptions\SqlStateExtracter.cs" /> >>> <Compile >>> Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> >>> <Compile Include="Id\SelectGenerator.cs" /> >>> + <Compile Include="IFutureValue.cs" /> >>> <Compile Include="Impl\FutureCriteriaBatch.cs" /> >>> <Compile Include="Properties\BackFieldStrategy.cs" /> >>> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> >>> >>> Modified: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -1,3 +1,4 @@ >>> +using NHibernate.Criterion; >>> using NHibernate.Impl; >>> using NUnit.Framework; >>> >>> @@ -85,5 +86,39 @@ >>> } >>> } >>> } >>> + >>> + [Test] >>> + public void >>> CanCombineSingleFutureValueWithEnumerableFutures() >>> + { >>> + using (var s = sessions.OpenSession()) >>> + { >>> + if (((SessionFactoryImpl)sessions) >>> + >>> .ConnectionProvider.Driver.SupportsMultipleQueries == false) >>> + { >>> + Assert.Ignore("Not applicable for >>> dialects that do not support multiple queries"); >>> + } >>> + >>> + var persons = >>> s.CreateCriteria(typeof(Person)) >>> + .SetMaxResults(10) >>> + .Future<Person>(); >>> + >>> + var personCount = >>> s.CreateCriteria(typeof(Person)) >>> + >>> .SetProjection(Projections.RowCount()) >>> + .FutureValue<int>(); >>> + >>> + using (var logSpy = new SqlLogSpy()) >>> + { >>> + int count = personCount.Value; >>> + >>> + foreach (var person in persons) >>> + { >>> + >>> + } >>> + >>> + var events = >>> logSpy.Appender.GetEvents(); >>> + Assert.AreEqual(1, >>> events.Length); >>> + } >>> + } >>> + } >>> } >>> } >>> >>> >>> This was sent by the SourceForge.net collaborative development platform, >>> the world's largest Open Source development site. >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword >>> _______________________________________________ >>> Nhibernate-commit mailing list >>> Nhi...@li... >>> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >>> >> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> >> > > > -- > Davy Brion > http://davybrion.com > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > |
|
From: Dario Q. <con...@da...> - 2009-01-25 23:01:03
|
You can create a new one and mark it as closed, just for tracking, and later we can obtain the release notes automatically from Jira. On Sun, Jan 25, 2009 at 5:56 PM, Davy Brion <ra...@da...> wrote: > nope sorry, i didn't think of it > > > On Sun, Jan 25, 2009 at 8:49 PM, Tuna Toksoz <te...@gm...> wrote: > >> Davy did you create a jira for this? >> >> Tuna Toksöz >> http://tunatoksoz.com >> >> Typos included to enhance the readers attention! >> >> >> >> >> On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: >> >>> Revision: 4000 >>> >>> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev >>> Author: davybrion >>> Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) >>> >>> Log Message: >>> ----------- >>> implementation for FutureValue<T> method on ICriteria (very similar to >>> the Future<T> implementation) >>> >>> Modified Paths: >>> -------------- >>> trunk/nhibernate/src/NHibernate/ICriteria.cs >>> trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> >>> Added Paths: >>> ----------- >>> trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> >>> Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -253,6 +253,16 @@ >>> /// <returns></returns> >>> IEnumerable<T> Future<T>(); >>> >>> + /// <summary> >>> + /// Get an IFutureValue instance, whose value can be >>> retrieved through >>> + /// its Value property. The query is not executed until >>> the Value property >>> + /// is retrieved, which will execute other Future queries >>> as well in a >>> + /// single roundtrip >>> + /// </summary> >>> + /// <typeparam name="T"></typeparam> >>> + /// <returns></returns> >>> + IFutureValue<T> FutureValue<T>(); >>> + >>> #region NHibernate specific >>> >>> /// <summary> >>> >>> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> (rev 0) >>> +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -0,0 +1,7 @@ >>> +namespace NHibernate >>> +{ >>> + public interface IFutureValue<T> >>> + { >>> + T Value { get; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -371,6 +371,12 @@ >>> return new Subcriteria(this, this, >>> associationPath, alias, joinType); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + session.FutureCriteriaBatch.Add(this); >>> + return >>> session.FutureCriteriaBatch.GetFutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> session.FutureCriteriaBatch.Add(this); >>> @@ -687,6 +693,11 @@ >>> return root.List(); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + return root.FutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> return root.Future<T>(); >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -3,87 +3,124 @@ >>> >>> namespace NHibernate.Impl >>> { >>> - public class FutureCriteriaBatch >>> - { >>> - private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> - private int index; >>> - private IList results; >>> - private readonly ISession session; >>> + public class FutureCriteriaBatch >>> + { >>> + private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> + private int index; >>> + private IList results; >>> + private readonly ISession session; >>> >>> - public FutureCriteriaBatch(ISession session) >>> - { >>> - this.session = session; >>> - } >>> + public FutureCriteriaBatch(ISession session) >>> + { >>> + this.session = session; >>> + } >>> >>> - public IList Results >>> - { >>> - get >>> - { >>> - if (results == null) >>> - { >>> - var multiCriteria = session.CreateMultiCriteria(); >>> - foreach (var crit in criterias) >>> - { >>> - multiCriteria.Add(crit); >>> - } >>> - results = multiCriteria.List(); >>> - ((SessionImpl)session).FutureCriteriaBatch = null; >>> - } >>> - return results; >>> - } >>> - } >>> + public IList Results >>> + { >>> + get >>> + { >>> + if (results == null) >>> + { >>> + var multiCriteria = >>> session.CreateMultiCriteria(); >>> + foreach (var crit in criterias) >>> + { >>> + multiCriteria.Add(crit); >>> + } >>> + results = multiCriteria.List(); >>> + >>> ((SessionImpl)session).FutureCriteriaBatch = null; >>> + } >>> + return results; >>> + } >>> + } >>> >>> - public void Add(ICriteria criteria) >>> - { >>> - criterias.Add(criteria); >>> - index = criterias.Count - 1; >>> - } >>> + public void Add(ICriteria criteria) >>> + { >>> + criterias.Add(criteria); >>> + index = criterias.Count - 1; >>> + } >>> >>> - public IEnumerable<T> GetEnumerator<T>() >>> - { >>> - int currentIndex = index; >>> - return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> - } >>> + public IFutureValue<T> GetFutureValue<T>() >>> + { >>> + int currentIndex = index; >>> + return new FutureValue<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - #region Nested type: DelayedEnumerator >>> + public IEnumerable<T> GetEnumerator<T>() >>> + { >>> + int currentIndex = index; >>> + return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - private class DelayedEnumerator<T> : IEnumerable<T> >>> - { >>> - public delegate IList GetResult(); >>> + #region Nested type: FutureValue >>> >>> - private readonly GetResult result; >>> + private class FutureValue<T> : IFutureValue<T> >>> + { >>> + public delegate IList GetResult(); >>> >>> - public DelayedEnumerator(GetResult result) >>> - { >>> - this.result = result; >>> - } >>> + private readonly GetResult getResult; >>> >>> - public IEnumerable<T> Enumerable >>> - { >>> - get >>> - { >>> - foreach (T item in result()) >>> - { >>> - yield return item; >>> - } >>> - } >>> - } >>> + public FutureValue(GetResult result) >>> + { >>> + getResult = result; >>> + } >>> >>> - #region IEnumerable<T> Members >>> + public T Value >>> + { >>> + get >>> + { >>> + var result = getResult(); >>> >>> - IEnumerator IEnumerable.GetEnumerator() >>> - { >>> - return ((IEnumerable) Enumerable).GetEnumerator(); >>> - } >>> + if (result.Count == 0) >>> + { >>> + return default(T); >>> + } >>> >>> - public IEnumerator<T> GetEnumerator() >>> - { >>> - return Enumerable.GetEnumerator(); >>> - } >>> + return (T)result[0]; >>> + } >>> + } >>> + } >>> >>> - #endregion >>> - } >>> + #endregion >>> >>> - #endregion >>> - } >>> + #region Nested type: DelayedEnumerator >>> + >>> + private class DelayedEnumerator<T> : IEnumerable<T> >>> + { >>> + public delegate IList GetResult(); >>> + >>> + private readonly GetResult result; >>> + >>> + public DelayedEnumerator(GetResult result) >>> + { >>> + this.result = result; >>> + } >>> + >>> + public IEnumerable<T> Enumerable >>> + { >>> + get >>> + { >>> + foreach (T item in result()) >>> + { >>> + yield return item; >>> + } >>> + } >>> + } >>> + >>> + #region IEnumerable<T> Members >>> + >>> + IEnumerator IEnumerable.GetEnumerator() >>> + { >>> + return >>> ((IEnumerable)Enumerable).GetEnumerator(); >>> + } >>> + >>> + public IEnumerator<T> GetEnumerator() >>> + { >>> + return Enumerable.GetEnumerator(); >>> + } >>> + >>> + #endregion >>> + } >>> + >>> + #endregion >>> + } >>> } >>> >>> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -456,6 +456,7 @@ >>> <Compile Include="Exceptions\SqlStateExtracter.cs" /> >>> <Compile >>> Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> >>> <Compile Include="Id\SelectGenerator.cs" /> >>> + <Compile Include="IFutureValue.cs" /> >>> <Compile Include="Impl\FutureCriteriaBatch.cs" /> >>> <Compile Include="Properties\BackFieldStrategy.cs" /> >>> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> >>> >>> Modified: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -1,3 +1,4 @@ >>> +using NHibernate.Criterion; >>> using NHibernate.Impl; >>> using NUnit.Framework; >>> >>> @@ -85,5 +86,39 @@ >>> } >>> } >>> } >>> + >>> + [Test] >>> + public void >>> CanCombineSingleFutureValueWithEnumerableFutures() >>> + { >>> + using (var s = sessions.OpenSession()) >>> + { >>> + if (((SessionFactoryImpl)sessions) >>> + >>> .ConnectionProvider.Driver.SupportsMultipleQueries == false) >>> + { >>> + Assert.Ignore("Not applicable for >>> dialects that do not support multiple queries"); >>> + } >>> + >>> + var persons = >>> s.CreateCriteria(typeof(Person)) >>> + .SetMaxResults(10) >>> + .Future<Person>(); >>> + >>> + var personCount = >>> s.CreateCriteria(typeof(Person)) >>> + >>> .SetProjection(Projections.RowCount()) >>> + .FutureValue<int>(); >>> + >>> + using (var logSpy = new SqlLogSpy()) >>> + { >>> + int count = personCount.Value; >>> + >>> + foreach (var person in persons) >>> + { >>> + >>> + } >>> + >>> + var events = >>> logSpy.Appender.GetEvents(); >>> + Assert.AreEqual(1, >>> events.Length); >>> + } >>> + } >>> + } >>> } >>> } >>> >>> >>> This was sent by the SourceForge.net collaborative development platform, >>> the world's largest Open Source development site. >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword >>> _______________________________________________ >>> Nhibernate-commit mailing list >>> Nhi...@li... >>> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >>> >> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> >> > > > -- > Davy Brion > http://davybrion.com > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > -- Dario Quintana http://darioquintana.com.ar |
|
From: <kp...@us...> - 2009-01-26 10:27:03
|
Revision: 4001
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4001&view=rev
Author: kpixel
Date: 2009-01-26 10:26:50 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Port "HHH-2884 : SessionFactory close notifications" from Revision 14452 (Hibernate 3.1)
Except SessionFactoryObserver and test/events/CallbackTest
Revision Links:
--------------
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=14452&view=rev
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Event/EventListeners.cs
trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Event/IDestructible.cs
Modified: trunk/nhibernate/src/NHibernate/Event/EventListeners.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/EventListeners.cs 2009-01-25 19:31:49 UTC (rev 4000)
+++ trunk/nhibernate/src/NHibernate/Event/EventListeners.cs 2009-01-26 10:26:50 UTC (rev 4001)
@@ -12,6 +12,8 @@
[Serializable]
public class EventListeners
{
+ private readonly List<object> initializedListeners = new List<object>();
+
private static readonly IDictionary<ListenerType, System.Type> eventInterfaceFromType =
new Dictionary<ListenerType, System.Type>(28);
@@ -607,6 +609,7 @@
private void InitializeListeners(Configuration cfg, object[] list)
{
+ initializedListeners.AddRange(list);
foreach (object i in list)
{
IInitializable initializable = i as IInitializable;
@@ -622,5 +625,24 @@
// todo-events Not ported
return this;
}
+
+ public void DestroyListeners()
+ {
+ try
+ {
+ foreach (object i in initializedListeners)
+ {
+ IDestructible destructible = i as IDestructible;
+ if (destructible != null)
+ {
+ destructible.Cleanup();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new HibernateException("could not destruct listeners", e);
+ }
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Event/IDestructible.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/IDestructible.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Event/IDestructible.cs 2009-01-26 10:26:50 UTC (rev 4001)
@@ -0,0 +1,15 @@
+
+namespace NHibernate.Event
+{
+ /// <summary>
+ /// Contract for listeners which require notification of SessionFactory closing,
+ /// presumably to destroy internal state.
+ /// </summary>
+ public interface IDestructible
+ {
+ /// <summary>
+ /// Notification of <see cref="ISessionFactory"/> shutdown.
+ /// </summary>
+ void Cleanup();
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-01-25 19:31:49 UTC (rev 4000)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-01-26 10:26:50 UTC (rev 4001)
@@ -743,6 +743,8 @@
{
schemaExport.Drop(false, true);
}
+
+ eventListeners.DestroyListeners();
}
public void Evict(System.Type persistentClass, object id)
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 19:31:49 UTC (rev 4000)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-26 10:26:50 UTC (rev 4001)
@@ -452,6 +452,7 @@
<Compile Include="Dialect\SybaseASA9Dialect.cs" />
<Compile Include="Driver\IfxDriver.cs" />
<Compile Include="Driver\OracleLiteDataClientDriver.cs" />
+ <Compile Include="Event\IDestructible.cs" />
<Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" />
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-01-27 03:49:30
|
Revision: 4003
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4003&view=rev
Author: darioquintana
Date: 2009-01-27 03:49:11 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Adding support for IQuery.Future<T>()
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
trunk/nhibernate/src/NHibernate/IQuery.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -285,5 +285,7 @@
int ExecuteUpdate(string query, QueryParameters queryParameters);
FutureCriteriaBatch FutureCriteriaBatch { get; }
+
+ FutureQueryBatch FutureQueryBatch { get; }
}
}
Modified: trunk/nhibernate/src/NHibernate/IQuery.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IQuery.cs 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/IQuery.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -584,5 +584,22 @@
/// "shape" of the query result.
/// </summary>
IQuery SetResultTransformer(IResultTransformer resultTransformer);
+
+ /// <summary>
+ /// Get a enumerable that when enumerated will execute
+ /// a batch of queries in a single database roundtrip
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns></returns>
+ IEnumerable<T> Future<T>();
+
+ /// Get an IFutureValue instance, whose value can be retrieved through
+ /// its Value property. The query is not executed until the Value property
+ /// is retrieved, which will execute other Future queries as well in a
+ /// single roundtrip
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns></returns>
+ IFutureValue<T> FutureValue<T>();
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -826,7 +826,19 @@
return this;
}
- /// <summary> Override the current session cache mode, just for this query.
+ public IEnumerable<T> Future<T>()
+ {
+ session.FutureQueryBatch.Add(this);
+ return session.FutureQueryBatch.GetEnumerator<T>();
+ }
+
+ public IFutureValue<T> FutureValue<T>()
+ {
+ session.FutureQueryBatch.Add(this);
+ return session.FutureQueryBatch.GetFutureValue<T>();
+ }
+
+ /// <summary> Override the current session cache mode, just for this query.
/// </summary>
/// <param name="cacheMode">The cache mode to use. </param>
/// <returns> this (for method chaining) </returns>
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -129,6 +129,7 @@
public abstract int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters);
public abstract int ExecuteUpdate(string query, QueryParameters queryParameters);
public abstract FutureCriteriaBatch FutureCriteriaBatch { get; internal set; }
+ public abstract FutureQueryBatch FutureQueryBatch { get; internal set; }
public virtual IQuery GetNamedQuery(string queryName)
{
Added: trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -0,0 +1,126 @@
+using System.Collections;
+using System.Collections.Generic;
+
+namespace NHibernate.Impl
+{
+ public class FutureQueryBatch
+ {
+ private readonly List<IQuery> queries = new List<IQuery>();
+ private int index;
+ private IList results;
+ private readonly ISession session;
+
+ public FutureQueryBatch(ISession session)
+ {
+ this.session = session;
+ }
+
+ public IList Results
+ {
+ get
+ {
+ if (results == null)
+ {
+ var multiQuery = session.CreateMultiQuery();
+ foreach (var crit in queries)
+ {
+ multiQuery.Add(crit);
+ }
+ results = multiQuery.List();
+ ((SessionImpl)session).FutureQueryBatch = null;
+ }
+ return results;
+ }
+ }
+
+ public void Add(IQuery query)
+ {
+ queries.Add(query);
+ index = queries.Count - 1;
+ }
+
+ public IFutureValue<T> GetFutureValue<T>()
+ {
+ int currentIndex = index;
+ return new FutureValue<T>(() => (IList)Results[currentIndex]);
+ }
+
+ public IEnumerable<T> GetEnumerator<T>()
+ {
+ int currentIndex = index;
+ return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
+ }
+
+ #region Nested type: FutureValue
+
+ private class FutureValue<T> : IFutureValue<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult getResult;
+
+ public FutureValue(GetResult result)
+ {
+ getResult = result;
+ }
+
+ public T Value
+ {
+ get
+ {
+ var result = getResult();
+
+ if (result.Count == 0)
+ {
+ return default(T);
+ }
+
+ return (T)result[0];
+ }
+ }
+ }
+
+ #endregion
+
+ #region Nested type: DelayedEnumerator
+
+ private class DelayedEnumerator<T> : IEnumerable<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult result;
+
+ public DelayedEnumerator(GetResult result)
+ {
+ this.result = result;
+ }
+
+ public IEnumerable<T> Enumerable
+ {
+ get
+ {
+ foreach (T item in result())
+ {
+ yield return item;
+ }
+ }
+ }
+
+ #region IEnumerable<T> Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)Enumerable).GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return Enumerable.GetEnumerator();
+ }
+
+ #endregion
+ }
+
+ #endregion
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -50,6 +50,7 @@
[NonSerialized] private readonly EntityMode entityMode = EntityMode.Poco;
[NonSerialized] private FutureCriteriaBatch futureCriteriaBatch;
+ [NonSerialized] private FutureQueryBatch futureQueryBatch;
[NonSerialized]
private readonly EventListeners listeners;
@@ -264,6 +265,20 @@
}
}
+ public override FutureQueryBatch FutureQueryBatch
+ {
+ get
+ {
+ if (futureQueryBatch == null)
+ futureQueryBatch = new FutureQueryBatch(this);
+ return futureQueryBatch;
+ }
+ internal set
+ {
+ futureQueryBatch = value;
+ }
+ }
+
/// <summary></summary>
public override IBatcher Batcher
{
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -819,6 +819,12 @@
internal set { throw new System.NotSupportedException("future queries are not supported for stateless session"); }
}
+ public override FutureQueryBatch FutureQueryBatch
+ {
+ get { throw new System.NotSupportedException("future queries are not supported for stateless session"); }
+ internal set { throw new System.NotSupportedException("future queries are not supported for stateless session"); }
+ }
+
public override IEntityPersister GetEntityPersister(string entityName, object obj)
{
CheckAndUpdateSessionStatus();
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 03:49:11 UTC (rev 4003)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -458,6 +458,7 @@
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
<Compile Include="Id\SelectGenerator.cs" />
<Compile Include="IFutureValue.cs" />
+ <Compile Include="Impl\FutureQueryBatch.cs" />
<Compile Include="Impl\FutureCriteriaBatch.cs" />
<Compile Include="Properties\BackFieldStrategy.cs" />
<Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs 2009-01-27 03:49:11 UTC (rev 4003)
@@ -0,0 +1,122 @@
+using NHibernate.Criterion;
+using NHibernate.Impl;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Futures
+{
+ using System.Collections;
+
+ [TestFixture]
+ public class FutureQueryFixture : TestCase
+ {
+
+ protected override IList Mappings
+ {
+ get { return new string[] { "NHSpecificTest.Futures.Mappings.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ [Test]
+ public void CanUseFutureQuery()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ var persons10 = s.CreateQuery("from Person")
+ .SetMaxResults(10)
+ .Future<Person>();
+ var persons5 = s.CreateQuery("from Person")
+ .SetMaxResults(5)
+ .Future<int>();
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ foreach (var person in persons5)
+ {
+
+ }
+
+ foreach (var person in persons10)
+ {
+
+ }
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(1, events.Length);
+ }
+ }
+ }
+
+ [Test]
+ public void TwoFuturesRunInTwoRoundTrips()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ var persons10 = s.CreateQuery("from Person")
+ .SetMaxResults(10)
+ .Future<Person>();
+
+ foreach (var person in persons10) { } // fire first future round-trip
+
+ var persons5 = s.CreateQuery("from Person")
+ .SetMaxResults(5)
+ .Future<int>();
+
+ foreach (var person in persons5) { } // fire second future round-trip
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(2, events.Length);
+ }
+ }
+ }
+
+ [Test]
+ public void CanCombineSingleFutureValueWithEnumerableFutures()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ var persons = s.CreateQuery("from Person")
+ .SetMaxResults(10)
+ .Future<Person>();
+
+ var personCount = s.CreateQuery("select count(*) from Person")
+ .FutureValue<long>();
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ long count = personCount.Value;
+
+ foreach (var person in persons)
+ {
+ }
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(1, events.Length);
+ }
+ }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-26 23:00:00 UTC (rev 4002)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-27 03:49:11 UTC (rev 4003)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -373,6 +373,7 @@
<Compile Include="NHSpecificTest\BasicTimeFixture.cs" />
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
+ <Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
<Compile Include="NHSpecificTest\Futures\Fixture.cs" />
<Compile Include="NHSpecificTest\Futures\Person.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-01-27 04:23:21
|
Revision: 4004
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4004&view=rev
Author: darioquintana
Date: 2009-01-27 04:23:01 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Refactoring: DelayedEnumerator and FutureValue moved as outer classes to reuse code.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs
trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs
Added: trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -0,0 +1,42 @@
+using System.Collections;
+using System.Collections.Generic;
+
+namespace NHibernate.Impl
+{
+ internal class DelayedEnumerator<T> : IEnumerable<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult result;
+
+ public DelayedEnumerator(GetResult result)
+ {
+ this.result = result;
+ }
+
+ public IEnumerable<T> Enumerable
+ {
+ get
+ {
+ foreach (T item in result())
+ {
+ yield return item;
+ }
+ }
+ }
+
+ #region IEnumerable<T> Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)Enumerable).GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return Enumerable.GetEnumerator();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-27 03:49:11 UTC (rev 4003)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -50,77 +50,5 @@
int currentIndex = index;
return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
}
-
- #region Nested type: FutureValue
-
- private class FutureValue<T> : IFutureValue<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult getResult;
-
- public FutureValue(GetResult result)
- {
- getResult = result;
- }
-
- public T Value
- {
- get
- {
- var result = getResult();
-
- if (result.Count == 0)
- {
- return default(T);
- }
-
- return (T)result[0];
- }
- }
- }
-
- #endregion
-
- #region Nested type: DelayedEnumerator
-
- private class DelayedEnumerator<T> : IEnumerable<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult result;
-
- public DelayedEnumerator(GetResult result)
- {
- this.result = result;
- }
-
- public IEnumerable<T> Enumerable
- {
- get
- {
- foreach (T item in result())
- {
- yield return item;
- }
- }
- }
-
- #region IEnumerable<T> Members
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)Enumerable).GetEnumerator();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return Enumerable.GetEnumerator();
- }
-
- #endregion
- }
-
- #endregion
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 03:49:11 UTC (rev 4003)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -50,77 +50,5 @@
int currentIndex = index;
return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]);
}
-
- #region Nested type: FutureValue
-
- private class FutureValue<T> : IFutureValue<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult getResult;
-
- public FutureValue(GetResult result)
- {
- getResult = result;
- }
-
- public T Value
- {
- get
- {
- var result = getResult();
-
- if (result.Count == 0)
- {
- return default(T);
- }
-
- return (T)result[0];
- }
- }
- }
-
- #endregion
-
- #region Nested type: DelayedEnumerator
-
- private class DelayedEnumerator<T> : IEnumerable<T>
- {
- public delegate IList GetResult();
-
- private readonly GetResult result;
-
- public DelayedEnumerator(GetResult result)
- {
- this.result = result;
- }
-
- public IEnumerable<T> Enumerable
- {
- get
- {
- foreach (T item in result())
- {
- yield return item;
- }
- }
- }
-
- #region IEnumerable<T> Members
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)Enumerable).GetEnumerator();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return Enumerable.GetEnumerator();
- }
-
- #endregion
- }
-
- #endregion
}
}
Added: trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs 2009-01-27 04:23:01 UTC (rev 4004)
@@ -0,0 +1,31 @@
+using System.Collections;
+
+namespace NHibernate.Impl
+{
+ internal class FutureValue<T> : IFutureValue<T>
+ {
+ public delegate IList GetResult();
+
+ private readonly GetResult getResult;
+
+ public FutureValue(GetResult result)
+ {
+ getResult = result;
+ }
+
+ public T Value
+ {
+ get
+ {
+ var result = getResult();
+
+ if (result.Count == 0)
+ {
+ return default(T);
+ }
+
+ return (T)result[0];
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 03:49:11 UTC (rev 4003)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 04:23:01 UTC (rev 4004)
@@ -458,8 +458,10 @@
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
<Compile Include="Id\SelectGenerator.cs" />
<Compile Include="IFutureValue.cs" />
+ <Compile Include="Impl\DelayedEnumerator.cs" />
<Compile Include="Impl\FutureQueryBatch.cs" />
<Compile Include="Impl\FutureCriteriaBatch.cs" />
+ <Compile Include="Impl\FutureValue.cs" />
<Compile Include="Properties\BackFieldStrategy.cs" />
<Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" />
<Compile Include="Bytecode\IAccessOptimizer.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-01-27 15:01:23
|
Revision: 4005
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4005&view=rev
Author: tehlike
Date: 2009-01-27 15:01:15 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Adding Where to Extra Lazy queries. Fix for NH-1627
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs
trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs
trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs
Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-01-27 04:23:01 UTC (rev 4004)
+++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-01-27 15:01:15 UTC (rev 4005)
@@ -836,15 +836,25 @@
return frag.ToSqlStringFragment(false);
}
-
+ private SqlString AddWhereFragment(SqlString sql)
+ {
+ if (!hasWhere)
+ return sql;
+ var sqlStringBuilder = new SqlStringBuilder(sql);
+ sqlStringBuilder.Add(" and ").Add(sqlWhereString);
+ return sqlStringBuilder.ToSqlString();
+ }
private SqlString GenerateSelectSizeString(bool isIntegerIndexed)
{
string selectValue = isIntegerIndexed
? "max(" + IndexColumnNames[0] + ") + 1"
: "count(" + ElementColumnNames[0] + ")"; //sets, maps, bags
- return
- new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "=").
- AddColumn(selectValue).ToSqlString();
+
+ var sqlString=new SqlSimpleSelectBuilder(dialect, factory)
+ .SetTableName(TableName)
+ .AddWhereFragment(KeyColumnNames, KeyType, "=")
+ .AddColumn(selectValue).ToSqlString();
+ return AddWhereFragment(sqlString);
}
private SqlString GenerateDetectRowByIndexString()
@@ -855,10 +865,14 @@
}
// TODO NH: may be we need something else when Index is mixed with Formula
- return
- new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "=").
- AddWhereFragment(IndexColumnNames, IndexType, "=").AddWhereFragment(indexFormulas, IndexType, "=").AddColumn("1").
- ToSqlString();
+ var sqlString=
+ new SqlSimpleSelectBuilder(dialect, factory)
+ .SetTableName(TableName)
+ .AddWhereFragment(KeyColumnNames, KeyType, "=")
+ .AddWhereFragment(IndexColumnNames, IndexType, "=")
+ .AddWhereFragment(indexFormulas, IndexType, "=")
+ .AddColumn("1").ToSqlString();
+ return AddWhereFragment(sqlString);
}
private SqlString GenerateSelectRowByIndexString()
@@ -868,18 +882,26 @@
return null;
}
- return
- new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "=").
- AddWhereFragment(IndexColumnNames, IndexType, "=").AddWhereFragment(indexFormulas, IndexType, "=").AddColumns(
- ElementColumnNames, elementColumnAliases).AddColumns(indexFormulas, indexColumnAliases).ToSqlString();
+ var sqlString=new SqlSimpleSelectBuilder(dialect, factory)
+ .SetTableName(TableName)
+ .AddWhereFragment(KeyColumnNames, KeyType, "=")
+ .AddWhereFragment(IndexColumnNames, IndexType, "=")
+ .AddWhereFragment(indexFormulas, IndexType, "=")
+ .AddColumns(ElementColumnNames, elementColumnAliases)
+ .AddColumns(indexFormulas, indexColumnAliases).ToSqlString();
+ return AddWhereFragment(sqlString);
}
private SqlString GenerateDetectRowByElementString()
{
- return
- new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "=").
- AddWhereFragment(ElementColumnNames, ElementType, "=").AddWhereFragment(elementFormulas, ElementType, "=").
- AddColumn("1").ToSqlString();
+ var sqlString=
+ new SqlSimpleSelectBuilder(dialect, factory)
+ .SetTableName(TableName)
+ .AddWhereFragment(KeyColumnNames, KeyType, "=")
+ .AddWhereFragment(ElementColumnNames, ElementType, "=")
+ .AddWhereFragment(elementFormulas, ElementType, "=")
+ .AddColumn("1").ToSqlString();
+ return AddWhereFragment(sqlString);
}
protected virtual SelectFragment GenerateSelectFragment(string alias, string columnSuffix)
Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-01-27 04:23:01 UTC (rev 4004)
+++ trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-01-27 15:01:15 UTC (rev 4005)
@@ -21,7 +21,40 @@
{
get { return null; }
}
+ [Test]
+ public void ExtraLazyWithWhereClause()
+ {
+ using(ISession s = OpenSession())
+ using(ITransaction t=s.BeginTransaction())
+ {
+ s.CreateSQLQuery("insert into Users (Name,Password) values('gavin','secret')")
+ .UniqueResult();
+ s.CreateSQLQuery("insert into Photos (Title,Owner) values('PRVaaa','gavin')")
+ .UniqueResult();
+ s.CreateSQLQuery("insert into Photos (Title,Owner) values('PUBbbb','gavin')")
+ .UniqueResult();
+ t.Commit();
+ }
+ using(ISession s = OpenSession())
+ {
+ var gavin = s.Get<User>("gavin");
+ Assert.AreEqual(1, gavin.Photos.Count);
+ Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents));
+ }
+ using(ISession s=OpenSession())
+ using(ITransaction t=s.BeginTransaction())
+ {
+ s.CreateSQLQuery("delete from Photos")
+ .UniqueResult();
+ s.CreateSQLQuery("delete from Users")
+ .UniqueResult();
+
+ t.Commit();
+ }
+ sessions.Evict(typeof(User));
+ sessions.Evict(typeof(Photo));
+ }
[Test]
public void OrphanDelete()
{
Added: trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs 2009-01-27 15:01:15 UTC (rev 4005)
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.Extralazy
+{
+ public class Photo
+ {
+
+ protected Photo() {}
+ public Photo(string title, User owner)
+ {
+ this.Title = title;
+ this.Owner = owner;
+ }
+
+ public virtual string Title
+ {
+ get; set;
+ }
+
+ public virtual User Owner
+ {
+ get; set;
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs 2009-01-27 04:23:01 UTC (rev 4004)
+++ trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs 2009-01-27 15:01:15 UTC (rev 4005)
@@ -9,6 +9,7 @@
private string password;
private IDictionary session = new Hashtable();
private ISet documents = new HashedSet();
+ private ISet photos = new HashedSet();
protected User() {}
public User(string name, string password)
{
@@ -39,5 +40,12 @@
get { return documents; }
set { documents = value; }
}
+
+
+ public virtual ISet Photos
+ {
+ get { return photos; }
+ set { photos = value; }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml 2009-01-27 04:23:01 UTC (rev 4004)
+++ trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml 2009-01-27 15:01:15 UTC (rev 4005)
@@ -25,8 +25,15 @@
<key column="owner"/>
<one-to-many class="Document"/>
</set>
+ <set name="Photos" inverse="true" lazy="true" where="Title like 'PRV%'" cascade="all,delete-orphan">
+ <key column="owner"/>
+ <one-to-many class="Photo"/>
+ </set>
</class>
-
+ <class name="Photo" table="photos">
+ <id name="Title"/>
+ <many-to-one name="Owner" not-null="true"/>
+ </class>
<class name="Document" table="documents">
<id name="Title"/>
<property name="Content" type="string" length="10000"/>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-27 04:23:01 UTC (rev 4004)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-27 15:01:15 UTC (rev 4005)
@@ -224,6 +224,7 @@
<Compile Include="Extralazy\Document.cs" />
<Compile Include="Extralazy\ExtraLazyFixture.cs" />
<Compile Include="Extralazy\Group.cs" />
+ <Compile Include="Extralazy\Photo.cs" />
<Compile Include="Extralazy\SessionAttribute.cs" />
<Compile Include="Extralazy\User.cs" />
<Compile Include="FilterTest\BinaryFiltered.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-01-30 17:35:26
|
Revision: 4006
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4006&view=rev
Author: fabiomaulo
Date: 2009-01-30 17:35:22 +0000 (Fri, 30 Jan 2009)
Log Message:
-----------
Fix NH-1584 by Seth Schubert
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs 2009-01-27 15:01:15 UTC (rev 4005)
+++ trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs 2009-01-30 17:35:22 UTC (rev 4006)
@@ -12,25 +12,35 @@
{
private readonly EntityKey ownerKey;
private readonly string propertyName;
+ private readonly int hashCode;
public AssociationKey(EntityKey ownerKey, string propertyName)
{
this.ownerKey = ownerKey;
this.propertyName = propertyName;
+ hashCode = ownerKey.GetHashCode() ^ propertyName.GetHashCode() ^ ownerKey.EntityName.GetHashCode();
}
public override bool Equals(object that)
{
- if(this==that) return true;
+ // NH : Different behavior for NH-1584
+ if (this == that)
+ {
+ return true;
+ }
- AssociationKey key = that as AssociationKey;
- if(key==null) return false;
- return key.propertyName.Equals(propertyName) && key.ownerKey.Equals(ownerKey);
+ var key = that as AssociationKey;
+ if (key == null)
+ {
+ return false;
+ }
+ return key.propertyName.Equals(propertyName) && key.ownerKey.Equals(ownerKey)
+ && key.ownerKey.EntityName.Equals(ownerKey.EntityName);
}
public override int GetHashCode()
{
- return ownerKey.GetHashCode() ^ propertyName.GetHashCode();
+ return hashCode;
}
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs 2009-01-27 15:01:15 UTC (rev 4005)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs 2009-01-30 17:35:22 UTC (rev 4006)
@@ -6,14 +6,9 @@
namespace NHibernate.Test.NHSpecificTest.NH1584
{
- [TestFixture, Ignore("Not supported yet.")]
+ [TestFixture]
public class TestFixture : BugTestCase
{
- public override string BugNumber
- {
- get { return "NH1584"; }
- }
-
protected override void OnTearDown()
{
using (ISession session = OpenSession())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <fab...@us...> - 2009-02-02 22:16:29
|
Revision: 4013
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4013&view=rev
Author: fabiomaulo
Date: 2009-02-02 21:33:58 +0000 (Mon, 02 Feb 2009)
Log Message:
-----------
- New Oracle dialects
- Updated ignore list in some tests
NOTE : Old Oracle dialects will be removed in a future NH version.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs
trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/DoubleTypeFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs
Added: trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -0,0 +1,19 @@
+using NHibernate.SqlCommand;
+
+namespace NHibernate.Dialect
+{
+ /// <summary>
+ /// A dialect specifically for use with Oracle 10g.
+ /// </summary>
+ /// <remarks>
+ /// The main difference between this dialect and <see cref="Oracle9iDialect"/>
+ /// is the use of "ANSI join syntax" here...
+ /// </remarks>
+ public class Oracle10gDialect : Oracle9iDialect
+ {
+ public override JoinFragment CreateOuterJoinFragment()
+ {
+ return new ANSIJoinFragment();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -0,0 +1,487 @@
+using System;
+using System.Collections;
+using System.Data;
+using NHibernate.Dialect.Function;
+using NHibernate.Engine;
+using NHibernate.SqlCommand;
+using NHibernate.SqlTypes;
+using NHibernate.Type;
+using Environment=NHibernate.Cfg.Environment;
+
+namespace NHibernate.Dialect
+{
+ /// <summary>
+ /// A dialect for Oracle 8i.
+ /// </summary>
+ public class Oracle8iDialect : Dialect
+ {
+ public override string CurrentTimestampSelectString
+ {
+ get { return "select sysdate from dual"; }
+ }
+
+ public override string CurrentTimestampSQLFunctionName
+ {
+ get { return "sysdate"; }
+ }
+
+ public override string AddColumnString
+ {
+ get { return "add"; }
+ }
+
+ public override string CascadeConstraintsString
+ {
+ get { return " cascade constraints"; }
+ }
+
+ public override string QuerySequencesString
+ {
+ get { return "select sequence_name from user_sequences"; }
+ }
+
+ public override string SelectGUIDString
+ {
+ get { return "select rawtohex(sys_guid()) from dual"; }
+ }
+
+ public override string CreateTemporaryTableString
+ {
+ get { return "create global temporary table"; }
+ }
+
+ public override string CreateTemporaryTablePostfix
+ {
+ get { return "on commit delete rows"; }
+ }
+
+ public override bool IsCurrentTimestampSelectStringCallable
+ {
+ get { return false; }
+ }
+
+ public Oracle8iDialect()
+ {
+ RegisterCharacterTypeMappings();
+ RegisterNumericTypeMappings();
+ RegisterDateTimeTypeMappings();
+ RegisterLargeObjectTypeMappings();
+
+ RegisterReverseHibernateTypeMappings();
+
+ RegisterFunctions();
+
+ RegisterDefaultProperties();
+ }
+
+ protected virtual void RegisterCharacterTypeMappings()
+ {
+ RegisterColumnType(DbType.AnsiStringFixedLength, "CHAR(255)");
+ RegisterColumnType(DbType.AnsiStringFixedLength, 2000, "CHAR($l)");
+ RegisterColumnType(DbType.AnsiString, "VARCHAR2(255)");
+ RegisterColumnType(DbType.AnsiString, 4000, "VARCHAR2($l)");
+ RegisterColumnType(DbType.StringFixedLength, "NCHAR(255)");
+ RegisterColumnType(DbType.StringFixedLength, 2000, "NCHAR($l)");
+ RegisterColumnType(DbType.String, "NVARCHAR2(255)");
+ RegisterColumnType(DbType.String, 4000, "NVARCHAR2($l)");
+ }
+
+ protected virtual void RegisterNumericTypeMappings()
+ {
+ RegisterColumnType(DbType.Boolean, "NUMBER(1,0)");
+ RegisterColumnType(DbType.Byte, "NUMBER(3,0)");
+ RegisterColumnType(DbType.Int16, "NUMBER(5,0)");
+ RegisterColumnType(DbType.Int32, "NUMBER(10,0)");
+ RegisterColumnType(DbType.Int64, "NUMBER(20,0)");
+ RegisterColumnType(DbType.UInt16, "NUMBER(5,0)");
+ RegisterColumnType(DbType.UInt32, "NUMBER(10,0)");
+ RegisterColumnType(DbType.UInt64, "NUMBER(20,0)");
+
+ RegisterColumnType(DbType.Currency, "NUMBER(20,2)");
+ RegisterColumnType(DbType.Currency, "NUMBER($p,$s)");
+ RegisterColumnType(DbType.Single, "FLOAT(24)");
+ RegisterColumnType(DbType.Double, "DOUBLE PRECISION");
+ RegisterColumnType(DbType.Double, 19, "NUMBER($p,$s)");
+ RegisterColumnType(DbType.Double, 19, "NUMBER(19, $l)");
+ RegisterColumnType(DbType.Decimal, "NUMBER(19,5)");
+ RegisterColumnType(DbType.Decimal, 19, "NUMBER(19, $l)");
+ RegisterColumnType(DbType.Decimal, 19, "NUMBER($p,$s)");
+ }
+
+ protected virtual void RegisterDateTimeTypeMappings()
+ {
+ RegisterColumnType(DbType.Date, "DATE");
+ RegisterColumnType(DbType.DateTime, "DATE");
+ RegisterColumnType(DbType.Time, "DATE");
+ }
+
+ protected virtual void RegisterLargeObjectTypeMappings()
+ {
+ RegisterColumnType(DbType.Binary, "RAW(2000)");
+ RegisterColumnType(DbType.Binary, 2000, "RAW($l)");
+ RegisterColumnType(DbType.Binary, 2147483647, "BLOB");
+ RegisterColumnType(DbType.AnsiString, 2147483647, "CLOB"); // should use the IType.ClobType
+ RegisterColumnType(DbType.String, 1073741823, "NCLOB");
+ }
+
+ protected virtual void RegisterReverseHibernateTypeMappings() {}
+
+ protected virtual void RegisterFunctions()
+ {
+ RegisterFunction("abs", new StandardSQLFunction("abs"));
+ RegisterFunction("sign", new StandardSQLFunction("sign", NHibernateUtil.Int32));
+
+ RegisterFunction("acos", new StandardSQLFunction("acos", NHibernateUtil.Double));
+ RegisterFunction("asin", new StandardSQLFunction("asin", NHibernateUtil.Double));
+ RegisterFunction("atan", new StandardSQLFunction("atan", NHibernateUtil.Double));
+ RegisterFunction("cos", new StandardSQLFunction("cos", NHibernateUtil.Double));
+ RegisterFunction("cosh", new StandardSQLFunction("cosh", NHibernateUtil.Double));
+ RegisterFunction("exp", new StandardSQLFunction("exp", NHibernateUtil.Double));
+ RegisterFunction("ln", new StandardSQLFunction("ln", NHibernateUtil.Double));
+ RegisterFunction("sin", new StandardSQLFunction("sin", NHibernateUtil.Double));
+ RegisterFunction("sinh", new StandardSQLFunction("sinh", NHibernateUtil.Double));
+ RegisterFunction("stddev", new StandardSQLFunction("stddev", NHibernateUtil.Double));
+ RegisterFunction("sqrt", new StandardSQLFunction("sqrt", NHibernateUtil.Double));
+ RegisterFunction("tan", new StandardSQLFunction("tan", NHibernateUtil.Double));
+ RegisterFunction("tanh", new StandardSQLFunction("tanh", NHibernateUtil.Double));
+ RegisterFunction("variance", new StandardSQLFunction("variance", NHibernateUtil.Double));
+
+ RegisterFunction("round", new StandardSQLFunction("round"));
+ RegisterFunction("trunc", new StandardSQLFunction("trunc"));
+ RegisterFunction("ceil", new StandardSQLFunction("ceil"));
+ RegisterFunction("floor", new StandardSQLFunction("floor"));
+
+ RegisterFunction("chr", new StandardSQLFunction("chr", NHibernateUtil.Character));
+ RegisterFunction("initcap", new StandardSQLFunction("initcap"));
+ RegisterFunction("lower", new StandardSQLFunction("lower"));
+ RegisterFunction("ltrim", new StandardSQLFunction("ltrim"));
+ RegisterFunction("rtrim", new StandardSQLFunction("rtrim"));
+ RegisterFunction("soundex", new StandardSQLFunction("soundex"));
+ RegisterFunction("upper", new StandardSQLFunction("upper"));
+ RegisterFunction("ascii", new StandardSQLFunction("ascii", NHibernateUtil.Int32));
+ RegisterFunction("length", new StandardSQLFunction("length", NHibernateUtil.Int64));
+ RegisterFunction("left", new SQLFunctionTemplate(NHibernateUtil.String, "substr(?1, 1, ?2)"));
+ RegisterFunction("right", new SQLFunctionTemplate(NHibernateUtil.String, "substr(?1, -?2)"));
+
+ RegisterFunction("to_char", new StandardSQLFunction("to_char", NHibernateUtil.String));
+ RegisterFunction("to_date", new StandardSQLFunction("to_date", NHibernateUtil.Timestamp));
+
+ RegisterFunction("current_date", new NoArgSQLFunction("current_date", NHibernateUtil.Date, false));
+ RegisterFunction("current_time", new NoArgSQLFunction("current_timestamp", NHibernateUtil.Time, false));
+ RegisterFunction("current_timestamp", new CurrentTimeStamp());
+
+ RegisterFunction("last_day", new StandardSQLFunction("last_day", NHibernateUtil.Date));
+ RegisterFunction("sysdate", new NoArgSQLFunction("sysdate", NHibernateUtil.Date, false));
+ RegisterFunction("systimestamp", new NoArgSQLFunction("systimestamp", NHibernateUtil.Timestamp, false));
+ RegisterFunction("uid", new NoArgSQLFunction("uid", NHibernateUtil.Int32, false));
+ RegisterFunction("user", new NoArgSQLFunction("user", NHibernateUtil.String, false));
+
+ RegisterFunction("rowid", new NoArgSQLFunction("rowid", NHibernateUtil.Int64, false));
+ RegisterFunction("rownum", new NoArgSQLFunction("rownum", NHibernateUtil.Int64, false));
+
+ // Multi-param string dialect functions...
+ RegisterFunction("instr", new StandardSQLFunction("instr", NHibernateUtil.Int32));
+ RegisterFunction("instrb", new StandardSQLFunction("instrb", NHibernateUtil.Int32));
+ RegisterFunction("lpad", new StandardSQLFunction("lpad", NHibernateUtil.String));
+ RegisterFunction("replace", new StandardSQLFunction("replace", NHibernateUtil.String));
+ RegisterFunction("rpad", new StandardSQLFunction("rpad", NHibernateUtil.String));
+ RegisterFunction("substr", new StandardSQLFunction("substr", NHibernateUtil.String));
+ RegisterFunction("substrb", new StandardSQLFunction("substrb", NHibernateUtil.String));
+ RegisterFunction("translate", new StandardSQLFunction("translate", NHibernateUtil.String));
+
+ RegisterFunction("locate", new LocateFunction());
+ RegisterFunction("substring", new StandardSQLFunction("substr", NHibernateUtil.String));
+ RegisterFunction("locate", new SQLFunctionTemplate(NHibernateUtil.Int32, "instr(?2,?1)"));
+ RegisterFunction("bit_length", new SQLFunctionTemplate(NHibernateUtil.Int32, "vsize(?1)*8"));
+ RegisterFunction("coalesce", new NvlFunction());
+
+ // Multi-param numeric dialect functions...
+ RegisterFunction("atan2", new StandardSQLFunction("atan2", NHibernateUtil.Single));
+ RegisterFunction("log", new StandardSQLFunction("log", NHibernateUtil.Int32));
+ RegisterFunction("mod", new StandardSQLFunction("mod", NHibernateUtil.Int32));
+ RegisterFunction("nvl", new StandardSQLFunction("nvl"));
+ RegisterFunction("nvl2", new StandardSQLFunction("nvl2"));
+ RegisterFunction("power", new StandardSQLFunction("power", NHibernateUtil.Single));
+
+ // Multi-param date dialect functions...
+ RegisterFunction("add_months", new StandardSQLFunction("add_months", NHibernateUtil.Date));
+ RegisterFunction("months_between", new StandardSQLFunction("months_between", NHibernateUtil.Single));
+ RegisterFunction("next_day", new StandardSQLFunction("next_day", NHibernateUtil.Date));
+
+ RegisterFunction("str", new StandardSQLFunction("to_char", NHibernateUtil.String));
+ }
+
+ protected internal virtual void RegisterDefaultProperties()
+ {
+ DefaultProperties[Environment.PrepareSql] = "false";
+ DefaultProperties[Environment.DefaultBatchFetchSize] = DefaultBatchSize;
+ // Oracle driver reports to support GetGeneratedKeys(), but they only
+ // support the version taking an array of the names of the columns to
+ // be returned (via its RETURNING clause). No other driver seems to
+ // support this overloaded version.
+ DefaultProperties[Environment.UseGetGeneratedKeys] = "false";
+ }
+
+ // features which change between 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /// <summary>
+ /// Support for the oracle proprietary join syntax...
+ /// </summary>
+ /// <returns> The orqacle join fragment </returns>
+ public override JoinFragment CreateOuterJoinFragment()
+ {
+ return new OracleJoinFragment();
+ }
+
+ /// <summary>
+ /// Map case support to the Oracle DECODE function. Oracle did not
+ /// add support for CASE until 9i.
+ /// </summary>
+ /// <returns> The oracle CASE -> DECODE fragment </returns>
+ public override CaseFragment CreateCaseFragment()
+ {
+ return new DecodeCaseFragment(this);
+ }
+
+ public override SqlString GetLimitString(SqlString sql, bool hasOffset)
+ {
+ sql = sql.Trim();
+ bool isForUpdate = false;
+ if (sql.EndsWithCaseInsensitive(" for update"))
+ {
+ sql = sql.Substring(0, sql.Length - 11);
+ isForUpdate = true;
+ }
+
+ var pagingSelect = new SqlStringBuilder(sql.Parts.Count + 10);
+ if (hasOffset)
+ {
+ pagingSelect.Add("select * from ( select row_.*, rownum rownum_ from ( ");
+ }
+ else
+ {
+ pagingSelect.Add("select * from ( ");
+ }
+ pagingSelect.Add(sql);
+ if (hasOffset)
+ {
+ pagingSelect.Add(" ) row_ where rownum <=").AddParameter().Add(") where rownum_ >").AddParameter();
+ }
+ else
+ {
+ pagingSelect.Add(" ) where rownum <=").AddParameter();
+ }
+
+ if (isForUpdate)
+ {
+ pagingSelect.Add(" for update");
+ }
+
+ return pagingSelect.ToSqlString();
+ }
+
+ /// <summary>
+ /// Allows access to the basic <see cref="Dialect.GetSelectClauseNullString"/>
+ /// implementation...
+ /// </summary>
+ /// <param name="sqlType">The <see cref="SqlType"/> mapping type</param>
+ /// <returns> The appropriate select cluse fragment </returns>
+ public virtual string GetBasicSelectClauseNullString(SqlType sqlType)
+ {
+ return base.GetSelectClauseNullString(sqlType);
+ }
+
+ public override string GetSelectClauseNullString(SqlType sqlType)
+ {
+ switch (sqlType.DbType)
+ {
+ case DbType.String:
+ case DbType.AnsiString:
+ case DbType.StringFixedLength:
+ case DbType.AnsiStringFixedLength:
+ return "to_char(null)";
+
+ case DbType.Date:
+ case DbType.DateTime:
+ case DbType.Time:
+ return "to_date(null)";
+
+ default:
+ return "to_number(null)";
+ }
+ }
+
+ public override string GetSequenceNextValString(string sequenceName)
+ {
+ return "select " + GetSelectSequenceNextValString(sequenceName) + " from dual";
+ }
+
+ public override string GetSelectSequenceNextValString(string sequenceName)
+ {
+ return sequenceName + ".nextval";
+ }
+
+ public override string GetCreateSequenceString(string sequenceName)
+ {
+ return "create sequence " + sequenceName; //starts with 1, implicitly
+ }
+
+ public override string GetDropSequenceString(string sequenceName)
+ {
+ return "drop sequence " + sequenceName;
+ }
+
+ public override bool DropConstraints
+ {
+ get { return false; }
+ }
+
+ public override string ForUpdateNowaitString
+ {
+ get { return " for update nowait"; }
+ }
+
+ public override bool SupportsSequences
+ {
+ get { return true; }
+ }
+
+ public override bool SupportsPooledSequences
+ {
+ get { return true; }
+ }
+
+ public override bool SupportsLimit
+ {
+ get { return true; }
+ }
+
+ public override string GetForUpdateString(string aliases)
+ {
+ return ForUpdateString + " of " + aliases;
+ }
+
+ public override string GetForUpdateNowaitString(string aliases)
+ {
+ return ForUpdateString + " of " + aliases + " nowait";
+ }
+
+ public override bool BindLimitParametersInReverseOrder
+ {
+ get { return true; }
+ }
+
+ public override bool UseMaxForLimit
+ {
+ get { return true; }
+ }
+
+ public override bool ForUpdateOfColumns
+ {
+ get { return true; }
+ }
+
+ public override bool SupportsUnionAll
+ {
+ get { return true; }
+ }
+
+ public override bool SupportsCommentOn
+ {
+ get { return true; }
+ }
+
+ public override bool SupportsTemporaryTables
+ {
+ get { return true; }
+ }
+
+ public override string GenerateTemporaryTableName(String baseTableName)
+ {
+ string name = base.GenerateTemporaryTableName(baseTableName);
+ return name.Length > 30 ? name.Substring(1, (30) - (1)) : name;
+ }
+
+ public override bool DropTemporaryTableAfterUse()
+ {
+ return false;
+ }
+
+ public override bool SupportsCurrentTimestampSelection
+ {
+ get { return true; }
+ }
+
+ #region Overridden informational metadata
+
+ public override bool SupportsEmptyInList
+ {
+ get { return false; }
+ }
+
+ public override bool SupportsExistsInSelect
+ {
+ get { return false; }
+ }
+
+ #endregion
+
+ #region Functions
+
+ private class CurrentTimeStamp : NoArgSQLFunction
+ {
+ public CurrentTimeStamp() : base("current_timestamp", NHibernateUtil.DateTime, true) {}
+
+ public override SqlString Render(IList args, ISessionFactoryImplementor factory)
+ {
+ return new SqlString(Name);
+ }
+ }
+
+ private class LocateFunction : ISQLFunction
+ {
+ private static readonly ISQLFunction LocateWith2Params = new SQLFunctionTemplate(NHibernateUtil.Int32,
+ "instr(?2, ?1)");
+
+ private static readonly ISQLFunction LocateWith3Params = new SQLFunctionTemplate(NHibernateUtil.Int32,
+ "instr(?2, ?1, ?3)");
+
+ #region Implementation of ISQLFunction
+
+ public IType ReturnType(IType columnType, IMapping mapping)
+ {
+ return NHibernateUtil.Int32;
+ }
+
+ public bool HasArguments
+ {
+ get { return true; }
+ }
+
+ public bool HasParenthesesIfNoArguments
+ {
+ get { return true; }
+ }
+
+ public SqlString Render(IList args, ISessionFactoryImplementor factory)
+ {
+ if (args.Count != 2 && args.Count != 3)
+ {
+ throw new QueryException("'locate' function takes 2 or 3 arguments");
+ }
+ if (args.Count == 2)
+ {
+ return LocateWith2Params.Render(args, factory);
+ }
+ else
+ {
+ return LocateWith3Params.Render(args, factory);
+ }
+ }
+
+ #endregion
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -1,3 +1,4 @@
+using System;
using System.Collections;
using System.Data;
using NHibernate.Dialect.Function;
@@ -30,6 +31,7 @@
/// </item>
/// </list>
/// </remarks>
+ [Obsolete("This dialect will be removed in the next NHibernate version; Use Oracle9iDialect")]
public class Oracle9Dialect : Dialect
{
/// <summary></summary>
Added: trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -0,0 +1,40 @@
+using System.Data;
+using NHibernate.SqlCommand;
+using NHibernate.SqlTypes;
+
+namespace NHibernate.Dialect
+{
+ public class Oracle9iDialect : Oracle8iDialect
+ {
+ public override string CurrentTimestampSelectString
+ {
+ get { return "select systimestamp from dual"; }
+ }
+
+ public override string CurrentTimestampSQLFunctionName
+ {
+ get
+ {
+ // the standard SQL function name is current_timestamp...
+ return "current_timestamp";
+ }
+ }
+
+ protected override void RegisterDateTimeTypeMappings()
+ {
+ RegisterColumnType(DbType.Date, "DATE");
+ RegisterColumnType(DbType.DateTime, "TIMESTAMP(4)");
+ RegisterColumnType(DbType.Time, "TIMESTAMP(4)");
+ }
+ public override string GetSelectClauseNullString(SqlType sqlType)
+ {
+ return GetBasicSelectClauseNullString(sqlType);
+ }
+
+ public override CaseFragment CreateCaseFragment()
+ {
+ // Oracle did add support for ANSI CASE statements in 9i
+ return new ANSICaseFragment(this);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -1,3 +1,4 @@
+using System;
using System.Data;
using NHibernate.SqlCommand;
@@ -6,6 +7,7 @@
/// <summary>
/// An SQL dialect for Oracle, compatible with Oracle 8.
/// </summary>
+ [Obsolete("This dialect will be removed in the next NHibernate version; Use Oracle8iDialect")]
public class OracleDialect : Oracle9Dialect
{
public OracleDialect()
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-02 21:33:58 UTC (rev 4013)
@@ -450,6 +450,9 @@
<Compile Include="Dialect\MsSql2008Dialect.cs" />
<Compile Include="Dialect\InformixDialect0940.cs" />
<Compile Include="Dialect\InformixDialect1000.cs" />
+ <Compile Include="Dialect\Oracle10gDialect.cs" />
+ <Compile Include="Dialect\Oracle8iDialect.cs" />
+ <Compile Include="Dialect\Oracle9iDialect.cs" />
<Compile Include="Dialect\OracleLiteDialect.cs" />
<Compile Include="Dialect\Schema\SQLiteMetaData.cs" />
<Compile Include="Dialect\Schema\SybaseAnywhereMetaData.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -22,30 +22,32 @@
[Test]
public void RefreshCascade()
{
- ISession session = OpenSession();
- ITransaction txn = session.BeginTransaction();
+ using(ISession session = OpenSession())
+ {
+ using (ITransaction txn = session.BeginTransaction())
+ {
+ JobBatch batch = new JobBatch(DateTime.Now);
+ batch.CreateJob().ProcessingInstructions = "Just do it!";
+ batch.CreateJob().ProcessingInstructions = "I know you can do it!";
- JobBatch batch = new JobBatch(DateTime.Now);
- batch.CreateJob().ProcessingInstructions = "Just do it!";
- batch.CreateJob().ProcessingInstructions = "I know you can do it!";
+ // write the stuff to the database; at this stage all job.status values are zero
+ session.Persist(batch);
+ session.Flush();
- // write the stuff to the database; at this stage all job.status values are zero
- session.Persist(batch);
- session.Flush();
+ // behind the session's back, let's modify the statuses
+ UpdateStatuses(session);
- // behind the session's back, let's modify the statuses
- UpdateStatuses(session);
+ // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
+ session.Refresh(batch);
- // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
- session.Refresh(batch);
+ foreach (Job job in batch.Jobs)
+ {
+ Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!");
+ }
- foreach (Job job in batch.Jobs)
- {
- Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!");
+ txn.Rollback();
+ }
}
-
- txn.Rollback();
- session.Close();
}
private void UpdateStatuses(ISession session)
@@ -62,33 +64,38 @@
public void RefreshIgnoringTransient()
{
// No exception expected
- ISession session = OpenSession();
- ITransaction txn = session.BeginTransaction();
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction txn = session.BeginTransaction())
+ {
+ var batch = new JobBatch(DateTime.Now);
+ session.Refresh(batch);
- var batch = new JobBatch(DateTime.Now);
- session.Refresh(batch);
-
- txn.Rollback();
- session.Close();
+ txn.Rollback();
+ }
+ }
}
[Test]
public void RefreshIgnoringTransientInCollection()
{
- ISession session = OpenSession();
- ITransaction txn = session.BeginTransaction();
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction txn = session.BeginTransaction())
+ {
- var batch = new JobBatch(DateTime.Now);
- batch.CreateJob().ProcessingInstructions = "Just do it!";
- session.Persist(batch);
- session.Flush();
+ var batch = new JobBatch(DateTime.Now);
+ batch.CreateJob().ProcessingInstructions = "Just do it!";
+ session.Persist(batch);
+ session.Flush();
- batch.CreateJob().ProcessingInstructions = "I know you can do it!";
- session.Refresh(batch);
- Assert.That(batch.Jobs.Count == 1);
+ batch.CreateJob().ProcessingInstructions = "I know you can do it!";
+ session.Refresh(batch);
+ Assert.That(batch.Jobs.Count == 1);
- txn.Rollback();
- session.Close();
+ txn.Rollback();
+ }
+ }
}
[Test]
Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -20,7 +20,7 @@
notSupportedStandardFunction.Add("locate",
new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) });
notSupportedStandardFunction.Add("bit_length",
- new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) });
+ new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect), typeof(Oracle9Dialect), typeof(OracleDialect), typeof(Oracle8iDialect), typeof(Oracle9iDialect), typeof(Oracle10gDialect) });
notSupportedStandardFunction.Add("extract",
new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) });
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -1,5 +1,6 @@
using System.Text;
using NHibernate.Cfg;
+using NHibernate.Dialect;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
@@ -9,6 +10,12 @@
[TestFixture]
public class Fixture
{
+ private static void CheckDialect(Configuration configuration)
+ {
+ if (!configuration.Properties[Environment.Dialect].Contains("MsSql"))
+ Assert.Ignore("Specific test for MsSQL dialects");
+ }
+
private static void AssertThatCheckOnTableExistenceIsCorrect(Configuration configuration)
{
var su = new SchemaExport(configuration);
@@ -22,6 +29,7 @@
public void TestForClassWithDefaultSchema()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ CheckDialect(cfg);
cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithNothing.hbm.xml", GetType().Assembly);
cfg.SetProperty(Environment.DefaultCatalog, "nhibernate");
cfg.SetProperty(Environment.DefaultSchema, "dbo");
@@ -32,6 +40,7 @@
public void WithDefaultValuesInMapping()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ CheckDialect(cfg);
cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithDefault.hbm.xml", GetType().Assembly);
AssertThatCheckOnTableExistenceIsCorrect(cfg);
}
@@ -40,6 +49,7 @@
public void WithSpecificValuesInMapping()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ CheckDialect(cfg);
cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithSpecific.hbm.xml", GetType().Assembly);
AssertThatCheckOnTableExistenceIsCorrect(cfg);
}
@@ -48,6 +58,7 @@
public void WithDefaultValuesInConfigurationPriorityToMapping()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ CheckDialect(cfg);
cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithDefault.hbm.xml", GetType().Assembly);
cfg.SetProperty(Environment.DefaultCatalog, "somethingDifferent");
cfg.SetProperty(Environment.DefaultSchema, "somethingDifferent");
Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs 2009-02-02 20:48:55 UTC (rev 4012)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs 2009-02-02 21:33:58 UTC (rev 4013)
@@ -77,9 +77,9 @@
[Test]
public void InsertZeroLength()
{
- if (typeof(Oracle9Dialect).IsInstanceOfType(Dialect))
+ if (Dialect is Oracle9Dialect || Dialect is Oracle8iDialect)
{
- return;
+ Assert.Ignore("Certain drivers (ie - Oralce) don't handle writing and reading byte[0]");
}
BinaryClass bcBinary = new BinaryClas...
[truncated message content] |
|
From: <dar...@us...> - 2009-02-04 02:49:05
|
Revision: 4028
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4028&view=rev
Author: darioquintana
Date: 2009-02-04 02:48:45 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Minor: Fixing indentation and renaming a test.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs
trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs
trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs
Modified: trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -115,15 +115,15 @@
/// </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 DateTime2 = new DateTime2Type();
- /// <summary>
- /// NHibernate date type
- /// </summary>
- public static readonly NullableType DateTimeOffset = new DateTimeOffsetType();
+ /// <summary>
+ /// NHibernate date type
+ /// </summary>
+ public static readonly NullableType DateTimeOffset = new DateTimeOffsetType();
/// <summary>
/// NHibernate date type
Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -25,8 +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 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);
Modified: trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -4,20 +4,20 @@
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)
- {
- }
+ /// <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"; }
- }
- }
+ public override string Name
+ {
+ get { return "DateTime2"; }
+ }
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -6,119 +6,119 @@
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)
- {
- }
+ /// <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 string Name
+ {
+ get { return "DateTimeOffset"; }
+ }
- public override System.Type ReturnedClass
- {
- get
- {
- return typeof(DateTimeOffset);
- }
- }
+ public override System.Type ReturnedClass
+ {
+ get { return typeof (DateTimeOffset); }
+ }
- public override System.Type PrimitiveClass
- {
- 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 IComparer Comparator
- {
- get { return Comparer<DateTimeOffset>.Default; }
- }
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ var 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 bool IsEqual(object x, object y)
- {
- if (x == y)
- {
- return true;
- }
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ var 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);
+ }
+ }
- if (x == null || y == null)
- {
- return false;
- }
+ public override bool IsEqual(object x, object y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
- DateTimeOffset date1 = (DateTimeOffset)x;
- DateTimeOffset date2 = (DateTimeOffset)y;
+ if (x == null || y == null)
+ {
+ return false;
+ }
- if (date1.Equals(date2))
- return true;
+ var date1 = (DateTimeOffset) x;
+ var date2 = (DateTimeOffset) y;
- 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);
- }
+ if (date1.Equals(date2))
+ return true;
- 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;
- }
+ 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 string ToString(object val)
- {
- return ((DateTimeOffset)val).ToString();
- }
-
- public override object FromStringValue(string xml)
- {
- return DateTimeOffset.Parse(xml);
- }
+ public override int GetHashCode(object x, EntityMode entityMode)
+ {
+ // Custom hash code implementation because DateTimeType is only accurate
+ // up to seconds.
+ var 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 ObjectToSQLString(object value, Dialect.Dialect dialect)
- {
- return "'" + ((DateTimeOffset)value) + "'";
- }
- }
+ 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-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -26,9 +26,9 @@
{
}
- public DateTimeType(SqlType sqlTypeDateTime) : base(sqlTypeDateTime)
- {
- }
+ public DateTimeType(SqlType sqlTypeDateTime) : base(sqlTypeDateTime)
+ {
+ }
/// <summary></summary>
public override string Name
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -108,11 +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");
+ /*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(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/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -2,14 +2,14 @@
namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
{
- public class AllDates
- {
- public int Id { get; set; }
+ public class AllDates
+ {
+ public int Id { get; set; }
- public DateTime Sql_datetime { get; set; }
+ public DateTime Sql_datetime { get; set; }
- public DateTime Sql_datetime2 { get; set; }
+ public DateTime Sql_datetime2 { get; set; }
- public DateTimeOffset Sql_datetimeoffset { get; set; }
- }
+ public DateTimeOffset Sql_datetimeoffset { get; set; }
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs 2009-02-03 22:49:04 UTC (rev 4027)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs 2009-02-04 02:48:45 UTC (rev 4028)
@@ -6,81 +6,80 @@
namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
{
- [TestFixture]
- public class DateTime2AndDateTimeOffSetFixture : TestCase
- {
- protected override IList Mappings
- {
- get { return new[] { "NHSpecificTest.DateTime2AndDateTimeOffSet.Mappings.hbm.xml" }; }
- }
+ [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 string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
- protected override bool AppliesTo(Dialect.Dialect dialect)
- {
- return dialect is MsSql2008Dialect;
- }
-
+ 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,
- };
+ public class DateTimeAssert
+ {
+ public static void AreEqual(DateTime dt1, DateTime dt2)
+ {
+ bool areEqual = new DateTimeType().IsEqual(dt1, dt2);
- using(ISession s = OpenSession())
- using(ITransaction tx = s.BeginTransaction())
- {
- s.Save(dates);
- tx.Commit();
- }
+ if (!areEqual)
+ Assert.Fail("Expected {0} but was {1}");
+ }
- 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);
- }
+ public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
+ {
+ bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
- using(ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
- s.Delete(datesRecovered);
- tx.Commit();
- }
- }
+ if (!areEqual)
+ Assert.Fail("Expected {0} but was {1}");
+ }
+ }
- public class DateTimeAssert
- {
- public static void AreEqual(DateTime dt1,DateTime dt2)
- {
- bool areEqual = new DateTimeType().IsEqual(dt1,dt2);
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ DateTime Now = DateTime.Now;
+ DateTimeOffset NowOS = DateTimeOffset.Now;
+ var dates = new AllDates
+ {
+ Sql_datetime = Now,
+ Sql_datetime2 = DateTime.MinValue,
+ Sql_datetimeoffset = NowOS,
+ };
- if(!areEqual)
- Assert.Fail("Expected {0} but was {1}");
- }
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(dates);
+ tx.Commit();
+ }
- public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
- {
- bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
- if (!areEqual)
- Assert.Fail("Expected {0} but was {1}");
- }
- }
- }
+ 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();
+ }
+ }
+ }
}
\ 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-04 13:53:41
|
Revision: 4035
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4035&view=rev
Author: darioquintana
Date: 2009-02-04 13:53:38 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Fix NH-1654 by Remco Ros
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2009-02-04 12:59:40 UTC (rev 4034)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2009-02-04 13:53:38 UTC (rev 4035)
@@ -16,6 +16,7 @@
RegisterColumnType(DbType.String, 1073741823, "NVARCHAR(MAX)");
RegisterColumnType(DbType.AnsiString, 2147483647, "VARCHAR(MAX)");
RegisterColumnType(DbType.Binary, 2147483647, "VARBINARY(MAX)");
+ RegisterKeyword("top");
}
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2009-02-04 12:59:40 UTC (rev 4034)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2009-02-04 13:53:38 UTC (rev 4035)
@@ -311,7 +311,7 @@
return "(".Equals(nextToken) ||
Keywords.Contains(lcToken) ||
functionRegistry.HasFunction(lcToken) ||
- // TODO H3: dialect.Keywords.Contains(lcToken) ||
+ dialect.Keywords.Contains(lcToken) ||
FunctionKeywords.Contains(lcToken);
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs 2009-02-04 12:59:40 UTC (rev 4034)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs 2009-02-04 13:53:38 UTC (rev 4035)
@@ -1,4 +1,5 @@
-using NUnit.Framework;
+using NHibernate.Dialect;
+using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.NH1654
{
@@ -10,7 +11,12 @@
get { return "NH1654"; }
}
- [Test,Ignore]
+ protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2000Dialect;
+ }
+
+ [Test]
public void Test()
{
int employeeId;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-04 15:54:56
|
Revision: 4037
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4037&view=rev
Author: fabiomaulo
Date: 2009-02-04 15:54:52 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Minor (reformatted)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/GuidType.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Type/GuidType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/GuidType.cs 2009-02-04 14:28:13 UTC (rev 4036)
+++ trunk/nhibernate/src/NHibernate/Type/GuidType.cs 2009-02-04 15:54:52 UTC (rev 4037)
@@ -24,14 +24,14 @@
/// <returns></returns>
public override object Get(IDataReader rs, int index)
{
- if (rs.GetFieldType(index) == typeof(Guid))
- {
- return rs.GetGuid(index);
- }
- else
- {
- return new Guid(Convert.ToString(rs[index]));
- }
+ if (rs.GetFieldType(index) == typeof (Guid))
+ {
+ return rs.GetGuid(index);
+ }
+ else
+ {
+ return new Guid(Convert.ToString(rs[index]));
+ }
}
/// <summary>
Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs 2009-02-04 14:28:13 UTC (rev 4036)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs 2009-02-04 15:54:52 UTC (rev 4037)
@@ -89,26 +89,26 @@
}
}
- [Test]
- public void GetGuidWorksWhenUnderlyingTypeIsRepresentedByString()
- {
- GuidType type = (GuidType)NHibernateUtil.Guid;
+ [Test]
+ public void GetGuidWorksWhenUnderlyingTypeIsRepresentedByString()
+ {
+ GuidType type = (GuidType)NHibernateUtil.Guid;
- Guid value = Guid.NewGuid();
- DataTable data = new DataTable("test");
- data.Columns.Add("guid", typeof(Guid));
- data.Columns.Add("varchar", typeof(string));
- DataRow row = data.NewRow();
- row["guid"] = value;
- row["varchar"] = value.ToString();
- data.Rows.Add(row);
- IDataReader reader = data.CreateDataReader();
- reader.Read();
+ Guid value = Guid.NewGuid();
+ DataTable data = new DataTable("test");
+ data.Columns.Add("guid", typeof(Guid));
+ data.Columns.Add("varchar", typeof(string));
+ DataRow row = data.NewRow();
+ row["guid"] = value;
+ row["varchar"] = value.ToString();
+ data.Rows.Add(row);
+ IDataReader reader = data.CreateDataReader();
+ reader.Read();
- Assert.AreEqual(value, type.Get(reader, "guid"));
- Assert.AreEqual(value, type.Get(reader, 0));
- Assert.AreEqual(value, type.Get(reader, "varchar"));
- Assert.AreEqual(value, type.Get(reader, 1));
- }
+ Assert.AreEqual(value, type.Get(reader, "guid"));
+ Assert.AreEqual(value, type.Get(reader, 0));
+ Assert.AreEqual(value, type.Get(reader, "varchar"));
+ Assert.AreEqual(value, type.Get(reader, 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: <fab...@us...> - 2009-02-04 17:25:48
|
Revision: 4038
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4038&view=rev
Author: fabiomaulo
Date: 2009-02-04 17:25:35 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Fix NH-1429 (Guid for Oracle)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
trunk/nhibernate/src/NHibernate/Driver/OracleClientDriver.cs
trunk/nhibernate/src/NHibernate/Driver/OracleDataClientDriver.cs
trunk/nhibernate/src/NHibernate/Type/GuidType.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-04 15:54:52 UTC (rev 4037)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-04 17:25:35 UTC (rev 4038)
@@ -68,7 +68,7 @@
RegisterNumericTypeMappings();
RegisterDateTimeTypeMappings();
RegisterLargeObjectTypeMappings();
-
+ RegisterGuidTypeMapping();
RegisterReverseHibernateTypeMappings();
RegisterFunctions();
@@ -76,6 +76,11 @@
RegisterDefaultProperties();
}
+ protected virtual void RegisterGuidTypeMapping()
+ {
+ RegisterColumnType(DbType.Guid, "RAW(16)");
+ }
+
protected virtual void RegisterCharacterTypeMappings()
{
RegisterColumnType(DbType.AnsiStringFixedLength, "CHAR(255)");
Modified: trunk/nhibernate/src/NHibernate/Driver/OracleClientDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/OracleClientDriver.cs 2009-02-04 15:54:52 UTC (rev 4037)
+++ trunk/nhibernate/src/NHibernate/Driver/OracleClientDriver.cs 2009-02-04 17:25:35 UTC (rev 4038)
@@ -1,5 +1,6 @@
using System.Data;
using System.Data.OracleClient;
+using NHibernate.SqlTypes;
namespace NHibernate.Driver
{
@@ -8,6 +9,8 @@
/// </summary>
public class OracleClientDriver : DriverBase
{
+ private static readonly SqlType GuidSqlType = new SqlType(DbType.Binary, 16);
+
public override IDbConnection CreateConnection()
{
return new OracleConnection();
@@ -32,5 +35,17 @@
{
get { return ":"; }
}
+
+ protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType)
+ {
+ if (sqlType.DbType == DbType.Guid)
+ {
+ base.InitializeParameter(dbParam, name, GuidSqlType);
+ }
+ else
+ {
+ base.InitializeParameter(dbParam, name, sqlType);
+ }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Driver/OracleDataClientDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/OracleDataClientDriver.cs 2009-02-04 15:54:52 UTC (rev 4037)
+++ trunk/nhibernate/src/NHibernate/Driver/OracleDataClientDriver.cs 2009-02-04 17:25:35 UTC (rev 4038)
@@ -14,6 +14,7 @@
/// </remarks>
public class OracleDataClientDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
{
+ private static readonly SqlType GuidSqlType = new SqlType(DbType.Binary, 16);
/// <summary>
/// Initializes a new instance of <see cref="OracleDataClientDriver"/>.
/// </summary>
@@ -54,11 +55,18 @@
{
// if the parameter coming in contains a boolean then we need to convert it
// to another type since ODP.NET doesn't support DbType.Boolean
- if (sqlType.DbType == DbType.Boolean)
+ switch (sqlType.DbType)
{
- sqlType = SqlTypeFactory.Int16;
+ case DbType.Boolean:
+ base.InitializeParameter(dbParam, name, SqlTypeFactory.Int16);
+ break;
+ case DbType.Guid:
+ base.InitializeParameter(dbParam, name, GuidSqlType);
+ break;
+ default:
+ base.InitializeParameter(dbParam, name, sqlType);
+ break;
}
- base.InitializeParameter(dbParam, name, sqlType);
}
#region IEmbeddedBatcherFactoryProvider Members
Modified: trunk/nhibernate/src/NHibernate/Type/GuidType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/GuidType.cs 2009-02-04 15:54:52 UTC (rev 4037)
+++ trunk/nhibernate/src/NHibernate/Type/GuidType.cs 2009-02-04 17:25:35 UTC (rev 4038)
@@ -28,10 +28,13 @@
{
return rs.GetGuid(index);
}
- else
+
+ if (rs.GetFieldType(index) == typeof(byte[]))
{
- return new Guid(Convert.ToString(rs[index]));
- }
+ return new Guid((byte[])(rs[index]));
+ }
+
+ return new Guid(Convert.ToString(rs[index]));
}
/// <summary>
@@ -53,7 +56,9 @@
public override void Set(IDbCommand cmd, object value, int index)
{
- ((IDataParameter)cmd.Parameters[index]).Value = value;
+ var dp = (IDataParameter) cmd.Parameters[index];
+
+ dp.Value = dp.DbType == DbType.Binary ? ((Guid)value).ToByteArray() : value;
}
/// <summary></summary>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-04 22:15:25
|
Revision: 4045
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4045&view=rev
Author: fabiomaulo
Date: 2009-02-04 22:15:23 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Fix NH-1479 (new feature guid.native generator)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.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/NativeGuidGenerator.cs
trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/
trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs
trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs
trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.cs
trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-02-04 21:49:37 UTC (rev 4044)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -271,7 +271,7 @@
/// <returns> The appropriate command. </returns>
public virtual string SelectGUIDString
{
- get{throw new NotSupportedException("dialect does not support GUIDs");}
+ get{throw new NotSupportedException("dialect does not support server side GUIDs generation.");}
}
/// <summary> Command used to create a table. </summary>
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-02-04 21:49:37 UTC (rev 4044)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -159,6 +159,11 @@
get { return false; }
}
+ public override string SelectGUIDString
+ {
+ get { return "select newid()"; }
+ }
+
/// <summary>
/// Generates the string to drop the table using SQL Server syntax.
/// </summary>
Modified: trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs 2009-02-04 21:49:37 UTC (rev 4044)
+++ trunk/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -40,6 +40,10 @@
/// <description><see cref="GuidCombGenerator"/></description>
/// </item>
/// <item>
+ /// <term>guid.native</term>
+ /// <description><see cref="NativeGuidGenerator"/></description>
+ /// </item>
+ /// <item>
/// <term>hilo</term>
/// <description><see cref="TableHiLoGenerator"/></description>
/// </item>
@@ -165,6 +169,7 @@
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));
}
Added: trunk/nhibernate/src/NHibernate/Id/NativeGuidGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/NativeGuidGenerator.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Id/NativeGuidGenerator.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -0,0 +1,58 @@
+using System;
+using System.Data;
+using log4net;
+using NHibernate.Engine;
+using NHibernate.Exceptions;
+using NHibernate.SqlCommand;
+using NHibernate.SqlTypes;
+using NHibernate.Type;
+
+namespace NHibernate.Id
+{
+ /// <summary>
+ /// Generates Guid values using the server side Guid function.
+ /// </summary>
+ public class NativeGuidGenerator : IIdentifierGenerator
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(NativeGuidGenerator));
+ private readonly IType identifierType = new GuidType();
+
+ #region Implementation of IIdentifierGenerator
+
+ public object Generate(ISessionImplementor session, object obj)
+ {
+ var sql = new SqlString(session.Factory.Dialect.SelectGUIDString);
+ try
+ {
+ IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, SqlTypeFactory.NoTypes);
+ IDataReader reader = null;
+ try
+ {
+ reader = session.Batcher.ExecuteReader(st);
+ object result;
+ try
+ {
+ reader.Read();
+ result = IdentifierGeneratorFactory.Get(reader, identifierType, session);
+ }
+ finally
+ {
+ reader.Close();
+ }
+ log.Debug("GUID identifier generated: " + result);
+ return result;
+ }
+ finally
+ {
+ session.Batcher.CloseCommand(st, reader);
+ }
+ }
+ catch (Exception sqle)
+ {
+ throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, "could not retrieve GUID", sql);
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-04 21:49:37 UTC (rev 4044)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-04 22:15:23 UTC (rev 4045)
@@ -464,6 +464,7 @@
<Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" />
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
+ <Compile Include="Id\NativeGuidGenerator.cs" />
<Compile Include="Id\SelectGenerator.cs" />
<Compile Include="IFutureValue.cs" />
<Compile Include="Impl\DelayedEnumerator.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidFixture.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -0,0 +1,44 @@
+using System.Collections;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.IdGen.NativeGuid
+{
+ [TestFixture]
+ public class NativeGuidFixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override IList Mappings
+ {
+ get { return new[] {"IdGen.NativeGuid.NativeGuidPoid.hbm.xml"}; }
+ }
+
+ [Test]
+ public void Crd()
+ {
+ object savedId;
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var nativeGuidPoid = new NativeGuidPoid();
+ savedId = s.Save(nativeGuidPoid);
+ tx.Commit();
+ Assert.That(savedId, Is.Not.Null);
+ Assert.That(savedId, Is.EqualTo(nativeGuidPoid.Id));
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var nativeGuidPoid = s.Get<NativeGuidPoid>(savedId);
+ Assert.That(nativeGuidPoid, Is.Not.Null);
+ s.Delete(nativeGuidPoid);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -0,0 +1,47 @@
+using System;
+using NHibernate.Cfg;
+using NHibernate.Engine;
+using NHibernate.Id;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.IdGen.NativeGuid
+{
+ [TestFixture]
+ public class NativeGuidGeneratorFixture
+ {
+ protected Configuration cfg;
+ protected ISessionFactoryImplementor sessions;
+
+ [TestFixtureSetUp]
+ public void TestFixtureSetUp()
+ {
+ cfg = new Configuration();
+ if (TestConfigurationHelper.hibernateConfigFile != null)
+ cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
+
+ sessions = (ISessionFactoryImplementor) cfg.BuildSessionFactory();
+ }
+
+ [Test]
+ public void ReturnedValueIsGuid()
+ {
+ try
+ {
+ var str = Dialect.Dialect.GetDialect().SelectGUIDString;
+ }
+ catch (NotSupportedException)
+ {
+ Assert.Ignore("This test does not apply to {0}", Dialect.Dialect.GetDialect());
+ }
+
+ var gen = new NativeGuidGenerator();
+ using (ISession s = sessions.OpenSession())
+ {
+ object result = gen.Generate((ISessionImplementor)s, null);
+ Assert.That(result, Is.TypeOf(typeof (Guid)));
+ Assert.That(result, Is.Not.EqualTo(Guid.Empty));
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.cs 2009-02-04 22:15:23 UTC (rev 4045)
@@ -0,0 +1,9 @@
+using System;
+
+namespace NHibernate.Test.IdGen.NativeGuid
+{
+ public class NativeGuidPoid
+ {
+ public Guid Id { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/IdGen/NativeGuid/NativeGuidPoid.hbm.xml 2009-02-04 22:15:23 UTC (rev 4045)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.IdGen.NativeGuid"
+ default-lazy="false">
+
+ <class name="NativeGuidPoid">
+ <id name="Id">
+ <generator class="guid.native" />
+ </id>
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 21:49:37 UTC (rev 4044)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 22:15:23 UTC (rev 4045)
@@ -294,6 +294,9 @@
<Compile Include="BulkManipulation\Vehicles.cs" />
<Compile Include="HQL\HqlFixture.cs" />
<Compile Include="IdGen\Enhanced\SequenceStyleConfigUnitFixture.cs" />
+ <Compile Include="IdGen\NativeGuid\NativeGuidFixture.cs" />
+ <Compile Include="IdGen\NativeGuid\NativeGuidGeneratorFixture.cs" />
+ <Compile Include="IdGen\NativeGuid\NativeGuidPoid.cs" />
<Compile Include="IdTest\Car.cs" />
<Compile Include="IdTest\HiLoInt16Class.cs" />
<Compile Include="IdTest\HiLoInt32Class.cs" />
@@ -1622,6 +1625,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Dates\Mappings\DateTimeOffset.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1654\Mappings.hbm.xml" />
<EmbeddedResource Include="Pagination\DataPoint.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-04 22:55:07
|
Revision: 4046
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4046&view=rev
Author: darioquintana
Date: 2009-02-04 22:54:43 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
- Add DbType.Date support to MsSql2008Dialect.
- Test for DbType.Time support (not implemented yet)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Date.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -8,6 +8,8 @@
{
RegisterColumnType(DbType.DateTime2, "DATETIME2");
RegisterColumnType(DbType.DateTimeOffset, "DATETIMEOFFSET");
+ RegisterColumnType(DbType.Date, "DATE");
+ //RegisterColumnType(DbType.Time, "TIME");
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -11,5 +11,9 @@
public DateTime Sql_datetime2 { get; set; }
public DateTimeOffset Sql_datetimeoffset { get; set; }
+
+ public TimeSpan Sql_time { get; set; }
+
+ public DateTime Sql_date { get; set; }
}
}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateFixture.cs (from rev 4044, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateFixture.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class DateFixture : FixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.Date.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ DateTime Now = DateTime.Now;
+ SavingAndRetrievingAction(new AllDates {Sql_date = Now},
+ entity => DateTimeAssert.AreEqual(entity.Sql_date, Now, true));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -5,7 +5,7 @@
namespace NHibernate.Test.NHSpecificTest.Dates
{
[TestFixture]
- public class DateTime2Fixture : DatesFixtureBase
+ public class DateTime2Fixture : FixtureBase
{
protected override IList Mappings
{
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -4,6 +4,9 @@
namespace NHibernate.Test.NHSpecificTest.Dates
{
+ /// <summary>
+ /// Useful assert to work with datetimes types.
+ /// </summary>
public class DateTimeAssert
{
public static void AreEqual(DateTime dt1, DateTime dt2)
@@ -11,9 +14,21 @@
bool areEqual = new DateTimeType().IsEqual(dt1, dt2);
if (!areEqual)
- Assert.Fail(string.Format("Expected {0} but was {1}",dt1,dt2));
+ Assert.Fail(string.Format("Expected {0} but was {1}", dt1, dt2));
}
+ public static void AreEqual(DateTime dt1, DateTime dt2, bool OnlyDatePart)
+ {
+ if (!OnlyDatePart)
+ throw new NotSupportedException();
+
+ bool areEqual = DatePartAreEqual(dt1, dt2);
+
+ if (!areEqual)
+ Assert.Fail(string.Format("Expected {0} but was {1}", dt1, dt2));
+ }
+
+
public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
{
bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
@@ -21,5 +36,27 @@
if (!areEqual)
Assert.Fail(string.Format("Expected {0} but was {1}", dt1, dt2));
}
+
+ /// <summary>
+ /// Compare only the date part.
+ /// </summary>
+ /// <returns>true if are equal, false otherwise</returns>
+ private static bool DatePartAreEqual(DateTime x, DateTime y)
+ {
+ if (x == y)
+ {
+ return true;
+ }
+
+ DateTime date1 = x;
+ DateTime date2 = y;
+
+ if (date1.Equals(date2))
+ return true;
+
+ return (date1.Year == date2.Year &&
+ date1.Month == date2.Month &&
+ date1.Day == date2.Day);
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -5,7 +5,7 @@
namespace NHibernate.Test.NHSpecificTest.Dates
{
[TestFixture]
- public class DateTimeOffSetFixture : DatesFixtureBase
+ public class DateTimeOffSetFixture : FixtureBase
{
protected override IList Mappings
{
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -1,51 +0,0 @@
-using System;
-using System.Collections;
-using NHibernate.Dialect;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest.Dates
-{
- [TestFixture]
- public abstract class DatesFixtureBase : TestCase
- {
- protected abstract override IList Mappings { get; }
-
- protected override string MappingsAssembly
- {
- get { return "NHibernate.Test"; }
- }
-
- protected override bool AppliesTo(Dialect.Dialect dialect)
- {
- return dialect is MsSql2008Dialect;
- }
-
- protected void SavingAndRetrievingAction(AllDates entity, Action<AllDates> action)
- {
- AllDates dates = entity;
-
- 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>();
-
- action.Invoke(datesRecovered);
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
- s.Delete(datesRecovered);
- tx.Commit();
- }
- }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs (from rev 4044, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -0,0 +1,51 @@
+using System;
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public abstract class FixtureBase : TestCase
+ {
+ protected abstract override IList Mappings { get; }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2008Dialect;
+ }
+
+ protected void SavingAndRetrievingAction(AllDates entity, Action<AllDates> action)
+ {
+ AllDates dates = entity;
+
+ 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>();
+
+ action.Invoke(datesRecovered);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+ s.Delete(datesRecovered);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Date.hbm.xml (from rev 4044, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Date.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Date.hbm.xml 2009-02-04 22:54:43 UTC (rev 4046)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Dates"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <property name="Sql_date" type="date" />
+
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml (from rev 4044, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml 2009-02-04 22:54:43 UTC (rev 4046)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Dates"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <property name="Sql_time" type="time" />
+
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs (from rev 4044, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs 2009-02-04 22:54:43 UTC (rev 4046)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class TimeFixture : FixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.Time.hbm.xml"}; }
+ }
+
+ [Test,Ignore]
+ public void SavingAndRetrievingTest()
+ {
+ TimeSpan Now = TimeSpan.MaxValue;
+ 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/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 22:15:23 UTC (rev 4045)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 22:54:43 UTC (rev 4046)
@@ -383,7 +383,9 @@
<Compile Include="NHSpecificTest\BasicTimeFixture.cs" />
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
- <Compile Include="NHSpecificTest\Dates\DatesFixtureBase.cs" />
+ <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\FixtureBase.cs" />
<Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
<Compile Include="NHSpecificTest\Dates\DateTimeAssert.cs" />
<Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
@@ -1626,6 +1628,8 @@
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
<EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\Time.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\Date.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Dates\Mappings\DateTimeOffset.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1654\Mappings.hbm.xml" />
<EmbeddedResource Include="Pagination\DataPoint.hbm.xml" />
@@ -1746,4 +1750,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-05 04:57:37
|
Revision: 4048
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4048&view=rev
Author: fabiomaulo
Date: 2009-02-05 04:57:35 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Class for future usage
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Id/Insert/NoCommentsInsert.cs
Added: trunk/nhibernate/src/NHibernate/Id/Insert/NoCommentsInsert.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/Insert/NoCommentsInsert.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Id/Insert/NoCommentsInsert.cs 2009-02-05 04:57:35 UTC (rev 4048)
@@ -0,0 +1,17 @@
+using NHibernate.Engine;
+using NHibernate.SqlCommand;
+
+namespace NHibernate.Id.Insert
+{
+ /// <summary>
+ /// Disable comments on insert.
+ /// </summary>
+ public class NoCommentsInsert : IdentifierGeneratingInsert
+ {
+ public NoCommentsInsert(ISessionFactoryImplementor factory) : base(factory) {}
+ public override SqlInsertBuilder SetComment(string comment)
+ {
+ return this;
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-05 04:47:03 UTC (rev 4047)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-05 04:57:35 UTC (rev 4048)
@@ -464,6 +464,7 @@
<Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" />
<Compile Include="Exceptions\SqlStateExtracter.cs" />
<Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" />
+ <Compile Include="Id\Insert\NoCommentsInsert.cs" />
<Compile Include="Id\NativeGuidGenerator.cs" />
<Compile Include="Id\SelectGenerator.cs" />
<Compile Include="IFutureValue.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-05 13:24:16
|
Revision: 4052
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4052&view=rev
Author: darioquintana
Date: 2009-02-05 13:24:13 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
NH-1659: current_timestamp in MsSql2008Dialect using SYSDATETIME()
NH-1658: current_timestamp_offset: current_timestamp for DateTimeOffset
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-05 12:06:08 UTC (rev 4051)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-05 13:24:13 UTC (rev 4052)
@@ -1,4 +1,5 @@
using System.Data;
+using NHibernate.Dialect.Function;
namespace NHibernate.Dialect
{
@@ -10,6 +11,9 @@
RegisterColumnType(DbType.DateTimeOffset, "DATETIMEOFFSET");
RegisterColumnType(DbType.Date, "DATE");
//RegisterColumnType(DbType.Time, "TIME");
+
+ RegisterFunction("current_timestamp", new NoArgSQLFunction("sysdatetime", NHibernateUtil.DateTime2, true));
+ RegisterFunction("current_timestamp_offset", new NoArgSQLFunction("sysdatetimeoffset", NHibernateUtil.DateTimeOffset, true));
}
}
}
\ 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-05 12:06:08 UTC (rev 4051)
+++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-05 13:24:13 UTC (rev 4052)
@@ -744,7 +744,27 @@
}
}
+ /// <summary>
+ /// NH-1658
+ /// </summary>
[Test]
+ public void Current_TimeStamp_Offset()
+ {
+ IgnoreIfNotSupported("current_timestamp_offset");
+ using (ISession s = OpenSession())
+ {
+ Animal a1 = new Animal("abcdef", 1.3f);
+ s.Save(a1);
+ s.Flush();
+ }
+ using (ISession s = OpenSession())
+ {
+ string hql = "select current_timestamp_offset() from Animal";
+ IList result = s.CreateQuery(hql).List();
+ }
+ }
+
+ [Test]
public void Extract()
{
IgnoreIfNotSupported("extract");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|