|
From: <te...@us...> - 2008-08-30 14:14:17
|
Revision: 3738
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3738&view=rev
Author: tehlike
Date: 2008-08-30 14:14:27 +0000 (Sat, 30 Aug 2008)
Log Message:
-----------
Synchronizing 3.5 project with 2.0
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate-3.5.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
Modified: trunk/nhibernate/src/NHibernate/NHibernate-3.5.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate-3.5.csproj 2008-08-29 10:55:05 UTC (rev 3737)
+++ trunk/nhibernate/src/NHibernate/NHibernate-3.5.csproj 2008-08-30 14:14:27 UTC (rev 3738)
@@ -530,6 +530,7 @@
<Compile Include="Context\ICurrentSessionContext.cs" />
<Compile Include="Context\ManagedWebSessionContext.cs" />
<Compile Include="Context\MapBasedSessionContext.cs" />
+ <Compile Include="Context\ThreadLocalSessionContext.cs" />
<Compile Include="Context\ThreadStaticSessionContext.cs" />
<Compile Include="Context\WebSessionContext.cs" />
<Compile Include="CriteriaTransformer.cs" />
@@ -641,6 +642,7 @@
<Compile Include="Dialect\Schema\MsSqlMetaData.cs" />
<Compile Include="Dialect\Schema\OracleMetaData.cs" />
<Compile Include="Dialect\Sybase11Dialect.cs" />
+ <Compile Include="Driver\ASA10ClientDriver.cs" />
<Compile Include="Driver\ISqlParameterFormatter.cs" />
<Compile Include="Driver\SqlStringFormatter.cs" />
<Compile Include="EmptyInterceptor.cs" />
@@ -678,6 +680,9 @@
<Compile Include="Engine\Query\Sql\NativeSQLQueryRootReturn.cs" />
<Compile Include="Engine\Query\Sql\NativeSQLQueryScalarReturn.cs" />
<Compile Include="Engine\StatefulPersistenceContext.cs" />
+ <Compile Include="Engine\TransactionHelper.cs" />
+ <Compile Include="Engine\Transaction\IIsolatedWork.cs" />
+ <Compile Include="Engine\Transaction\Isolater.cs" />
<Compile Include="Engine\TwoPhaseLoad.cs" />
<Compile Include="Engine\ValueInclusion.cs" />
<Compile Include="Engine\VersionValue.cs" />
@@ -792,6 +797,13 @@
<Compile Include="Exceptions\SQLStateConverter.cs" />
<Compile Include="FKUnmatchingColumnsException.cs" />
<Compile Include="Id\AbstractPostInsertGenerator.cs" />
+ <Compile Include="Id\Enhanced\IAccessCallback.cs" />
+ <Compile Include="Id\Enhanced\IDatabaseStructure.cs" />
+ <Compile Include="Id\Enhanced\IOptimizer.cs" />
+ <Compile Include="Id\Enhanced\OptimizerFactory.cs" />
+ <Compile Include="Id\Enhanced\SequenceStructure.cs" />
+ <Compile Include="Id\Enhanced\SequenceStyleGenerator.cs" />
+ <Compile Include="Id\Enhanced\TableStructure.cs" />
<Compile Include="Id\Insert\AbstractReturningDelegate.cs">
<SubType>Code</SubType>
</Compile>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-08-29 10:55:05 UTC (rev 3737)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-08-30 14:14:27 UTC (rev 3738)
@@ -26,7 +26,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
- <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<NoWarn>618,612</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -72,11 +72,22 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Any\Address.cs" />
+ <Compile Include="Any\AnyTypeTest.cs" />
+ <Compile Include="Any\ComplexPropertyValue.cs" />
+ <Compile Include="Any\IntegerPropertyValue.cs" />
+ <Compile Include="Any\IPropertyValue.cs" />
+ <Compile Include="Any\Person.cs" />
+ <Compile Include="Any\PropertySet.cs" />
+ <Compile Include="Any\StringPropertyValue.cs" />
<Compile Include="Assertions\InheritedAreMarkedSerializable.cs" />
<Compile Include="Assertions\IsSerializable.cs" />
<Compile Include="CacheTest\CacheFixture.cs" />
<Compile Include="CacheTest\QueryCacheFixture.cs" />
<Compile Include="CacheTest\TimestamperFixture.cs" />
+ <Compile Include="Cascade\Job.cs" />
+ <Compile Include="Cascade\JobBatch.cs" />
+ <Compile Include="Cascade\RefreshFixture.cs" />
<Compile Include="CfgTest\ConfigurationFixture.cs" />
<Compile Include="CfgTest\ConfigurationSchemaFixture.cs" />
<Compile Include="CfgTest\DefaultNsAssmFixture.cs" />
@@ -116,6 +127,9 @@
<Compile Include="Criteria\Student.cs" />
<Compile Include="Criteria\StudentDTO.cs" />
<Compile Include="DebugConnectionProvider.cs" />
+ <Compile Include="Deletetransient\Address.cs" />
+ <Compile Include="Deletetransient\DeleteTransientEntityTest.cs" />
+ <Compile Include="Deletetransient\Person.cs" />
<Compile Include="DialectTest\DB2DialectFixture.cs" />
<Compile Include="DialectTest\DialectFixture.cs" />
<Compile Include="DialectTest\FirebirdDialectFixture.cs" />
@@ -125,7 +139,46 @@
<Compile Include="DriverTest\NullReferenceFixture.cs" />
<Compile Include="DriverTest\OracleClientDriverFixture.cs" />
<Compile Include="DriverTest\OracleDataClientDriverFixture.cs" />
+ <Compile Include="DynamicEntity\Address.cs" />
+ <Compile Include="DynamicEntity\Company.cs" />
+ <Compile Include="DynamicEntity\Customer.cs" />
+ <Compile Include="DynamicEntity\DataProxyHandler.cs" />
+ <Compile Include="DynamicEntity\Interceptor\InterceptorDynamicEntity.cs" />
+ <Compile Include="DynamicEntity\Interceptor\ProxyInterceptor.cs" />
+ <Compile Include="DynamicEntity\IProxyMarker.cs" />
+ <Compile Include="DynamicEntity\Person.cs" />
+ <Compile Include="DynamicEntity\ProxyHelper.cs" />
+ <Compile Include="DynamicEntity\Tuplizer\EntityNameInterceptor.cs" />
+ <Compile Include="DynamicEntity\Tuplizer\MyEntityInstantiator.cs" />
+ <Compile Include="DynamicEntity\Tuplizer\MyEntityTuplizer.cs" />
+ <Compile Include="DynamicEntity\Tuplizer\TuplizerDynamicEntity.cs" />
<Compile Include="EngineTest\TypedValueFixture.cs" />
+ <Compile Include="EntityModeTest\Map\Basic\DynamicClassFixture.cs" />
+ <Compile Include="Events\Collections\AbstractCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\AbstractParentWithCollection.cs" />
+ <Compile Include="Events\Collections\Association\AbstractAssociationCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManyBagToSetCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManySetToSetCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\ManyToMany\ChildWithBidirectionalManyToMany.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\ManyToMany\ParentWithBidirectionalManyToMany.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManyBagCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManyBagSubclassCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManySetCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\OneToMany\ChildWithManyToOne.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\OneToMany\ParentWithBidirectionalOneToMany.cs" />
+ <Compile Include="Events\Collections\Association\Bidirectional\OneToMany\ParentWithBidirectionalOneToManySubclass.cs" />
+ <Compile Include="Events\Collections\Association\Unidirectional\ManyToMany\UnidirectionalManyToManyBagCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Unidirectional\OneToMany\UnidirectionalOneToManyBagCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Unidirectional\OneToMany\UnidirectionalOneToManySetCollectionEventFixture.cs" />
+ <Compile Include="Events\Collections\Association\Unidirectional\ParentWithCollectionOfEntities.cs" />
+ <Compile Include="Events\Collections\ChildEntity.cs" />
+ <Compile Include="Events\Collections\ChildValue.cs" />
+ <Compile Include="Events\Collections\CollectionListeners.cs" />
+ <Compile Include="Events\Collections\IChild.cs" />
+ <Compile Include="Events\Collections\IEntity.cs" />
+ <Compile Include="Events\Collections\IParentWithCollection.cs" />
+ <Compile Include="Events\Collections\Values\ParentWithCollectionOfValues.cs" />
+ <Compile Include="Events\Collections\Values\ValuesBagCollectionEventFixture.cs" />
<Compile Include="ExceptionsTest\PropertyAccessExceptionFixture.cs" />
<Compile Include="ExpressionTest\BaseExpressionFixture.cs" />
<Compile Include="ExpressionTest\BetweenExpressionFixture.cs" />
@@ -147,6 +200,11 @@
<Compile Include="ExpressionTest\SQLExpressionFixture.cs" />
<Compile Include="ExpressionTest\SubQueries\Classes.cs" />
<Compile Include="ExpressionTest\SubQueries\SubQueriesSqlFixture.cs" />
+ <Compile Include="Extralazy\Document.cs" />
+ <Compile Include="Extralazy\ExtraLazyFixture.cs" />
+ <Compile Include="Extralazy\Group.cs" />
+ <Compile Include="Extralazy\SessionAttribute.cs" />
+ <Compile Include="Extralazy\User.cs" />
<Compile Include="FilterTest\BinaryFiltered.cs" />
<Compile Include="FilterTest\Category.cs" />
<Compile Include="FilterTest\Department.cs" />
@@ -200,6 +258,7 @@
<Compile Include="HQLFunctionTest\SQLFunctionTemplateTest.cs" />
<Compile Include="BulkManipulation\NativeSQLBulkOperations.cs" />
<Compile Include="BulkManipulation\Vehicles.cs" />
+ <Compile Include="IdGen\Enhanced\SequenceStyleConfigUnitFixture.cs" />
<Compile Include="IdTest\HiLoInt16Class.cs" />
<Compile Include="IdTest\HiLoInt32Class.cs" />
<Compile Include="IdTest\HiLoInt64Class.cs" />
@@ -267,6 +326,10 @@
<Compile Include="MultipleCollectionFetchTest\MultipleSetFetchFixture.cs" />
<Compile Include="MultipleCollectionFetchTest\Person.cs" />
<Compile Include="MultiThreadRunner.cs" />
+ <Compile Include="Naturalid\Immutable\ImmutableNaturalIdFixture.cs" />
+ <Compile Include="Naturalid\Immutable\User.cs" />
+ <Compile Include="Naturalid\Mutable\MutableNaturalIdFixture.cs" />
+ <Compile Include="Naturalid\Mutable\User.cs" />
<Compile Include="NHAssert.cs" />
<Compile Include="NHibernateUtilTest.cs" />
<Compile Include="NHSpecificTest\AliasFixture.cs" />
@@ -1320,6 +1383,29 @@
<EmbeddedResource Include="NHSpecificTest\NH1253\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="Any\Person.hbm.xml" />
+ <EmbeddedResource Include="Any\Properties.hbm.xml" />
+ <EmbeddedResource Include="Cascade\Job.hbm.xml" />
+ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
+ <EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
+ <EmbeddedResource Include="DynamicEntity\Interceptor\Customer.hbm.xml" />
+ <EmbeddedResource Include="DynamicEntity\Tuplizer\Customer.hbm.xml" />
+ <EmbeddedResource Include="EntityModeTest\Map\Basic\ProductLine.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManyBagToSetMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManySetToSetMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManyBagMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManyBagSubclassMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManySetMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Unidirectional\ManyToMany\UnidirectionalManyToManyBagMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Unidirectional\OneToMany\UnidirectionalOneToManyBagMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Association\Unidirectional\OneToMany\UnidirectionalOneToManySetMapping.hbm.xml" />
+ <EmbeddedResource Include="Events\Collections\Values\ValuesBagMapping.hbm.xml" />
+ <EmbeddedResource Include="Extralazy\UserGroup.hbm.xml" />
+ <EmbeddedResource Include="Naturalid\Immutable\User.hbm.xml" />
+ <EmbeddedResource Include="Naturalid\Mutable\User.hbm.xml" />
+ <EmbeddedResource Include="TypeParameters\Typedef.hbm.xml" />
+ </ItemGroup>
+ <ItemGroup>
<Folder Include="Properties\" />
<Folder Include="Unionsubclass2\" />
</ItemGroup>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-03 17:54:16
|
Revision: 3741
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3741&view=rev
Author: fabiomaulo
Date: 2008-09-03 17:54:20 +0000 (Wed, 03 Sep 2008)
Log Message:
-----------
Merge r3740 (fix NH-1473)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/EntityType.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Type/EntityType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/EntityType.cs 2008-09-03 17:39:18 UTC (rev 3740)
+++ trunk/nhibernate/src/NHibernate/Type/EntityType.cs 2008-09-03 17:54:20 UTC (rev 3741)
@@ -81,7 +81,7 @@
}
else
{
- yid = persister.GetIdentifier(x, entityMode);
+ yid = persister.GetIdentifier(y, entityMode);
}
return persister.IdentifierType.IsEqual(xid, yid, entityMode, factory);
@@ -567,13 +567,13 @@
public override int Compare(object x, object y, EntityMode? entityMode)
{
IComparable xComp = x as IComparable;
- IComparable yComp = x as IComparable;
+ IComparable yComp = y as IComparable;
if (xComp != null)
return xComp.CompareTo(y);
if (yComp != null)
- return yComp.CompareTo(x);
+ return -yComp.CompareTo(x);
- return 0; //TODO: entities CAN be compared, by PK, fix this! -> only if/when we can extract the id values....
+ return 0;
}
private System.Type DetermineAssociatedEntityClass()
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-03 17:39:18 UTC (rev 3740)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-03 17:54:20 UTC (rev 3741)
@@ -828,6 +828,8 @@
<Compile Include="TypesTest\DecimalTypeFixture.cs" />
<Compile Include="TypesTest\DoubleClass.cs" />
<Compile Include="TypesTest\DoubleTypeFixture.cs" />
+ <Compile Include="TypesTest\EntityClass.cs" />
+ <Compile Include="TypesTest\EntityTypeFixture.cs" />
<Compile Include="TypesTest\EnumStringClass.cs" />
<Compile Include="TypesTest\EnumStringTypeFixture.cs" />
<Compile Include="TypesTest\GuidClass.cs" />
@@ -1449,6 +1451,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="TypesTest\EntityClass.hbm.xml" />
<EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManyBagToSetMapping.hbm.xml" />
<EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManySetToSetMapping.hbm.xml" />
<EmbeddedResource Include="Events\Collections\Association\Bidirectional\OneToMany\BidirectionalOneToManyBagMapping.hbm.xml" />
Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.cs 2008-09-03 17:54:20 UTC (rev 3741)
@@ -0,0 +1,45 @@
+using System;
+
+namespace NHibernate.Test.TypesTest
+{
+ public class EntityClass
+ {
+ private int _id;
+
+ public EntityClass() {}
+
+ public EntityClass(int _id)
+ {
+ this._id = _id;
+ }
+
+ public int Id
+ {
+ get { return _id; }
+ set { _id = value; }
+ }
+ }
+
+ public class ComparableEntityClass : EntityClass, IComparable
+ {
+ public ComparableEntityClass() {}
+
+ #region IComparable Members
+
+ public ComparableEntityClass(int _id) : base(_id) {}
+
+ public int CompareTo(object obj)
+ {
+ EntityClass other = obj as EntityClass;
+
+ if (other == null)
+ {
+ return 1;
+ }
+
+ return Id.CompareTo(other.Id);
+ }
+
+ #endregion
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityClass.hbm.xml 2008-09-03 17:54:20 UTC (rev 3741)
@@ -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.TypesTest"
+ default-lazy="false">
+
+ <class name="EntityClass" table="nh_entity">
+ <id name="Id" column="id">
+ <generator class="assigned" />
+ </id>
+
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs 2008-09-03 17:54:20 UTC (rev 3741)
@@ -0,0 +1,53 @@
+using NHibernate.Engine;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.TypesTest
+{
+ // http://jira.nhibernate.org/browse/NH-1473
+ [TestFixture]
+ public class EntityTypeFixture : TypeFixtureBase
+ {
+ protected override string TypeName
+ {
+ get { return "Entity"; }
+ }
+
+ [Test]
+ public void Compare()
+ {
+ EntityType type = (EntityType) NHibernateUtil.Entity(typeof (EntityClass));
+
+ EntityClass a = new EntityClass(1);
+ EntityClass b = new EntityClass(2);
+
+ EntityClass ca = new ComparableEntityClass(1);
+ EntityClass cb = new ComparableEntityClass(2);
+
+ Assert.AreEqual(-1, type.Compare(a, cb, EntityMode.Poco));
+ Assert.AreEqual(-1, type.Compare(ca, b, EntityMode.Poco));
+ Assert.AreEqual(-1, type.Compare(ca, cb, EntityMode.Poco));
+
+ Assert.AreEqual(1, type.Compare(b, ca, EntityMode.Poco));
+ Assert.AreEqual(1, type.Compare(cb, a, EntityMode.Poco));
+ Assert.AreEqual(1, type.Compare(cb, ca, EntityMode.Poco));
+
+ Assert.AreEqual(0, type.Compare(ca, a, EntityMode.Poco));
+ Assert.AreEqual(0, type.Compare(a, ca, EntityMode.Poco));
+ }
+
+ [Test]
+ public void Equals()
+ {
+ EntityType type = (EntityType) NHibernateUtil.Entity(typeof (EntityClass));
+
+ EntityClass a = new EntityClass(1);
+ EntityClass b = new EntityClass(2);
+ EntityClass c = new EntityClass(1);
+
+ Assert.IsTrue(type.IsEqual(a, a, EntityMode.Poco, (ISessionFactoryImplementor) sessions));
+ Assert.IsFalse(type.IsEqual(a, b, EntityMode.Poco, (ISessionFactoryImplementor) sessions));
+ Assert.IsTrue(type.IsEqual(a, c, EntityMode.Poco, (ISessionFactoryImplementor) sessions));
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-03 20:57:14
|
Revision: 3743
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3743&view=rev
Author: fabiomaulo
Date: 2008-09-03 20:57:21 +0000 (Wed, 03 Sep 2008)
Log Message:
-----------
Merge r3742 (Fix NH-1464)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs 2008-09-03 20:48:55 UTC (rev 3742)
+++ trunk/nhibernate/src/NHibernate/Proxy/ProxyTypeValidator.cs 2008-09-03 20:57:21 UTC (rev 3743)
@@ -91,8 +91,8 @@
private static void CheckMethodIsVirtual(System.Type type, MethodInfo method, IList errors)
{
- if (method.DeclaringType != typeof(object) &&
- (method.IsPublic || method.IsAssembly || method.IsFamilyOrAssembly))
+ if (method.DeclaringType != typeof(object) && !IsDisposeMethod(method) &&
+ method.IsPublic || method.IsAssembly || method.IsFamilyOrAssembly)
{
if (!method.IsVirtual || method.IsFinal)
{
@@ -101,6 +101,11 @@
}
}
+ private static bool IsDisposeMethod(MethodBase method)
+ {
+ return method.Name.Equals("Dispose") && method.MemberType == MemberTypes.Method && method.GetParameters().Length == 0;
+ }
+
private static bool HasVisibleDefaultConstructor(System.Type type)
{
ConstructorInfo constructor = type.GetConstructor(
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1464/Fixture.cs 2008-09-03 20:57:21 UTC (rev 3743)
@@ -0,0 +1,72 @@
+using System;
+using System.Collections;
+using NHibernate.Proxy;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1464
+{
+ [TestFixture]
+ public class Fixture
+ {
+ public class CPPMimicBase
+ {
+ public virtual void Dispose()
+ {
+
+ }
+ }
+ public class CPPMimic : CPPMimicBase
+ {
+ public sealed override void Dispose()
+ {
+
+ }
+ }
+
+ public class Another: IDisposable
+ {
+ protected void Dispose(bool disposing)
+ {
+
+ }
+
+ public void Dispose()
+ {
+ }
+
+ ~Another()
+ {
+
+ }
+ }
+
+ public class OneMore : IDisposable
+ {
+ public void Dispose(bool disposing)
+ {
+
+ }
+
+ public void Dispose()
+ {
+ }
+
+ ~OneMore()
+ {
+
+ }
+ }
+
+ [Test]
+ public void NoExceptionForDispose()
+ {
+ ICollection errs = ProxyTypeValidator.ValidateType(typeof (CPPMimic));
+ Assert.That(errs, Is.Null);
+ errs = ProxyTypeValidator.ValidateType(typeof(Another));
+ Assert.That(errs, Is.Null);
+ errs = ProxyTypeValidator.ValidateType(typeof(OneMore));
+ Assert.That(errs.Count, Is.EqualTo(1));
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-03 20:48:55 UTC (rev 3742)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-03 20:57:21 UTC (rev 3743)
@@ -464,6 +464,7 @@
<Compile Include="NHSpecificTest\NH1419\Blog.cs" />
<Compile Include="NHSpecificTest\NH1419\Entry.cs" />
<Compile Include="NHSpecificTest\NH1419\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1464\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-03 21:36:17
|
Revision: 3745
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3745&view=rev
Author: fabiomaulo
Date: 2008-09-03 21:35:18 +0000 (Wed, 03 Sep 2008)
Log Message:
-----------
Fix NH-1467 (documentation) by Simon Cropp
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs
trunk/nhibernate/src/NHibernate/Action/EntityAction.cs
trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs
trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs
trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs
trunk/nhibernate/src/NHibernate/AssertionFailure.cs
trunk/nhibernate/src/NHibernate/Cache/CachedItem.cs
trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs
trunk/nhibernate/src/NHibernate/CallbackException.cs
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/ClassCacheConfiguration.cs
trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs
trunk/nhibernate/src/NHibernate/Cfg/Environment.cs
trunk/nhibernate/src/NHibernate/Cfg/ImprovedNamingStrategy.cs
trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Classic/ValidationFailure.cs
trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs
trunk/nhibernate/src/NHibernate/Collection/IPersistentCollection.cs
trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs
trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs
trunk/nhibernate/src/NHibernate/Criterion/ICriteriaQuery.cs
trunk/nhibernate/src/NHibernate/Criterion/LogicalExpression.cs
trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/Schema/IDataBaseSchema.cs
trunk/nhibernate/src/NHibernate/Dialect/Sybase11Dialect.cs
trunk/nhibernate/src/NHibernate/Engine/ActionQueue.cs
trunk/nhibernate/src/NHibernate/Engine/CascadeStyle.cs
trunk/nhibernate/src/NHibernate/Engine/CascadingAction.cs
trunk/nhibernate/src/NHibernate/Engine/EntityEntry.cs
trunk/nhibernate/src/NHibernate/Engine/IPersistenceContext.cs
trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs
trunk/nhibernate/src/NHibernate/Engine/Loading/LoadContexts.cs
trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs
trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs
trunk/nhibernate/src/NHibernate/Engine/TypedValue.cs
trunk/nhibernate/src/NHibernate/Event/Default/AbstractFlushingEventListener.cs
trunk/nhibernate/src/NHibernate/Event/Default/AbstractSaveEventListener.cs
trunk/nhibernate/src/NHibernate/Event/Default/DefaultFlushEntityEventListener.cs
trunk/nhibernate/src/NHibernate/Event/IEventSource.cs
trunk/nhibernate/src/NHibernate/Event/IPostInsertEventListener.cs
trunk/nhibernate/src/NHibernate/Event/ListenerType.cs
trunk/nhibernate/src/NHibernate/Event/MergeEvent.cs
trunk/nhibernate/src/NHibernate/Exceptions/SQLStateConverter.cs
trunk/nhibernate/src/NHibernate/Hql/Classic/FromParser.cs
trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs
trunk/nhibernate/src/NHibernate/IDetachedQuery.cs
trunk/nhibernate/src/NHibernate/IMultiQuery.cs
trunk/nhibernate/src/NHibernate/IQuery.cs
trunk/nhibernate/src/NHibernate/ISession.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractDetachedQuery.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/DbCommandSet.cs
trunk/nhibernate/src/NHibernate/Impl/EnumerableImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate/Loader/Custom/ColumnCollectionAliases.cs
trunk/nhibernate/src/NHibernate/Loader/Custom/EntityFetchReturn.cs
trunk/nhibernate/src/NHibernate/Loader/Custom/ScalarReturn.cs
trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs
trunk/nhibernate/src/NHibernate/Loader/GeneratedCollectionAliases.cs
trunk/nhibernate/src/NHibernate/Loader/ICollectionAliases.cs
trunk/nhibernate/src/NHibernate/Loader/Loader.cs
trunk/nhibernate/src/NHibernate/LockMode.cs
trunk/nhibernate/src/NHibernate/Mapping/Collection.cs
trunk/nhibernate/src/NHibernate/Mapping/DenormalizedTable.cs
trunk/nhibernate/src/NHibernate/Mapping/IMetaAttributable.cs
trunk/nhibernate/src/NHibernate/Mapping/PersistentClass.cs
trunk/nhibernate/src/NHibernate/Mapping/RootClass.cs
trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
trunk/nhibernate/src/NHibernate/Persister/Collection/ICollectionPersister.cs
trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
trunk/nhibernate/src/NHibernate/Persister/Entity/IEntityPersister.cs
trunk/nhibernate/src/NHibernate/Persister/Entity/IQueryable.cs
trunk/nhibernate/src/NHibernate/Persister/Entity/JoinedSubclassEntityPersister.cs
trunk/nhibernate/src/NHibernate/Persister/PersisterFactory.cs
trunk/nhibernate/src/NHibernate/Properties/IGetter.cs
trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs
trunk/nhibernate/src/NHibernate/Proxy/AbstractLazyInitializer.cs
trunk/nhibernate/src/NHibernate/Proxy/INHibernateProxy.cs
trunk/nhibernate/src/NHibernate/Proxy/IProxyFactory.cs
trunk/nhibernate/src/NHibernate/QueryParameterException.cs
trunk/nhibernate/src/NHibernate/SqlCommand/OracleJoinFragment.cs
trunk/nhibernate/src/NHibernate/SqlCommand/Parameter.cs
trunk/nhibernate/src/NHibernate/SqlCommand/SqlInsertBuilder.cs
trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs
trunk/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs
trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs
trunk/nhibernate/src/NHibernate/Tuple/Component/IComponentTuplizer.cs
trunk/nhibernate/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs
trunk/nhibernate/src/NHibernate/Tuple/Entity/IEntityTuplizer.cs
trunk/nhibernate/src/NHibernate/Tuple/IInstantiator.cs
trunk/nhibernate/src/NHibernate/Type/ClassMetaType.cs
trunk/nhibernate/src/NHibernate/Type/CollectionType.cs
trunk/nhibernate/src/NHibernate/Type/EmbeddedComponentType.cs
trunk/nhibernate/src/NHibernate/Type/ILiteralType.cs
trunk/nhibernate/src/NHibernate/Type/IType.cs.xmldoc
trunk/nhibernate/src/NHibernate/Type/ManyToOneType.cs
trunk/nhibernate/src/NHibernate/Type/NullableType.cs
trunk/nhibernate/src/NHibernate/Type/PrimitiveType.cs
trunk/nhibernate/src/NHibernate/Type/TimeType.cs
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate/UserTypes/ILoggableUserType.cs
trunk/nhibernate/src/NHibernate/UserTypes/IUserCollectionType.cs
trunk/nhibernate/src/NHibernate/UserTypes/IUserType.cs
trunk/nhibernate/src/NHibernate/Util/JoinedEnumerable.cs
trunk/nhibernate/src/NHibernate/Util/ObjectUtils.cs
trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
trunk/nhibernate/src/NHibernate/Util/SafetyEnumerable.cs
trunk/nhibernate/src/NHibernate/Util/SequencedHashMap.cs
trunk/nhibernate/src/NHibernate/Util/SoftLimitMRUCache.cs
trunk/nhibernate/src/NHibernate/Util/StringHelper.cs
Modified: trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Action/CollectionAction.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -29,7 +29,7 @@
/// <param name="persister">The <see cref="ICollectionPersister"/> that is responsible for the persisting the Collection.</param>
/// <param name="collection">The Persistent collection.</param>
/// <param name="key">The identifier of the Collection.</param>
- /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param>
+ /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occurring in.</param>
protected CollectionAction(ICollectionPersister persister, IPersistentCollection collection, object key,
ISessionImplementor session)
{
@@ -91,7 +91,7 @@
// executed, since this may be an inverse="true"
// bidirectional association and it is one of the
// earlier entity actions which actually updates
- // the database (this action is resposible for
+ // the database (this action is responsible for
// second-level cache invalidation only)
if (persister.HasCache)
{
@@ -177,4 +177,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Action/EntityAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/EntityAction.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Action/EntityAction.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -28,7 +28,7 @@
/// </summary>
/// <param name="session">The session from which this action is coming.</param>
/// <param name="id">The id of the entity</param>
- /// <param name="instance">The entiyt instance</param>
+ /// <param name="instance">The entity instance</param>
/// <param name="persister">The entity persister</param>
protected internal EntityAction(ISessionImplementor session, object id, object instance, IEntityPersister persister)
{
Modified: trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -84,7 +84,7 @@
TypeFactory.DeepCopy(state, persister.PropertyTypes, persister.PropertyCheckability, state, Session);
if (persister.HasUpdateGeneratedProperties)
{
- // this entity defines proeprty generation, so process those generated
+ // this entity defines property generation, so process those generated
// values...
persister.ProcessUpdateGeneratedProperties(id, instance, state, Session);
if (persister.IsVersionPropertyGenerated)
Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -527,7 +527,7 @@
#region IDisposable Members
/// <summary>
- /// A flag to indicate if <c>Disose()</c> has been called.
+ /// A flag to indicate if <c>Dispose()</c> has been called.
/// </summary>
private bool _isAlreadyDisposed;
Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -115,7 +115,7 @@
}
catch (Exception e)
{
- throw new HibernateException("An exception occured when executing batch queries", e);
+ throw new HibernateException("An exception occurred when executing batch queries", e);
}
}
@@ -153,4 +153,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/AssertionFailure.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AssertionFailure.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/AssertionFailure.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -16,7 +16,7 @@
public AssertionFailure() : base(String.Empty)
{
LogManager.GetLogger(typeof(AssertionFailure)).Error(
- "An AssertionFailure occured - this may indicate a bug in NHibernate");
+ "An AssertionFailure occurred - this may indicate a bug in NHibernate");
}
/// <summary>
@@ -26,7 +26,7 @@
public AssertionFailure(string message) : base(message)
{
LogManager.GetLogger(typeof(AssertionFailure)).Error(
- "An AssertionFailure occured - this may indicate a bug in NHibernate", this);
+ "An AssertionFailure occurred - this may indicate a bug in NHibernate", this);
}
/// <summary>
@@ -41,7 +41,7 @@
public AssertionFailure(string message, Exception innerException) : base(message, innerException)
{
LogManager.GetLogger(typeof(AssertionFailure)).Error(
- "An AssertionFailure occured - this may indicate a bug in NHibernate", innerException);
+ "An AssertionFailure occurred - this may indicate a bug in NHibernate", innerException);
}
/// <summary>
@@ -58,4 +58,4 @@
{
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Cache/CachedItem.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cache/CachedItem.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cache/CachedItem.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -64,7 +64,7 @@
}
/// <summary>
- /// Don't overwite already cached items
+ /// Don't overwrite already cached items
/// </summary>
/// <param name="txTimestamp"></param>
/// <param name="newVersion"></param>
@@ -85,4 +85,4 @@
"}";
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -32,7 +32,7 @@
/// <summary>
/// Initializes a new instance of the <see cref="QueryKey"/> class.
/// </summary>
- /// <param name="factory">the sesion factory for this query key, required to get the identifiers of entities that are used as values.</param>
+ /// <param name="factory">the session factory for this query key, required to get the identifiers of entities that are used as values.</param>
/// <param name="queryString">The query string.</param>
/// <param name="queryParameters">The query parameters.</param>
/// <param name="filters">The filters.</param>
@@ -254,4 +254,4 @@
return buf.ToString();
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/CallbackException.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/CallbackException.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/CallbackException.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -15,7 +15,7 @@
/// is not a null reference, the current exception is raised in a catch block that handles
/// the inner exception.
/// </param>
- public CallbackException(Exception innerException) : this("An exception occured in a callback", innerException)
+ public CallbackException(Exception innerException) : this("An exception occurred in a callback", innerException)
{
}
@@ -55,4 +55,4 @@
{
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -652,7 +652,7 @@
}
/// <summary>
- /// Generate DDL for droping tables
+ /// Generate DDL for dropping tables
/// </summary>
/// <seealso cref="NHibernate.Tool.hbm2ddl.SchemaExport" />
public string[] GenerateDropSchemaScript(Dialect.Dialect dialect)
@@ -1778,7 +1778,7 @@
/// </summary>
/// <param name="type">The <see cref="ListenerType"/>.</param>
/// <param name="listeners">The listener for <paramref name="type"/> or null to clear.</param>
- /// <remarks>Listners of <paramref name="listeners"/> must implements one of the interface of event listenesr.</remarks>
+ /// <remarks>Listeners of <paramref name="listeners"/> must implements one of the interface of event listenesr.</remarks>
/// <seealso cref="NHibernate.Event"/>
public void SetListeners(ListenerType type, object[] listeners)
{
Modified: trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/ClassCacheConfiguration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/ClassCacheConfiguration.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/ClassCacheConfiguration.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -158,7 +158,7 @@
/// </summary>
/// <remarks>
/// Not implemented in Cache.
- /// Defaul value <see cref="ClassCacheInclude.All"/>.
+ /// Default value <see cref="ClassCacheInclude.All"/>.
/// </remarks>
public ClassCacheInclude Include
{
Modified: trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -51,7 +51,7 @@
}
catch (Exception e)
{
- // Encapsule and reThrow
+ // Encapsulate and reThrow
throw new HibernateConfigException(e);
}
Parse(nav, fromAppSetting);
@@ -108,7 +108,7 @@
private static void LogWarnIgnoredProperty(string propName)
{
if (log.IsWarnEnabled)
- log.Warn(string.Format("{0} propety is ignored out of application configuration file.", propName));
+ log.Warn(string.Format("{0} property is ignored out of application configuration file.", propName));
}
private void ParseReflectionOptimizer(XPathNavigator navigator, bool fromAppConfig)
Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -29,9 +29,9 @@
/// corresponds to Java system-level properties; <c><session-factory></c>
/// section is the session-factory-level configuration.
///
- /// It is possible to use the applicatoin configuration file (App.config) together with the NHibernate
+ /// It is possible to use the application configuration file (App.config) together with the NHibernate
/// configuration file (hibernate.cfg.xml) at the same time.
- /// Properties in hibernate.cfg.xml override/merge properties in applicatoin configuration file where same
+ /// Properties in hibernate.cfg.xml override/merge properties in application configuration file where same
/// property is found. For others configuration a merge is applied.
/// </remarks>
public sealed class Environment
Modified: trunk/nhibernate/src/NHibernate/Cfg/ImprovedNamingStrategy.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/ImprovedNamingStrategy.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/ImprovedNamingStrategy.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -30,7 +30,7 @@
}
/// <summary>
- /// Return the full property path with underscore seperators, mixed case converted to underscores
+ /// Return the full property path with underscore separators, mixed case converted to underscores
/// </summary>
/// <param name="propertyName"></param>
/// <returns></returns>
@@ -60,7 +60,7 @@
}
/// <summary>
- /// Return the full property path prefixed by the unqualified class name, with underscore seperators, mixed case converted to underscores
+ /// Return the full property path prefixed by the unqualified class name, with underscore separators, mixed case converted to underscores
/// </summary>
/// <param name="className"></param>
/// <param name="propertyName"></param>
@@ -96,4 +96,4 @@
return buf.ToString();
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -79,7 +79,7 @@
/// Binding table between the logical column name and the name out of the naming strategy
/// for each table.
/// According that when the column name is not set, the property name is considered as such
- /// This means that while theorically possible through the naming strategy contract, it is
+ /// This means that while theoretically possible through the naming strategy contract, it is
/// forbidden to have 2 real columns having the same logical name
/// </summary>
protected internal IDictionary<Table, ColumnNames> columnNameBindingPerTable;
@@ -387,7 +387,7 @@
/// <summary>
/// Gets or sets a boolean indicating if the Fully Qualified Type name should
- /// automattically have an import added as the class name.
+ /// automatically have an import added as the class name.
/// </summary>
/// <value><see langword="true" /> if the class name should be used as an import.</value>
/// <remarks>
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -737,7 +737,7 @@
return columns.ToString();
}
- //automatically makes a column with the default name if none is specifed by XML
+ //automatically makes a column with the default name if none is specified by XML
protected void BindSimpleValue(XmlNode node, SimpleValue model, bool isNullable, string path)
{
BindSimpleValueType(node, model);
Modified: trunk/nhibernate/src/NHibernate/Classic/ValidationFailure.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Classic/ValidationFailure.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Classic/ValidationFailure.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -13,7 +13,7 @@
/// <summary>
/// Initializes a new instance of the <see cref="ValidationFailure"/> class.
/// </summary>
- public ValidationFailure() : base("A validation failure occured")
+ public ValidationFailure() : base("A validation failure occurred")
{
}
@@ -33,7 +33,7 @@
/// is not a null reference, the current exception is raised in a catch block that handles
/// the inner exception.
/// </param>
- public ValidationFailure(Exception innerException) : base("A validation failure occured", innerException)
+ public ValidationFailure(Exception innerException) : base("A validation failure occurred", innerException)
{
}
@@ -65,4 +65,4 @@
{
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Collection/AbstractPersistentCollection.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -361,7 +361,7 @@
}
/// <summary>
- /// Queue an addition, delete etc. if the peristent collection supports it
+ /// Queue an addition, delete etc. if the persistent collection supports it
/// </summary>
protected void QueueOperation(IDelayedOperation element)
{
@@ -493,7 +493,7 @@
/// <summary>
/// Gets a <see cref="Boolean"/> indicating if the underlying collection is directly
- /// accessable through code.
+ /// accessible through code.
/// </summary>
/// <value>
/// <see langword="true" /> if we are not guaranteed that the NHibernate collection wrapper
@@ -865,4 +865,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Collection/IPersistentCollection.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Collection/IPersistentCollection.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Collection/IPersistentCollection.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -127,7 +127,7 @@
/// <summary>
/// Gets a <see cref="bool"/> indicating if the underlying collection is directly
- /// accessable through code.
+ /// accessible through code.
/// </summary>
/// <value>
/// <see langword="true" /> if we are not guaranteed that the NHibernate collection wrapper
@@ -338,4 +338,4 @@
/// </returns>
ICollection GetOrphans(object snapshot, string entityName);
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Collection/PersistentBag.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -67,7 +67,7 @@
// the multiplicity would be broken ... so use an idbag instead
object element = role.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
// NH Different behavior : we don't check for null
- // The NH-750 test show how cheking for null we are ignoring the not-found tag and
+ // The NH-750 test show how checking for null we are ignoring the not-found tag and
// the DB may have some records ignored by NH. This issue may need some more deep consideration.
//if (element != null)
bag.Add(element);
@@ -538,4 +538,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -76,7 +76,7 @@
private object GetIdentifier(int index)
{
- // NH specific : To emulate IDictionary behavior but using Dictionary<int, object> (whitout boxing/unboxing for index)
+ // NH specific : To emulate IDictionary behavior but using Dictionary<int, object> (without boxing/unboxing for index)
object result;
identifiers.TryGetValue(index, out result);
return result;
@@ -437,4 +437,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Criterion/ICriteriaQuery.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/ICriteriaQuery.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Criterion/ICriteriaQuery.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -64,7 +64,7 @@
int GetIndexForAlias();
/// <summary>
- /// When adding values to the query string it is imparative that they are reported via this function back to the query builder.
+ /// When adding values to the query string it is imperative that they are reported via this function back to the query builder.
/// Do not report the same item multiple times as it will be assumed to be a separate parameter.
/// </summary>
void AddUsedTypedValues(TypedValue [] values);
Modified: trunk/nhibernate/src/NHibernate/Criterion/LogicalExpression.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/LogicalExpression.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Criterion/LogicalExpression.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -47,7 +47,7 @@
/// Combines the <see cref="TypedValue"/> for the Left Hand Side and the
/// Right Hand Side of the Expression into one array.
/// </summary>
- /// <returns>An arry of <see cref="TypedValue"/>s.</returns>
+ /// <returns>An array of <see cref="TypedValue"/>s.</returns>
public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
TypedValue[] lhstv = _lhs.GetTypedValues(criteria, criteriaQuery);
Modified: trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Criterion/Restrictions.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -663,7 +663,7 @@
}
/// <summary>
- /// Return the conjuction of two expressions
+ /// Return the conjunction of two expressions
/// </summary>
/// <param name="lhs">The Expression to use as the Left Hand Side.</param>
/// <param name="rhs">The Expression to use as the Right Hand Side.</param>
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2008-09-03 21:03:23 UTC (rev 3744)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2008-09-03 21:35:18 UTC (rev 3745)
@@ -989,7 +989,7 @@
}
...
[truncated message content] |
|
From: <fab...@us...> - 2008-09-03 22:46:33
|
Revision: 3748
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3748&view=rev
Author: fabiomaulo
Date: 2008-09-03 22:46:41 +0000 (Wed, 03 Sep 2008)
Log Message:
-----------
- Merge r3747 (fix NH-1462)
- Minors
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Util/StringHelper.cs
trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Util/StringHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2008-09-03 22:42:30 UTC (rev 3747)
+++ trunk/nhibernate/src/NHibernate/Util/StringHelper.cs 2008-09-03 22:46:41 UTC (rev 3748)
@@ -235,7 +235,7 @@
/// <returns></returns>
public static string GetFullClassname(string typeName)
{
- return typeName.Trim().Split(' ', ',')[0];
+ return new TypeNameParser().ParseTypeName(typeName, null, null).Type;
}
/// <summary>
@@ -492,7 +492,7 @@
char first = name[0];
// Should we check for prefix == string.Empty rather than a length check?
- if (prefix != null && prefix.Length > 0 && first != SingleQuote && !char.IsDigit(first))
+ if (!string.IsNullOrEmpty(prefix) && first != SingleQuote && !char.IsDigit(first))
{
return prefix + Dot + name;
}
@@ -505,7 +505,7 @@
public static string[] Qualify(string prefix, string[] names)
{
// Should we check for prefix == string.Empty rather than a length check?
- if (prefix != null && prefix.Length > 0)
+ if (!string.IsNullOrEmpty(prefix))
{
int len = names.Length;
string[] qualified = new string[len];
Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs 2008-09-03 22:42:30 UTC (rev 3747)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs 2008-09-03 22:46:41 UTC (rev 3748)
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using NHibernate.Util;
using NUnit.Framework;
@@ -29,6 +30,17 @@
}
[Test]
+ public void GetFullClassNameForGenericType()
+ {
+ string typeName = typeof (IDictionary<int, string>).AssemblyQualifiedName;
+ string expected = typeof (IDictionary<int, string>).FullName;
+ Assert.AreEqual(expected, StringHelper.GetFullClassname(typeName));
+ typeName = "some.namespace.SomeType`1[[System.Int32, mscorlib], System.Int32], some.assembly";
+ expected = "some.namespace.SomeType`1[[System.Int32, mscorlib], System.Int32]";
+ Assert.AreEqual(expected, StringHelper.GetFullClassname(typeName));
+ }
+
+ [Test]
public void CountUnquotedParams()
{
// Base case, no values
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-08 04:52:07
|
Revision: 3752
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3752&view=rev
Author: fabiomaulo
Date: 2008-09-08 04:52:17 +0000 (Mon, 08 Sep 2008)
Log Message:
-----------
Merge (NH-1434, NH-1435, NH-1436, NH-1437, NH-1438, NH-1439 (by David Bachmann with little change))
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/PostgreSQL81Dialect.cs
trunk/nhibernate/src/NHibernate/Mapping/Table.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/ProjectionsTest.cs
trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1250/PolymorphicJoinFetchFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1408/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Dialect/PostgreSQL81Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/PostgreSQL81Dialect.cs 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate/Dialect/PostgreSQL81Dialect.cs 2008-09-08 04:52:17 UTC (rev 3752)
@@ -68,11 +68,12 @@
/// <summary>
/// PostgreSQL supports <c>serial</c> and <c>serial4</c> type for 4 bytes integer auto increment column.
/// <c>bigserial</c> or <c>serial8</c> can be used for 8 bytes integer auto increment column.
- /// This dialect uses <c>serial</c>
/// </summary>
- public override string IdentityColumnString
+ /// <returns><c>bigserial</c> if <paramref name="type"/> equal Int64,
+ /// <c>serial</c> otherwise</returns>
+ public override string GetIdentityColumnString(DbType type)
{
- get { return "serial"; }
+ return (type == DbType.Int64) ? "bigserial" : "serial";
}
/// <summary>
@@ -105,4 +106,4 @@
get { return true; }
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Mapping/Table.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-09-08 04:52:17 UTC (rev 3752)
@@ -441,7 +441,7 @@
buf.Append(col.GetSqlType(dialect, p));
}
buf.Append(' ')
- .Append(dialect.IdentityColumnString);
+ .Append(dialect.GetIdentityColumnString(col.GetSqlTypeCode(p).DbType));
}
else
{
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/ProjectionsTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/ProjectionsTest.cs 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/ProjectionsTest.cs 2008-09-08 04:52:17 UTC (rev 3752)
@@ -143,7 +143,7 @@
using (ISession session = sessions.OpenSession())
{
IList<Student> list = session.CreateCriteria(typeof(Student))
- .Add(Expression.Like(Projections.Id(), "2", MatchMode.Start))
+ .Add(Expression.Like(Projections.Property("Name"), "aye", MatchMode.Start))
.List<Student>();
Assert.AreEqual(27L, list[0].StudentNumber);
}
@@ -155,7 +155,7 @@
using (ISession session = sessions.OpenSession())
{
IList<Student> list = session.CreateCriteria(typeof(Student))
- .Add(Expression.InsensitiveLike(Projections.Id(), "2", MatchMode.Start))
+ .Add(Expression.InsensitiveLike(Projections.Property("Name"), "AYE", MatchMode.Start))
.List<Student>();
Assert.AreEqual(27L, list[0].StudentNumber);
}
@@ -344,4 +344,4 @@
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate.Test/Legacy/FooBarTest.cs 2008-09-08 04:52:17 UTC (rev 3752)
@@ -2467,22 +2467,22 @@
s.CreateQuery("select count(*) from Bar as bar where 'abc' in elements(bar.Baz.FooArray)").List();
s.CreateQuery("select count(*) from Bar as bar where 1 in indices(bar.Baz.FooArray)").List();
s.CreateQuery(
- "select count(*) from Bar as bar, bar.Component.Glarch.ProxyArray as g where g.id in indices(bar.Baz.FooArray)").
+ "select count(*) from Bar as bar, bar.Component.Glarch.ProxyArray as g where cast(g.id as Int32) in indices(bar.Baz.FooArray)").
List();
s.CreateQuery(
- "select max( elements(bar.Baz.FooArray) ) from Bar as bar, bar.Component.Glarch.ProxyArray as g where g.id in indices(bar.Baz.FooArray)")
+ "select max( elements(bar.Baz.FooArray) ) from Bar as bar, bar.Component.Glarch.ProxyArray as g where cast(g.id as Int32) in indices(bar.Baz.FooArray)")
.List();
s.CreateQuery(
- "select count(*) from Bar as bar where 1 in (from bar.Component.Glarch.ProxyArray g where g.Name='foo')").List();
+ "select count(*) from Bar as bar where '1' in (from bar.Component.Glarch.ProxyArray g where g.Name='foo')").List();
s.CreateQuery(
- "select count(*) from Bar as bar where 1 in (from g in bar.Component.Glarch.ProxyArray.elements where g.Name='foo')")
+ "select count(*) from Bar as bar where '1' in (from g in bar.Component.Glarch.ProxyArray.elements where g.Name='foo')")
.List();
// TODO: figure out why this is throwing an ORA-1722 error
if (!(Dialect is Oracle9Dialect))
{
s.CreateQuery(
- "select count(*) from Bar as bar left outer join bar.Component.Glarch.ProxyArray as pg where 1 in (from g in bar.Component.Glarch.ProxyArray)")
+ "select count(*) from Bar as bar left outer join bar.Component.Glarch.ProxyArray as pg where '1' in (from g in bar.Component.Glarch.ProxyArray)")
.List();
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-08 04:52:17 UTC (rev 3752)
@@ -40,7 +40,7 @@
{
s.EnableFilter("RelatedClass_Valued").SetParameter("forValue", 2);
IQuery q =
- s.CreateQuery("select mc.Description, count(mc.Id) from MainClass mc join mc.Related r group by mc.Description");
+ s.CreateQuery("select mc.Description, count(mc.Id) from MainClass mc join mc.Related r group by mc.Description order by mc.Description");
IList l = q.List();
Assert.AreEqual(2, l.Count);
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1250/PolymorphicJoinFetchFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1250/PolymorphicJoinFetchFixture.cs 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1250/PolymorphicJoinFetchFixture.cs 2008-09-08 04:52:17 UTC (rev 3752)
@@ -1,3 +1,4 @@
+using NHibernate.Dialect;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.NH1250
@@ -15,8 +16,12 @@
get { return "NH1250"; }
}
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2000Dialect;
+ }
+
[Test]
-
public void FetchUsingICriteria()
{
using (ISession s = OpenSession())
@@ -30,7 +35,6 @@
}
[Test]
-
public void FetchUsingIQuery()
{
using (ISession s = OpenSession())
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1408/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1408/Mappings.hbm.xml 2008-09-08 04:26:20 UTC (rev 3751)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1408/Mappings.hbm.xml 2008-09-08 04:52:17 UTC (rev 3752)
@@ -17,9 +17,7 @@
<one-to-many class="DbResourceKey" />
</bag>
- <property name="RawValue" type="StringClob">
- <column name="Value" sql-type="ntext" not-null="true" />
- </property>
+ <property name="RawValue" type="string" column="Value" not-null="true"/>
<subclass name="StringDbResource" discriminator-value="string" />
<subclass name="IntDbResource" discriminator-value="int" />
@@ -38,4 +36,4 @@
<property name="Key0" column="Key0" type="String(25)" index="RES_KEY0_IDX" />
<property name="Key1" column="Key1" type="String(25)" index="RES_KEY1_IDX" />
</class>
-</hibernate-mapping>
\ No newline at end of file
+</hibernate-mapping>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2008-09-13 06:36:10
|
Revision: 3757
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3757&view=rev
Author: ayenderahien
Date: 2008-09-13 06:36:20 +0000 (Sat, 13 Sep 2008)
Log Message:
-----------
Fixing binary parameter lengths on SQL CE
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/DialectTest/SqlCEDialectFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs 2008-09-13 06:35:33 UTC (rev 3756)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs 2008-09-13 06:36:20 UTC (rev 3757)
@@ -17,8 +17,8 @@
RegisterColumnType(DbType.AnsiString, "NVARCHAR(255)");
RegisterColumnType(DbType.AnsiString, 4000, "NVARCHAR");
RegisterColumnType(DbType.AnsiString, 1073741823, "NTEXT");
- RegisterColumnType(DbType.Binary, "VARBINARY(4000)");
- RegisterColumnType(DbType.Binary, 4000, "VARBINARY($l)");
+ RegisterColumnType(DbType.Binary, "VARBINARY(8000)");
+ RegisterColumnType(DbType.Binary, 8000, "VARBINARY($l)");
RegisterColumnType(DbType.Binary, 1073741823, "IMAGE");
RegisterColumnType(DbType.Boolean, "BIT");
RegisterColumnType(DbType.Byte, "TINYINT");
Added: trunk/nhibernate/src/NHibernate.Test/DialectTest/SqlCEDialectFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/DialectTest/SqlCEDialectFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/DialectTest/SqlCEDialectFixture.cs 2008-09-13 06:36:20 UTC (rev 3757)
@@ -0,0 +1,30 @@
+namespace NHibernate.Test.DialectTest
+{
+ using Dialect;
+ using Mapping;
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class SqlCEDialectFixture
+ {
+ [Test]
+ public void BinaryBlob_mapping_to_SqlCe_types()
+ {
+ Dialect dialect = new MsSqlCeDialect();
+ SimpleValue sv = new SimpleValue();
+ sv.TypeName = NHibernateUtil.BinaryBlob.Name;
+ Column column = new Column();
+ column.Value = sv;
+
+ // no length, should produce maximum
+ Assert.AreEqual("VARBINARY(8000)", column.GetSqlType(dialect, null));
+
+ // maximum varbinary length is 8000
+ column.Length = 8000;
+ Assert.AreEqual("VARBINARY(8000)", column.GetSqlType(dialect,null));
+
+ column.Length = 8001;
+ Assert.AreEqual("IMAGE", column.GetSqlType(dialect, null));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-09-13 06:35:33 UTC (rev 3756)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-09-13 06:36:20 UTC (rev 3757)
@@ -135,6 +135,7 @@
<Compile Include="DialectTest\FirebirdDialectFixture.cs" />
<Compile Include="DialectTest\MsSql2005DialectFixture.cs" />
<Compile Include="DialectTest\MsSqlDialectFixture.cs" />
+ <Compile Include="DialectTest\SqlCEDialectFixture.cs" />
<Compile Include="DialectTest\SQLiteDialectFixture.cs" />
<Compile Include="DriverTest\NullReferenceFixture.cs" />
<Compile Include="DriverTest\OracleClientDriverFixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-14 13:24:59
|
Revision: 3760
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3760&view=rev
Author: fabiomaulo
Date: 2008-09-14 13:25:09 +0000 (Sun, 14 Sep 2008)
Log Message:
-----------
Merge r3758 (fix NH-1484)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Engine/IMapping.cs
trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-09-14 13:07:51 UTC (rev 3759)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-09-14 13:25:09 UTC (rev 3760)
@@ -153,6 +153,11 @@
}
return prop.Type;
}
+
+ public bool HasNonIdentifierPropertyNamedId(string className)
+ {
+ return "id".Equals(GetIdentifierPropertyName(className));
+ }
}
[NonSerialized]
Modified: trunk/nhibernate/src/NHibernate/Engine/IMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/IMapping.cs 2008-09-14 13:07:51 UTC (rev 3759)
+++ trunk/nhibernate/src/NHibernate/Engine/IMapping.cs 2008-09-14 13:25:09 UTC (rev 3760)
@@ -13,5 +13,7 @@
string GetIdentifierPropertyName(string className);
IType GetReferencedPropertyType(string className, string propertyName);
+
+ bool HasNonIdentifierPropertyNamedId(string className);
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2008-09-14 13:07:51 UTC (rev 3759)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2008-09-14 13:25:09 UTC (rev 3760)
@@ -818,6 +818,11 @@
return GetEntityPersister(className).GetPropertyType(propertyName);
}
+ public bool HasNonIdentifierPropertyNamedId(string className)
+ {
+ return "id".Equals(GetIdentifierPropertyName(className));
+ }
+
public IConnectionProvider ConnectionProvider
{
get { return settings.ConnectionProvider; }
Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs 2008-09-14 13:07:51 UTC (rev 3759)
+++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs 2008-09-14 13:25:09 UTC (rev 3760)
@@ -180,17 +180,8 @@
private bool HasNonIdentifierPropertyNamedId(EntityType entityType, IMapping factory)
{
- // TODO : would be great to have a Mapping#hasNonIdentifierPropertyNamedId method
- // I don't believe that Mapping#getReferencedPropertyType accounts for the identifier property; so
- // if it returns for a property named 'id', then we should have a non-id field named id
- try
- {
- return factory.GetReferencedPropertyType(entityType.GetAssociatedEntityName(), EntityPersister.EntityID) != null;
- }
- catch (MappingException)
- {
- return false;
- }
+ // NH: Different implementation (removed done "todo" of H3.2.6)
+ return factory.HasNonIdentifierPropertyNamedId(entityType.GetAssociatedEntityName());
}
protected void InitComponentPropertyPaths(string path, IAbstractComponentType type, string[] columns,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-14 14:09:26
|
Revision: 3762
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3762&view=rev
Author: fabiomaulo
Date: 2008-09-14 14:09:37 +0000 (Sun, 14 Sep 2008)
Log Message:
-----------
Merge r3761 (fix NH-1483)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/BaseClass.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/SubClass.cs
Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2008-09-14 13:53:17 UTC (rev 3761)
+++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2008-09-14 14:09:37 UTC (rev 3762)
@@ -416,7 +416,7 @@
// Entity was found in second-level cache...
// NH: Different behavior (take a look to options.ExactPersister (NH-295))
- if (!options.ExactPersister || entry.Subclass.Equals(persister.EntityName))
+ if (!options.ExactPersister || persister.EntityMetamodel.SubclassEntityNames.Contains(entry.Subclass))
{
return AssembleCacheEntry(entry, @event.EntityId, persister, @event);
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/BaseClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/BaseClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/BaseClass.cs 2008-09-14 14:09:37 UTC (rev 3762)
@@ -0,0 +1,14 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1483
+{
+ public abstract class BaseClass
+ {
+ private Guid _id;
+
+ public Guid Id
+ {
+ get { return _id; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Fixture.cs 2008-09-14 14:09:37 UTC (rev 3762)
@@ -0,0 +1,111 @@
+using System;
+using System.Data;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1483
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnTearDown()
+ {
+ DeleteAll(true);
+ }
+
+ /// <summary>
+ /// Tests that a Subclass can be loaded from second level cache as the specifed
+ /// type of baseclass
+ /// </summary>
+ /// <typeparam name="TBaseClass">The type of the BaseClass to test.</typeparam>
+ public void TestLoadFromSecondLevelCache<TBaseClass>() where TBaseClass : BaseClass
+ {
+ //create a new persistent entity to work with
+ Guid id = CreateAndSaveNewSubclass().Id;
+
+ using (ISession session = OpenSession())
+ {
+ //make sure the entity can be pulled
+ TBaseClass entity = session.Get<TBaseClass>(id);
+ Assert.IsNotNull(entity);
+ }
+
+ //delete the subclass so we know we will be getting
+ //it from the second level cache
+ DeleteAll(false);
+
+ using (ISession session = OpenSession())
+ {
+ //reload the subclass, this should pull it directly from cache
+ TBaseClass restoredEntity = session.Get<TBaseClass>(id);
+
+ Assert.IsNotNull(restoredEntity);
+ }
+ }
+
+ /// <summary>
+ /// Creates and save a new subclass to the database.
+ /// </summary>
+ /// <returns>the new persistent SubClass</returns>
+ private SubClass CreateAndSaveNewSubclass()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction trans = session.BeginTransaction())
+ {
+ SubClass entity = new SubClass();
+ session.Save(entity);
+ trans.Commit();
+
+ return entity;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Deletes all the baseclass entities from the persistence medium
+ /// </summary>
+ /// <param name="inNHibernateScope">whether to delete the entities though NHibernate
+ /// scope our outside of the scope so that entities will still remain in the session cache</param>
+ private void DeleteAll(bool inNHibernateScope)
+ {
+ using (ISession session = OpenSession())
+ {
+ if (inNHibernateScope)
+ {
+ using (ITransaction trans = session.BeginTransaction())
+ {
+ session.Delete("from BaseClass");
+ trans.Commit();
+ }
+ }
+ else
+ {
+ //delete directly from the db
+ using (IDbCommand cmd = session.Connection.CreateCommand())
+ {
+ cmd.CommandText = "DELETE FROM BaseClass";
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Verifies that a subclass can be loaded from the second level cache
+ /// </summary>
+ [Test]
+ public void LoadSubclassFromSecondLevelCache()
+ {
+ TestLoadFromSecondLevelCache<SubClass>();
+ }
+
+ /// <summary>
+ /// Verifies that a subclass can be loaded from the second level cache
+ /// </summary>
+ [Test]
+ public void LoadSubclassFromSecondLevelCacheAsBaseClass()
+ {
+ TestLoadFromSecondLevelCache<BaseClass>();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/Mappings.hbm.xml 2008-09-14 14:09:37 UTC (rev 3762)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1483"
+ assembly="NHibernate.Test"
+ default-access="field.camelcase-underscore">
+ <class name="BaseClass" lazy="false" discriminator-value="0">
+ <id name="Id" type="guid"
+ unsaved-value="null">
+ <generator class="guid.comb" />
+ </id>
+ <discriminator column="discriminator" type="System.Int32" />
+
+ <subclass name="SubClass" discriminator-value="1" lazy="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/SubClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/SubClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1483/SubClass.cs 2008-09-14 14:09:37 UTC (rev 3762)
@@ -0,0 +1,8 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1483
+{
+ public class SubClass : BaseClass
+ {
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-14 13:53:17 UTC (rev 3761)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-14 14:09:37 UTC (rev 3762)
@@ -466,6 +466,9 @@
<Compile Include="NHSpecificTest\NH1419\Entry.cs" />
<Compile Include="NHSpecificTest\NH1419\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1464\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1483\BaseClass.cs" />
+ <Compile Include="NHSpecificTest\NH1483\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1483\SubClass.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1453,6 +1456,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1483\Mappings.hbm.xml" />
<EmbeddedResource Include="TypesTest\EntityClass.hbm.xml" />
<EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManyBagToSetMapping.hbm.xml" />
<EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManySetToSetMapping.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-18 11:44:28
|
Revision: 3764
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3764&view=rev
Author: fabiomaulo
Date: 2008-09-18 18:44:37 +0000 (Thu, 18 Sep 2008)
Log Message:
-----------
- Test for Extends (2 ignored tests related with entity-name feature)
- Refactoring for generic, equality comparer and some other stuff
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingsQueue.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs
trunk/nhibernate/src/NHibernate/Util/AssemblyQualifiedTypeName.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Extendshbm/
trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.cs
trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.cs
trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs
trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.cs
trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/allinone.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/allseparateinone.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/entitynames.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/packageentitynames.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Extendshbm/unionsubclass.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs 2008-09-18 18:41:18 UTC (rev 3763)
+++ trunk/nhibernate/src/NHibernate/Cfg/ClassExtractor.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -1,7 +1,7 @@
-using System.Collections;
using System.Xml;
-using Iesi.Collections;
using NHibernate.Util;
+using System.Collections.Generic;
+using Iesi.Collections.Generic;
namespace NHibernate.Cfg
{
@@ -16,24 +16,69 @@
/// </summary>
public class ClassEntry
{
- private readonly AssemblyQualifiedTypeName _fullExtends;
- private readonly AssemblyQualifiedTypeName _fullClassName;
+ private readonly string entityName;
+ private readonly string extendsEntityName;
+ private readonly AssemblyQualifiedTypeName fullExtends;
+ private readonly AssemblyQualifiedTypeName fullClassName;
+ private readonly int hashCode;
- public ClassEntry(string extends, string className, string assembly, string @namespace)
+ public ClassEntry(string extends, string className, string entityName, string assembly, string @namespace)
{
- _fullExtends = extends == null ? null : TypeNameParser.Parse(extends, @namespace, assembly);
- _fullClassName = className == null ? null : TypeNameParser.Parse(className, @namespace, assembly);
+ fullExtends = string.IsNullOrEmpty(extends) ? null : TypeNameParser.Parse(extends, @namespace, assembly);
+ fullClassName = string.IsNullOrEmpty(className) ? null : TypeNameParser.Parse(className, @namespace, assembly);
+ this.entityName = entityName;
+ extendsEntityName = string.IsNullOrEmpty(extends) ? null : extends;
+ unchecked
+ {
+ hashCode = (entityName != null ? entityName.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (fullExtends != null ? fullExtends.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (fullClassName != null ? fullClassName.GetHashCode() : 0);
+ }
}
public AssemblyQualifiedTypeName FullExtends
{
- get { return _fullExtends; }
+ get { return fullExtends; }
}
public AssemblyQualifiedTypeName FullClassName
{
- get { return _fullClassName; }
+ get { return fullClassName; }
}
+
+ public string EntityName
+ {
+ get { return entityName; }
+ }
+
+ public string ExtendsEntityName
+ {
+ get { return extendsEntityName; }
+ }
+
+ public override bool Equals(object obj)
+ {
+ ClassEntry that = obj as ClassEntry;
+ return Equals(that);
+ }
+
+ public bool Equals(ClassEntry obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+ return Equals(obj.entityName, entityName) && Equals(obj.fullExtends, fullExtends) && Equals(obj.fullClassName, fullClassName);
+ }
+
+ public override int GetHashCode()
+ {
+ return hashCode;
+ }
}
/// <summary>
@@ -42,7 +87,7 @@
/// </summary>
/// <param name="document">A validated <see cref="XmlDocument"/> representing
/// a mapping file.</param>
- public static ICollection GetClassEntries(XmlDocument document)
+ public static ICollection<ClassEntry> GetClassEntries(XmlDocument document)
{
// TODO this should be extracted into a utility method since there's similar
// code in Configuration
@@ -50,7 +95,7 @@
nsmgr.AddNamespace(HbmConstants.nsPrefix, Configuration.MappingSchemaXMLNS);
// Since the document is validated, no error checking is done in this method.
- HashedSet classEntries = new HashedSet();
+ HashedSet<ClassEntry> classEntries = new HashedSet<ClassEntry>();
XmlNode root = document.DocumentElement;
@@ -65,12 +110,15 @@
nsmgr
);
- foreach (XmlNode classNode in classNodes)
+ if (classNodes != null)
{
- string name = XmlHelper.GetAttributeValue(classNode, "name");
- string extends = XmlHelper.GetAttributeValue(classNode, "extends");
- ClassEntry ce = new ClassEntry(extends, name, assembly, @namespace);
- classEntries.Add(ce);
+ foreach (XmlNode classNode in classNodes)
+ {
+ string name = XmlHelper.GetAttributeValue(classNode, "name");
+ string extends = XmlHelper.GetAttributeValue(classNode, "extends");
+ string entityName = XmlHelper.GetAttributeValue(classNode, "entity-name");
+ classEntries.Add(new ClassEntry(extends, name, entityName, assembly, @namespace));
+ }
}
return classEntries;
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingsQueue.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingsQueue.cs 2008-09-18 18:41:18 UTC (rev 3763)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingsQueue.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -1,11 +1,8 @@
-using System;
using System.Collections;
-using System.Reflection;
using System.Text;
+using Iesi.Collections.Generic;
+using System.Collections.Generic;
-using Iesi.Collections;
-using NHibernate.Util;
-
namespace NHibernate.Cfg
{
/// <summary>
@@ -13,9 +10,9 @@
/// </summary>
public class MappingsQueue
{
- private readonly ISet _processedClassNames = new HashedSet();
-
- private readonly IList _unavailableEntries = new ArrayList();
+ private readonly ISet<string> _processedClassNames = new HashedSet<string>();
+
+ private readonly List<MappingsQueueEntry> _unavailableEntries = new List<MappingsQueueEntry>();
private readonly Queue _availableEntries = new Queue();
/// <summary>
@@ -23,9 +20,7 @@
/// </summary>
public void AddDocument(NamedXmlDocument document)
{
- MappingsQueueEntry re = new MappingsQueueEntry(
- document,
- ClassExtractor.GetClassEntries(document.Document));
+ MappingsQueueEntry re = new MappingsQueueEntry(document, ClassExtractor.GetClassEntries(document.Document));
AddEntry(re);
}
@@ -57,7 +52,7 @@
}
}
- private void AddProcessedClassNames(ICollection classNames)
+ private void AddProcessedClassNames(ICollection<string> classNames)
{
_processedClassNames.AddAll(classNames);
if (classNames.Count > 0)
@@ -113,7 +108,7 @@
foreach (MappingsQueueEntry resourceEntry in resourceEntries)
{
- foreach (AssemblyQualifiedTypeName className in resourceEntry.RequiredClassNames)
+ foreach (string className in resourceEntry.RequiredClassNames)
{
message.Append('\n')
.Append(className);
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs 2008-09-18 18:41:18 UTC (rev 3763)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -1,6 +1,7 @@
-using System.Collections;
using Iesi.Collections;
using NHibernate.Util;
+using Iesi.Collections.Generic;
+using System.Collections.Generic;
namespace NHibernate.Cfg
{
@@ -10,10 +11,10 @@
public class MappingsQueueEntry
{
private readonly NamedXmlDocument document;
- private readonly ISet requiredClassNames;
- private readonly ISet containedClassNames;
+ private readonly ISet<string> requiredClassNames;
+ private readonly ISet<string> containedClassNames;
- public MappingsQueueEntry(NamedXmlDocument document, ICollection classEntries)
+ public MappingsQueueEntry(NamedXmlDocument document, IEnumerable<ClassExtractor.ClassEntry> classEntries)
{
this.document = document;
@@ -27,28 +28,34 @@
get { return document; }
}
- private static ISet GetClassNames(ICollection classEntries)
+ private static ISet<string> GetClassNames(IEnumerable<ClassExtractor.ClassEntry> classEntries)
{
- HashedSet result = new HashedSet();
+ HashedSet<string> result = new HashedSet<string>();
foreach (ClassExtractor.ClassEntry ce in classEntries)
{
- if (ce.FullClassName != null)
- result.Add(ce.FullClassName);
+ if (ce.EntityName != null)
+ {
+ result.Add(ce.EntityName);
+ }
+ else if (ce.FullClassName != null)
+ {
+ result.Add(ce.FullClassName.Type);
+ }
}
return result;
}
- private static ISet GetExtendsNames(ICollection classEntries)
+ private static ISet<string> GetExtendsNames(IEnumerable<ClassExtractor.ClassEntry> classEntries)
{
- HashedSet result = new HashedSet();
+ HashedSet<string> result = new HashedSet<string>();
foreach (ClassExtractor.ClassEntry ce in classEntries)
{
if (ce.FullExtends != null)
{
- result.Add(ce.FullExtends);
+ result.Add(ce.FullExtends.Type);
}
}
@@ -60,12 +67,12 @@
/// needed by the classes in this resource.
/// </summary>
/// <returns>An <see cref="ISet"/> of <see cref="AssemblyQualifiedTypeName" /></returns>
- public ICollection RequiredClassNames
+ public ICollection<string> RequiredClassNames
{
get { return requiredClassNames; }
}
- public ICollection ContainedClassNames
+ public ICollection<string> ContainedClassNames
{
get { return containedClassNames; }
}
Modified: trunk/nhibernate/src/NHibernate/Util/AssemblyQualifiedTypeName.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/AssemblyQualifiedTypeName.cs 2008-09-18 18:41:18 UTC (rev 3763)
+++ trunk/nhibernate/src/NHibernate/Util/AssemblyQualifiedTypeName.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -4,8 +4,9 @@
{
public class AssemblyQualifiedTypeName
{
- private string type;
- private string assembly;
+ private readonly string type;
+ private readonly string assembly;
+ private readonly int hashCode;
public AssemblyQualifiedTypeName(string type, string assembly)
{
@@ -15,6 +16,10 @@
}
this.type = type;
this.assembly = assembly;
+ unchecked
+ {
+ hashCode = (type.GetHashCode() * 397) ^ (assembly != null ? assembly.GetHashCode() : 0);
+ }
}
public string Type
@@ -30,40 +35,35 @@
public override bool Equals(object obj)
{
AssemblyQualifiedTypeName other = obj as AssemblyQualifiedTypeName;
-
- if (other == null) return false;
-
- return string.Equals(type, other.type)
- && string.Equals(assembly, other.assembly);
+ return Equals(other);
}
- public override int GetHashCode()
+ public override string ToString()
{
- unchecked
+ if (assembly == null)
{
- int hashCode = 0;
- if (type != null)
- {
- hashCode += type.GetHashCode();
- }
+ return type;
+ }
- if (assembly != null)
- {
- hashCode += assembly.GetHashCode();
- }
-
- return hashCode;
- }
+ return string.Concat(type, ", ", assembly);
}
- public override string ToString()
+ public bool Equals(AssemblyQualifiedTypeName obj)
{
- if (assembly == null)
+ if (obj == null)
{
- return type;
+ return false;
}
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+ return Equals(obj.type, type) && Equals(obj.assembly, assembly);
+ }
- return string.Concat(type, ", ", assembly);
+ public override int GetHashCode()
+ {
+ return hashCode;
}
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,20 @@
+namespace NHibernate.Test.Extendshbm
+{
+ public class Customer: Person
+ {
+ private Employee salesperson;
+ private string comments;
+
+ public virtual Employee Salesperson
+ {
+ get { return salesperson; }
+ set { salesperson = value; }
+ }
+
+ public virtual string Comments
+ {
+ get { return comments; }
+ set { comments = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/Customer.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm"
+ default-access="field.camelcase">
+ <subclass name="Customer" extends="Person">
+ <property name="Comments"/>
+ <many-to-one name="Salesperson"/>
+ </subclass>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,27 @@
+namespace NHibernate.Test.Extendshbm
+{
+ public class Employee: Person
+ {
+ private string title;
+ private decimal salary;
+ private Employee manager;
+
+ public virtual string Title
+ {
+ get { return title; }
+ set { title = value; }
+ }
+
+ public virtual decimal Salary
+ {
+ get { return salary; }
+ set { salary = value; }
+ }
+
+ public virtual Employee Manager
+ {
+ get { return manager; }
+ set { manager = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/Employee.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm"
+ default-access="field.camelcase">
+
+ <subclass name="Employee" extends="Person">
+ <property name="Title" length="20"/>
+ <property name="Salary" length="2"/>
+ <many-to-one name="Manager"/>
+ </subclass>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,132 @@
+using NHibernate.Cfg;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.Extendshbm
+{
+ [TestFixture]
+ public class ExtendsFixture
+ {
+ protected static string BaseForMappings
+ {
+ get { return "NHibernate.Test."; }
+ }
+
+ [Test]
+ public void AllInOne()
+ {
+ Configuration cfg = new Configuration();
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.allinone.hbm.xml", typeof(ExtendsFixture).Assembly);
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof(Person).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof(Employee).FullName), Is.Not.Null);
+ }
+
+ [Test]
+ public void OutOfOrder()
+ {
+ Configuration cfg = new Configuration();
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.Customer.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Null, "cannot be in the configuration yet!");
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.Person.hbm.xml", typeof (ExtendsFixture).Assembly);
+ cfg.AddResource(BaseForMappings + "Extendshbm.Employee.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildSessionFactory();
+
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Person).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Not.Null);
+ }
+
+ [Test]
+ public void NwaitingForSuper()
+ {
+ Configuration cfg = new Configuration();
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.Customer.hbm.xml", typeof (ExtendsFixture).Assembly);
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Null, "cannot be in the configuration yet!");
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.Employee.hbm.xml", typeof (ExtendsFixture).Assembly);
+ Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Null, "cannot be in the configuration yet!");
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.Person.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildMappings();
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Person).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Not.Null);
+ }
+
+ [Test]
+ public void MissingSuper()
+ {
+ Configuration cfg = new Configuration();
+
+ try
+ {
+ cfg.AddResource(BaseForMappings + "Extendshbm.Customer.hbm.xml", typeof (ExtendsFixture).Assembly);
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Null, "cannot be in the configuration yet!");
+ cfg.AddResource(BaseForMappings + "Extendshbm.Employee.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildSessionFactory();
+
+ Assert.Fail("Should not be able to build sessionfactory without a Person");
+ }
+ catch (HibernateException) {}
+ }
+
+ [Test]
+ public void AllSeparateInOne()
+ {
+ Configuration cfg = new Configuration();
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.allseparateinone.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildSessionFactory();
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Person).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Not.Null);
+ }
+
+ [Test, Ignore("Not supported yet!")]
+ public void JoinedSubclassAndEntityNamesOnly()
+ {
+ Configuration cfg = new Configuration();
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.entitynames.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildMappings();
+ Assert.That(cfg.GetClassMapping("EntityHasName"), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping("EntityCompany"), Is.Not.Null);
+ }
+
+ [Test, Ignore("Not supported yet!")]
+ public void EntityNamesWithPackageFailureExpected()
+ {
+ Configuration cfg = new Configuration();
+ cfg.AddResource(BaseForMappings + "Extendshbm.packageentitynames.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildMappings();
+
+ Assert.That(cfg.GetClassMapping("EntityHasName"), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping("EntityCompany"), Is.Not.Null);
+ }
+
+ [Test]
+ public void UnionSubclass()
+ {
+ Configuration cfg = new Configuration();
+
+ cfg.AddResource(BaseForMappings + "Extendshbm.unionsubclass.hbm.xml", typeof (ExtendsFixture).Assembly);
+
+ cfg.BuildMappings();
+
+ Assert.That(cfg.GetClassMapping(typeof (Person).FullName), Is.Not.Null);
+ Assert.That(cfg.GetClassMapping(typeof (Customer).FullName), Is.Not.Null);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.cs 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,27 @@
+namespace NHibernate.Test.Extendshbm
+{
+ public class Person
+ {
+ private long id;
+ private string name;
+ private char sex;
+
+ public virtual long Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual char Sex
+ {
+ get { return sex; }
+ set { sex = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/Person.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm"
+ default-access="field.camelcase">
+
+ <class name="Person">
+ <id name="Id" column="person_id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+ <discriminator type="string"/>
+ <property name="Name" not-null="true" length="80"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/allinone.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/allinone.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/allinone.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm"
+ default-access="field.camelcase">
+
+ <class name="Person">
+ <id name="Id" column="person_id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+ <discriminator type="string"/>
+ <property name="Name" not-null="true" length="80"/>
+
+ <subclass name="Employee">
+ <property name="Title" length="20"/>
+ <property name="Salary" length="2"/>
+ <many-to-one name="Manager"/>
+ </subclass>
+
+ <subclass name="Customer">
+ <property name="Comments"/>
+ <many-to-one name="Salesperson"/>
+ </subclass>
+ </class>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/allseparateinone.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/allseparateinone.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/allseparateinone.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm"
+ default-access="field.camelcase">
+
+ <class name="Person">
+
+ <id name="Id" column="person_id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+ <discriminator type="string"/>
+
+ <property name="Name" not-null="true" length="80"/>
+
+ <subclass name="Employee">
+ <property name="Title" length="20"/>
+ <property name="Salary" length="2"/>
+ <many-to-one name="Manager"/>
+ </subclass>
+
+
+
+ </class>
+
+
+ <subclass name="Customer" extends="Person">
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </subclass>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/entitynames.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/entitynames.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/entitynames.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
+
+ <class lazy="true" entity-name="EntityHasName" table="F5_ENTITY_HASNAME">
+ <id name="id" column="ID" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="attrName" type="string">
+ <column name="NAME"/>
+ </property>
+ </class>
+ <joined-subclass lazy="true" entity-name="EntityCompany" table="F5_ENTITY_COMPANY" extends="EntityHasName">
+ <key column="REF_ID"/>
+ <many-to-one name="parent" entity-name="EntityHasName"/>
+ </joined-subclass>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/packageentitynames.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/packageentitynames.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/packageentitynames.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm">
+
+ <class lazy="true" entity-name="EntityHasName" table="F5_ENTITY_HASNAME">
+ <id name="id" column="ID" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="attrName" type="string">
+ <column name="NAME"/>
+ </property>
+ </class>
+ <joined-subclass lazy="true" entity-name="EntityCompany" table="F5_ENTITY_COMPANY" extends="EntityHasName">
+ <key column="REF_ID"/>
+ <many-to-one name="parent" entity-name="EntityHasName"/>
+ </joined-subclass>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Extendshbm/unionsubclass.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/unionsubclass.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/unionsubclass.hbm.xml 2008-09-18 18:44:37 UTC (rev 3764)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Extendshbm"
+ default-access="field.camelcase">
+
+ <class name="Person">
+ <id name="id" column="person_id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+ <discriminator type="string"/>
+
+ <property name="name" not-null="true" length="80"/>
+ </class>
+
+
+ <union-subclass name="Customer" extends="Person">
+ <property name="Comments"/>
+ <many-to-one name="Salesperson"/>
+ </union-subclass>
+
+ <subclass name="Employee" extends="Person">
+ <property name="Title" length="20"/>
+ <property name="Salary" length="2"/>
+ <many-to-one name="Manager"/>
+ </subclass>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-18 18:41:18 UTC (rev 3763)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-18 18:44:37 UTC (rev 3764)
@@ -205,6 +205,10 @@
<Compile Include="ExpressionTest\SQLExpressionFixture.cs" />
<Compile Include="ExpressionTest\SubQueries\Classes.cs" />
<Compile Include="ExpressionTest\SubQueries\SubQueriesSqlFixture.cs" />
+ <Compile Include="Extendshbm\Customer.cs" />
+ <Compile Include="Extendshbm\Employee.cs" />
+ <Compile Include="Extendshbm\ExtendsFixture.cs" />
+ <Compile Include="Extendshbm\Person.cs" />
<Compile Include="Extralazy\Document.cs" />
<Compile Include="Extralazy\ExtraLazyFixture.cs" />
<Compile Include="Extralazy\Group.cs" />
@@ -1456,6 +1460,14 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="Extendshbm\allinone.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\allseparateinone.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\Customer.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\Employee.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\entitynames.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\packageentitynames.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\Person.hbm.xml" />
+ <EmbeddedResource Include="Extendshbm\unionsubclass.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1483\Mappings.hbm.xml" />
<EmbeddedResource Include="TypesTest\EntityClass.hbm.xml" />
<EmbeddedResource Include="Events\Collections\Association\Bidirectional\ManyToMany\BidirectionalManyToManyBagToSetMapping.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open...
[truncated message content] |
|
From: <fab...@us...> - 2008-09-18 13:29:53
|
Revision: 3765
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3765&view=rev
Author: fabiomaulo
Date: 2008-09-18 20:29:55 +0000 (Thu, 18 Sep 2008)
Log Message:
-----------
- Refactoring
- One more step to support entity-name
- previous ignored test passed
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-09-18 18:44:37 UTC (rev 3764)
+++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-09-18 20:29:55 UTC (rev 3765)
@@ -173,20 +173,11 @@
propertyReferences.Add(upr);
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public PersistentClass GetClass(System.Type type)
- {
- // TODO NH: Remove this method
- return GetClass(type.FullName);
- }
-
public PersistentClass GetClass(string className)
{
- return classes[className];
+ PersistentClass result;
+ classes.TryGetValue(className, out result);
+ return result;
}
/// <summary>
@@ -215,11 +206,6 @@
set { defaultAssembly = value; }
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="role"></param>
- /// <returns></returns>
public Mapping.Collection GetCollection(string role)
{
return collections[role];
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2008-09-18 18:44:37 UTC (rev 3764)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2008-09-18 20:29:55 UTC (rev 3765)
@@ -37,7 +37,7 @@
/// <param name="className"></param>
/// <param name="mappings"></param>
/// <returns></returns>
- protected static string FullClassName(string className, Mappings mappings)
+ protected static string FullQualifiedClassName(string className, Mappings mappings)
{
if (className == null)
return null;
@@ -47,6 +47,23 @@
}
/// <summary>
+ /// Converts a partial class name into a fully one
+ /// </summary>
+ /// <param name="className"></param>
+ /// <param name="mappings"></param>
+ /// <returns>The class FullName (without the assembly)</returns>
+ /// <remarks>
+ /// The FullName is equivalent to the default entity-name
+ /// </remarks>
+ protected static string FullClassName(string className, Mappings mappings)
+ {
+ if (className == null)
+ return null;
+
+ return TypeNameParser.Parse(className, mappings.DefaultNamespace, mappings.DefaultAssembly).Type;
+ }
+
+ /// <summary>
/// Attempts to find a type by its full name. Throws a <see cref="MappingException" />
/// using the provided <paramref name="errorMessage" /> in case of failure.
/// </summary>
@@ -72,7 +89,7 @@
/// <summary>
/// Similar to <see cref="ClassForFullNameChecked" />, but handles short class names
- /// by calling <see cref="FullClassName" />.
+ /// by calling <see cref="FullQualifiedClassName" />.
/// </summary>
/// <param name="name"></param>
/// <param name="mappings"></param>
@@ -80,7 +97,7 @@
/// <returns></returns>
protected static System.Type ClassForNameChecked(string name, Mappings mappings, string errorMessage)
{
- return ClassForFullNameChecked(FullClassName(name, mappings), errorMessage);
+ return ClassForFullNameChecked(FullQualifiedClassName(name, mappings), errorMessage);
}
protected static string GetClassName(string unqualifiedName, Mappings mappings)
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2008-09-18 18:44:37 UTC (rev 3764)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2008-09-18 20:29:55 UTC (rev 3765)
@@ -235,7 +235,7 @@
XmlNode tuplizer = LocateTuplizerDefinition(node, EntityMode.Map);
if (tuplizer != null)
{
- string tupClassName = FullClassName(tuplizer.Attributes["class"].Value, mappings);
+ string tupClassName = FullQualifiedClassName(tuplizer.Attributes["class"].Value, mappings);
entity.AddTuplizer(EntityMode.Map, tupClassName);
}
}
@@ -253,7 +253,7 @@
XmlNode tuplizer = LocateTuplizerDefinition(node, EntityMode.Xml);
if (tuplizer != null)
{
- string tupClassName = FullClassName(tuplizer.Attributes["class"].Value, mappings);
+ string tupClassName = FullQualifiedClassName(tuplizer.Attributes["class"].Value, mappings);
entity.AddTuplizer(EntityMode.Xml, tupClassName);
}
}
@@ -279,7 +279,7 @@
XmlNode tuplizer = LocateTuplizerDefinition(node, EntityMode.Poco);
if (tuplizer != null)
{
- string tupClassName = FullClassName(tuplizer.Attributes["class"].Value, mappings);
+ string tupClassName = FullQualifiedClassName(tuplizer.Attributes["class"].Value, mappings);
entity.AddTuplizer(EntityMode.Poco, tupClassName);
}
}
@@ -460,14 +460,20 @@
{
XmlAttribute extendsAttr = subnode.Attributes["extends"];
if (extendsAttr == null)
+ {
throw new MappingException("'extends' attribute is not found.");
- String extendsValue = FullClassName(extendsAttr.Value, mappings);
- System.Type superclass = ClassForFullNameChecked(extendsValue,
- "extended class not found: {0}");
- PersistentClass superModel = mappings.GetClass(superclass);
-
+ }
+ string extendsName = extendsAttr.Value;
+ PersistentClass superModel = mappings.GetClass(extendsName);
+ if(superModel == null)
+ {
+ string qualifiedExtendsName = FullClassName(extendsName, mappings);
+ superModel = mappings.GetClass(qualifiedExtendsName);
+ }
if (superModel == null)
- throw new MappingException("Cannot extend unmapped class: " + extendsValue);
+ {
+ throw new MappingException("Cannot extend unmapped class: " + extendsName);
+ }
return superModel;
}
@@ -541,7 +547,7 @@
model.ComponentClass = ClassForNameChecked(
classNode.Value, mappings,
"component class not found: {0}");
- model.ComponentClassName = FullClassName(classNode.Value, mappings);
+ model.ComponentClassName = FullQualifiedClassName(classNode.Value, mappings);
model.IsEmbedded = false;
}
else if (reflectedClass != null)
@@ -767,7 +773,7 @@
{
originalTypeName = typeChild.Attributes["name"].Value;
// NH: allow className completing it with assembly+namespace of the mapping doc.
- typeName = FullClassName(originalTypeName, mappings);
+ typeName = FullQualifiedClassName(originalTypeName, mappings);
foreach (XmlNode childNode in typeChild.ChildNodes)
parameters.Add(childNode.Attributes["name"].Value, childNode.InnerText.Trim());
}
@@ -780,7 +786,7 @@
TypeDef typeDef = originalTypeName == null ? mappings.GetTypeDef(typeName) : mappings.GetTypeDef(originalTypeName);
if (typeDef != null)
{
- typeName = FullClassName(typeDef.TypeClass, mappings);
+ typeName = FullQualifiedClassName(typeDef.TypeClass, mappings);
// parameters on the property mapping should
// override parameters in the typedef
Dictionary<string, string> allParameters = new Dictionary<string, string>(typeDef.Parameters);
@@ -1207,7 +1213,7 @@
string entityName = XmlHelper.GetAttributeValue(elem, "entity-name");
string className = XmlHelper.GetAttributeValue(elem, "class");
entityName = entityName
- ?? (className == null ? null : StringHelper.GetFullClassname(FullClassName(className, model)));
+ ?? (className == null ? null : StringHelper.GetFullClassname(FullQualifiedClassName(className, model)));
return entityName;
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2008-09-18 18:44:37 UTC (rev 3764)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2008-09-18 20:29:55 UTC (rev 3765)
@@ -152,7 +152,7 @@
}
else
{
- model.TypeName = FullClassName(typeName, mappings);
+ model.TypeName = FullQualifiedClassName(typeName, mappings);
}
}
@@ -211,7 +211,7 @@
model.IsSorted = true;
if (!sortedAtt.Value.Equals("natural"))
{
- string comparatorClassName = FullClassName(sortedAtt.Value, mappings);
+ string comparatorClassName = FullQualifiedClassName(sortedAtt.Value, mappings);
try
{
model.Comparer = Activator.CreateInstance(ReflectHelper.ClassForName(comparatorClassName));
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2008-09-18 18:44:37 UTC (rev 3764)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2008-09-18 20:29:55 UTC (rev 3765)
@@ -123,7 +123,7 @@
{
foreach (HbmImport importSchema in mappingSchema.import ?? new HbmImport[0])
{
- string fullClassName = FullClassName(importSchema.@class, mappings);
+ string fullClassName = FullQualifiedClassName(importSchema.@class, mappings);
string rename = importSchema.rename ?? StringHelper.GetClassname(fullClassName);
log.DebugFormat("Import: {0} -> {1}", rename, fullClassName);
@@ -135,7 +135,7 @@
{
foreach (HbmTypedef typedef in mappingSchema.typedef ?? new HbmTypedef[0])
{
- string typeClass = FullClassName(typedef.@class, mappings);
+ string typeClass = FullQualifiedClassName(typedef.@class, mappings);
string typeName = typedef.name;
IEnumerable<HbmParam> paramIter = typedef.param ?? new HbmParam[0];
Dictionary<string, string> parameters = new Dictionary<string, string>(5);
Modified: trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2008-09-18 18:44:37 UTC (rev 3764)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2008-09-18 20:29:55 UTC (rev 3765)
@@ -92,7 +92,7 @@
Assert.That(cfg.GetClassMapping(typeof (Employee).FullName), Is.Not.Null);
}
- [Test, Ignore("Not supported yet!")]
+ [Test]
public void JoinedSubclassAndEntityNamesOnly()
{
Configuration cfg = new Configuration();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-18 14:05:51
|
Revision: 3766
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3766&view=rev
Author: fabiomaulo
Date: 2008-09-18 21:06:00 +0000 (Thu, 18 Sep 2008)
Log Message:
-----------
EntityNames recognitions inside a hbm file with default namespace
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs
trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs 2008-09-18 20:29:55 UTC (rev 3765)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingsQueueEntry.cs 2008-09-18 21:06:00 UTC (rev 3766)
@@ -1,7 +1,5 @@
-using Iesi.Collections;
-using NHibernate.Util;
+using System.Collections.Generic;
using Iesi.Collections.Generic;
-using System.Collections.Generic;
namespace NHibernate.Cfg
{
@@ -10,17 +8,16 @@
/// </summary>
public class MappingsQueueEntry
{
+ private readonly HashedSet<string> containedClassNames;
private readonly NamedXmlDocument document;
- private readonly ISet<string> requiredClassNames;
- private readonly ISet<string> containedClassNames;
+ private readonly HashedSet<string> requiredClassNames;
public MappingsQueueEntry(NamedXmlDocument document, IEnumerable<ClassExtractor.ClassEntry> classEntries)
{
this.document = document;
containedClassNames = GetClassNames(classEntries);
- requiredClassNames = GetExtendsNames(classEntries);
- requiredClassNames.RemoveAll(containedClassNames);
+ requiredClassNames = GetRequiredClassNames(classEntries, containedClassNames);
}
public NamedXmlDocument Document
@@ -28,8 +25,25 @@
get { return document; }
}
- private static ISet<string> GetClassNames(IEnumerable<ClassExtractor.ClassEntry> classEntries)
+ /// <summary>
+ /// Gets the names of all entities outside this resource
+ /// needed by the classes in this resource.
+ /// </summary>
+ public ICollection<string> RequiredClassNames
{
+ get { return requiredClassNames; }
+ }
+
+ /// <summary>
+ /// Gets the names of all entities in this resource
+ /// </summary>
+ public ICollection<string> ContainedClassNames
+ {
+ get { return containedClassNames; }
+ }
+
+ private static HashedSet<string> GetClassNames(IEnumerable<ClassExtractor.ClassEntry> classEntries)
+ {
HashedSet<string> result = new HashedSet<string>();
foreach (ClassExtractor.ClassEntry ce in classEntries)
@@ -47,13 +61,14 @@
return result;
}
- private static ISet<string> GetExtendsNames(IEnumerable<ClassExtractor.ClassEntry> classEntries)
+ private static HashedSet<string> GetRequiredClassNames(IEnumerable<ClassExtractor.ClassEntry> classEntries,
+ ICollection<string> containedNames)
{
HashedSet<string> result = new HashedSet<string>();
foreach (ClassExtractor.ClassEntry ce in classEntries)
{
- if (ce.FullExtends != null)
+ if (ce.ExtendsEntityName != null && !containedNames.Contains(ce.FullExtends.Type) && !containedNames.Contains(ce.ExtendsEntityName))
{
result.Add(ce.FullExtends.Type);
}
@@ -61,20 +76,5 @@
return result;
}
-
- /// <summary>
- /// Gets the names of all classes outside this resource
- /// needed by the classes in this resource.
- /// </summary>
- /// <returns>An <see cref="ISet"/> of <see cref="AssemblyQualifiedTypeName" /></returns>
- public ICollection<string> RequiredClassNames
- {
- get { return requiredClassNames; }
- }
-
- public ICollection<string> ContainedClassNames
- {
- get { return containedClassNames; }
- }
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2008-09-18 20:29:55 UTC (rev 3765)
+++ trunk/nhibernate/src/NHibernate.Test/Extendshbm/ExtendsFixture.cs 2008-09-18 21:06:00 UTC (rev 3766)
@@ -104,7 +104,7 @@
Assert.That(cfg.GetClassMapping("EntityCompany"), Is.Not.Null);
}
- [Test, Ignore("Not supported yet!")]
+ [Test]
public void EntityNamesWithPackageFailureExpected()
{
Configuration cfg = new Configuration();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2008-09-25 09:51:42
|
Revision: 3779
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3779&view=rev
Author: ayenderahien
Date: 2008-09-25 09:50:03 +0000 (Thu, 25 Sep 2008)
Log Message:
-----------
Better handling resultTransformers on multi criteria and multi queries
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-09-20 22:06:36 UTC (rev 3778)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-09-25 09:50:03 UTC (rev 3779)
@@ -18,8 +18,8 @@
{
public class MultiCriteriaImpl : IMultiCriteria
{
- private static readonly ILog log = LogManager.GetLogger(typeof (MultiCriteriaImpl));
- private readonly IList criteriaQueries = new ArrayList();
+ private static readonly ILog log = LogManager.GetLogger(typeof(MultiCriteriaImpl));
+ private readonly IList<ICriteria> criteriaQueries = new List<ICriteria>();
private readonly SessionImpl session;
private readonly ISessionFactoryImplementor factory;
@@ -30,7 +30,7 @@
private readonly List<CriteriaLoader> loaders = new List<CriteriaLoader>();
private readonly Dialect.Dialect dialect;
private IList criteriaResults;
- private Dictionary<string, int> criteriaResultPositions = new Dictionary<string, int>();
+ private readonly Dictionary<string, int> criteriaResultPositions = new Dictionary<string, int>();
private bool isCacheable = false;
private bool forceCacheRefresh = false;
private string cacheRegion;
@@ -114,10 +114,10 @@
IList result =
assembler.GetResultFromQueryCache(session,
- combinedParameters,
- querySpaces,
- queryCache,
- key);
+ combinedParameters,
+ querySpaces,
+ queryCache,
+ key);
if (result == null)
{
@@ -139,11 +139,21 @@
{
if (resultTransformer != null)
{
- for (int i = 0, len = results.Count; i < len; ++i)
+ for (int i = 0; i < results.Count; i++)
{
results[i] = resultTransformer.TransformList((IList)results[i]);
}
}
+ else
+ {
+ for (int i = 0; i < results.Count; i++)
+ {
+ var critImp = criteriaQueries[i] as CriteriaImpl;
+ if(critImp==null || critImp.ResultTransformer==null)
+ continue;
+ results[i] = critImp.ResultTransformer.TransformList((IList)results[i]);
+ }
+ }
return results;
}
@@ -200,11 +210,11 @@
Loader.Loader.Advance(reader, selection);
}
int count;
- for (count = 0; count < maxRows && reader.Read(); count++)
+ for (count = 0; count < maxRows && reader.Read(); count++)
{
object o =
loader.GetRowFromResultSet(reader, session, queryParameters, loader.GetLockModes(queryParameters.LockModes),
- null, hydratedObjects[i], keys, false);
+ null, hydratedObjects[i], keys, false);
if (createSubselects[i])
{
subselectResultKeys[i].Add(keys);
@@ -307,7 +317,7 @@
{
for (int i = 0; i < loaders.Count; i++)
{
- QueryParameters parameter = parameters[i];
+ QueryParameters parameter = parameters[i];
RowSelection selection = parameter.RowSelection;
if (Loader.Loader.UseLimit(selection, dialect) && dialect.BindLimitParametersFirst)
{
@@ -326,7 +336,8 @@
public IMultiCriteria Add(string key, ICriteria criteria)
{
ThrowIfKeyAlreadyExists(key);
- criteriaResultPositions.Add(key, criteriaQueries.Add(criteria));
+ criteriaQueries.Add(criteria);
+ criteriaResultPositions.Add(key, criteriaQueries.Count - 1);
return this;
}
@@ -341,7 +352,8 @@
public IMultiCriteria Add(string key, DetachedCriteria detachedCriteria)
{
ThrowIfKeyAlreadyExists(key);
- criteriaResultPositions.Add(key, criteriaQueries.Add(detachedCriteria.GetExecutableCriteria(session)));
+ criteriaQueries.Add(detachedCriteria.GetExecutableCriteria(session));
+ criteriaResultPositions.Add(key, criteriaQueries.Count-1);
return this;
}
@@ -399,8 +411,8 @@
positionalParameterTypes.AddRange(queryParameters.PositionalParameterTypes);
positionalParameterValues.AddRange(queryParameters.PositionalParameterValues);
}
- combinedQueryParameters.PositionalParameterTypes = (IType[]) positionalParameterTypes.ToArray(typeof (IType));
- combinedQueryParameters.PositionalParameterValues = (object[]) positionalParameterValues.ToArray(typeof (object));
+ combinedQueryParameters.PositionalParameterTypes = (IType[])positionalParameterTypes.ToArray(typeof(IType));
+ combinedQueryParameters.PositionalParameterValues = (object[])positionalParameterValues.ToArray(typeof(object));
return combinedQueryParameters;
}
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-09-20 22:06:36 UTC (rev 3778)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-09-25 09:50:03 UTC (rev 3779)
@@ -396,9 +396,9 @@
protected virtual IList GetResultList(IList results)
{
- for (int i = 0, len = results.Count; i < len; ++i)
+ for (int i = 0, len = results.Count; i < len; ++i)
{
- IList subList = (IList)results[i];
+ IList subList = (IList)results[i];
QueryParameters parameter = Parameters[i];
HolderInstantiator holderInstantiator = GetHolderInstantiator(parameter);
if (holderInstantiator.IsRequired)
@@ -406,13 +406,16 @@
for (int j = 0; j < subList.Count; j++)
{
object[] row = subList[j] as object[];
- if(row!=null) //if the result is array
- subList[j] = holderInstantiator.Instantiate(row);
+ if (row == null)
+ row = new object[] { subList[j] };
+ subList[j] = holderInstantiator.Instantiate(row);
}
- if (holderInstantiator.ResultTransformer != null)
+ IResultTransformer transformer =
+ holderInstantiator.ResultTransformer;
+ if (transformer != null)
{
- results[i] = holderInstantiator.ResultTransformer.TransformList(subList);
+ results[i] = transformer.TransformList(subList);
}
}
}
@@ -426,7 +429,7 @@
{
return new HolderInstantiator(resultTransformer, null);
}
- if (parameter.ResultTransformer!=null)
+ if (parameter.ResultTransformer != null)
{
return new HolderInstantiator(parameter.ResultTransformer, null);
}
@@ -783,7 +786,7 @@
}
return false;
}
-
+
private void ThrowIfKeyAlreadyExists(string key)
{
if (criteriaResultPositions.ContainsKey(key))
Modified: trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs 2008-09-20 22:06:36 UTC (rev 3778)
+++ trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs 2008-09-25 09:50:03 UTC (rev 3779)
@@ -9,6 +9,8 @@
namespace NHibernate.Test.QueryTest
{
+ using Transform;
+
[TestFixture]
public class MultipleQueriesFixture : TestCase
{
@@ -417,5 +419,104 @@
}
}
+
+ [Test]
+ public void ExecutingCriteriaThroughMultiQueryTransformsResults()
+ {
+ CreateItems();
+
+ using (ISession session = OpenSession())
+ {
+ ResultTransformerStub transformer = new ResultTransformerStub();
+ IQuery criteria = session.CreateQuery("from Item")
+ .SetResultTransformer(transformer);
+ session.CreateMultiQuery()
+ .Add(criteria)
+ .List();
+
+ Assert.IsTrue(transformer.WasTransformTupleCalled, "Transform Tuple was not called");
+ Assert.IsTrue(transformer.WasTransformListCalled, "Transform List was not called");
+ }
+
+ RemoveAllItems();
+ }
+
+ [Test]
+ public void ExecutingCriteriaThroughMultiQueryTransformsResults_When_setting_on_multi_query_directly()
+ {
+ CreateItems();
+
+ using (ISession session = OpenSession())
+ {
+ ResultTransformerStub transformer = new ResultTransformerStub();
+ IQuery query = session.CreateQuery("from Item");
+ session.CreateMultiQuery()
+ .Add(query)
+ .SetResultTransformer(transformer)
+ .List();
+
+ Assert.IsTrue(transformer.WasTransformTupleCalled, "Transform Tuple was not called");
+ Assert.IsTrue(transformer.WasTransformListCalled, "Transform List was not called");
+ }
+
+ RemoveAllItems();
+ }
+
+
+ [Test]
+ public void ExecutingCriteriaThroughMultiCriteriaTransformsResults()
+ {
+ CreateItems();
+
+ using (ISession session = OpenSession())
+ {
+ ResultTransformerStub transformer = new ResultTransformerStub();
+ ICriteria criteria = session.CreateCriteria(typeof(Item))
+ .SetResultTransformer(transformer);
+ IMultiCriteria multiCriteria = session.CreateMultiCriteria()
+ .Add(criteria);
+ multiCriteria.List();
+
+ Assert.IsTrue(transformer.WasTransformTupleCalled, "Transform Tuple was not called");
+ Assert.IsTrue(transformer.WasTransformListCalled,"Transform List was not called");
+ }
+
+ RemoveAllItems();
+ }
+
+ public class ResultTransformerStub : IResultTransformer
+ {
+ private bool _wasTransformTupleCalled;
+ private bool _wasTransformListCalled;
+
+ public bool WasTransformTupleCalled
+ {
+ get { return _wasTransformTupleCalled; }
+ }
+
+ public bool WasTransformListCalled
+ {
+ get { return _wasTransformListCalled; }
+ }
+
+ public ResultTransformerStub()
+ {
+ _wasTransformTupleCalled = false;
+ _wasTransformListCalled = false;
+ }
+
+ public object TransformTuple(object[] tuple, string[]aliases)
+ {
+ _wasTransformTupleCalled = true;
+ return tuple;
+ }
+
+ public IList TransformList(IList collection)
+ {
+ _wasTransformListCalled = true;
+ return collection;
+ }
+ }
+
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-09-26 19:23:24
|
Revision: 3781
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3781&view=rev
Author: tehlike
Date: 2008-09-26 19:23:17 +0000 (Fri, 26 Sep 2008)
Log Message:
-----------
Fix for NH1499 by adding meaningful exception: Cannot use subqueries on a criteria without a projection.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/SubqueryExpression.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/
Modified: trunk/nhibernate/src/NHibernate/Criterion/SubqueryExpression.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/SubqueryExpression.cs 2008-09-26 18:24:00 UTC (rev 3780)
+++ trunk/nhibernate/src/NHibernate/Criterion/SubqueryExpression.cs 2008-09-26 19:23:17 UTC (rev 3781)
@@ -104,9 +104,15 @@
innerQuery =
new CriteriaQueryTranslator(factory, criteriaImpl, //implicit polymorphism not supported (would need a union)
criteriaImpl.EntityOrClassName, criteriaQuery.GenerateSQLAlias(), criteriaQuery);
-
- parameters = innerQuery.GetQueryParameters();
- types = innerQuery.ProjectedTypes;
+ if (innerQuery.HasProjection)
+ {
+ parameters = innerQuery.GetQueryParameters();
+ types = innerQuery.ProjectedTypes;
+ }
+ else
+ {
+ types = null;
+ }
}
public ICriteria Criteria
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-09-26 18:24:00 UTC (rev 3780)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-09-26 19:23:17 UTC (rev 3781)
@@ -491,6 +491,9 @@
<Compile Include="NHSpecificTest\NH1483\SubClass.cs" />
<Compile Include="NHSpecificTest\NH1488\Domain.cs" />
<Compile Include="NHSpecificTest\NH1488\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1499\Document.cs" />
+ <Compile Include="NHSpecificTest\NH1499\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1499\Person.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1464,6 +1467,9 @@
<EmbeddedResource Include="NHSpecificTest\NH1403\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH1499\Mappings.hbm.xml" />
+ </ItemGroup>
+ <ItemGroup>
<Folder Include="Properties\" />
<Folder Include="Unionsubclass2\" />
</ItemGroup>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-09-26 23:25:23
|
Revision: 3784
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3784&view=rev
Author: tehlike
Date: 2008-09-26 23:25:05 +0000 (Fri, 26 Sep 2008)
Log Message:
-----------
Applying patch for NH1502 by Jaroslav Mart?\195?\161sek with a little modification.
Converting "string orderByString" to "SqlString orderByString" in order to keep placeholder
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/Order.cs
trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs
trunk/nhibernate/src/NHibernate/Loader/Entity/CascadeEntityJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/Entity/EntityJoinWalker.cs
trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlSelectBuilderFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Person.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/Order.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Order.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/Criterion/Order.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -43,7 +43,7 @@
/// <summary>
/// Render the SQL fragment
/// </summary>
- public virtual string ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
+ public virtual SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
if(projection!=null)
{
@@ -52,7 +52,7 @@
SqlString truncated = NHibernate.Util.StringHelper.RemoveAsAliasesFromSql(produced);
sb = sb.Append(truncated);
sb = sb.Append(ascending ? " asc" : " desc");
- return sb.ToString();
+ return sb;
}
string[] columns = criteriaQuery.GetColumnAliasesUsingProjection(criteria, propertyName);
@@ -67,13 +67,13 @@
if (lower)
{
fragment.Append(factory.Dialect.LowercaseFunction)
- .Append('(');
+ .Append("(");
}
fragment.Append(columns[i]);
if (lower)
{
- fragment.Append(')');
+ fragment.Append(")");
}
fragment.Append(ascending ? " asc" : " desc");
@@ -84,7 +84,7 @@
}
}
- return fragment.ToString();
+ return new SqlString(fragment.ToString());
}
public override string ToString()
Modified: trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -28,7 +28,7 @@
alias = rootSqlAlias;
}
- protected void InitAll(SqlString whereString,string orderByString,LockMode lockMode)
+ protected void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode)
{
WalkEntityTree(persister, Alias);
IList<OuterJoinableAssociation> allAssociations = new List<OuterJoinableAssociation>(associations);
@@ -41,20 +41,20 @@
}
protected void InitProjection(SqlString projectionString, SqlString whereString,
- string orderByString, string groupByString, SqlString havingString, LockMode lockMode)
+ SqlString orderByString, string groupByString, SqlString havingString, LockMode lockMode)
{
WalkEntityTree(persister, Alias);
Persisters = new ILoadable[0];
InitStatementString(projectionString, whereString, orderByString, groupByString, havingString, lockMode);
}
- private void InitStatementString(SqlString condition, string orderBy, LockMode lockMode)
+ private void InitStatementString(SqlString condition, SqlString orderBy, LockMode lockMode)
{
InitStatementString(null, condition, orderBy, string.Empty, null, lockMode);
}
private void InitStatementString(SqlString projection,SqlString condition,
- string orderBy,string groupBy, SqlString having, LockMode lockMode)
+ SqlString orderBy,string groupBy, SqlString having, LockMode lockMode)
{
int joins = CountEntityPersisters(associations);
Suffixes = BasicLoader.GenerateSuffixes(joins + 1);
Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaQueryTranslator.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -189,21 +189,21 @@
return condition.ToSqlString();
}
- public string GetOrderBy()
+ public SqlString GetOrderBy()
{
- StringBuilder orderBy = new StringBuilder(30);
+ SqlStringBuilder orderBy = new SqlStringBuilder(30);
bool first = true;
foreach (CriteriaImpl.OrderEntry oe in rootCriteria.IterateOrderings())
{
if (!first)
{
- orderBy.Append(StringHelper.CommaSpace);
+ orderBy.Add(StringHelper.CommaSpace);
}
first = false;
- orderBy.Append(oe.Order.ToSqlString(oe.Criteria, this));
+ orderBy.Add(oe.Order.ToSqlString(oe.Criteria, this));
}
- return orderBy.ToString();
+ return orderBy.ToSqlString();
}
public ISessionFactoryImplementor Factory
@@ -718,4 +718,4 @@
#endregion
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/CascadeEntityJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Entity/CascadeEntityJoinWalker.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/Loader/Entity/CascadeEntityJoinWalker.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -19,7 +19,7 @@
//include the discriminator and class-level where, but not filters
.Add(persister.FilterFragment(Alias, new CollectionHelper.EmptyMapClass<string, IFilter>()));
- InitAll(whereCondition.ToSqlString(), string.Empty, LockMode.Read);
+ InitAll(whereCondition.ToSqlString(), SqlString.Empty, LockMode.Read);
}
protected override bool IsJoinedFetchEnabled(IAssociationType type, FetchMode config, CascadeStyle cascadeStyle)
@@ -38,4 +38,4 @@
get { return "load " + Persister.EntityName; }
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Loader/Entity/EntityJoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Entity/EntityJoinWalker.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/Loader/Entity/EntityJoinWalker.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -25,7 +25,7 @@
//include the discriminator and class-level where, but not filters
.Add(persister.FilterFragment(Alias, new CollectionHelper.EmptyMapClass<string, IFilter>()));
- InitAll(whereCondition.ToSqlString(), string.Empty, lockMode);
+ InitAll(whereCondition.ToSqlString(), SqlString.Empty, lockMode);
}
/// <summary>
@@ -42,4 +42,4 @@
get { return "load " + Persister.EntityName; }
}
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -525,21 +525,34 @@
return !tooDeep && !IsDuplicateAssociation(lhsTable, lhsColumnNames, type);
}
- protected string OrderBy(IList<OuterJoinableAssociation> associations, string orderBy)
+ protected SqlString OrderBy(IList<OuterJoinableAssociation> associations, SqlString orderBy)
{
return MergeOrderings(OrderBy(associations), orderBy);
}
- protected string MergeOrderings(string ass, string orderBy)
+ protected SqlString OrderBy(IList<OuterJoinableAssociation> associations, string orderBy)
{
+ return MergeOrderings(OrderBy(associations), new SqlString(orderBy));
+ }
+
+ protected SqlString MergeOrderings(SqlString ass, SqlString orderBy)
+ {
if (ass.Length == 0)
return orderBy;
else if (orderBy.Length == 0)
return ass;
else
- return ass + StringHelper.CommaSpace + orderBy;
+ return ass.Append(StringHelper.CommaSpace).Append(orderBy);
}
+ protected SqlString MergeOrderings(string ass, SqlString orderBy) {
+ return this.MergeOrderings(new SqlString(ass), orderBy);
+ }
+
+ protected SqlString MergeOrderings(string ass, string orderBy) {
+ return this.MergeOrderings(new SqlString(ass), new SqlString(orderBy));
+ }
+
/// <summary>
/// Generate a sequence of <c>LEFT OUTER JOIN</c> clauses for the given associations.
/// </summary>
@@ -597,9 +610,9 @@
/// <summary>
/// Get the order by string required for collection fetching
/// </summary>
- protected static string OrderBy(IList<OuterJoinableAssociation> associations)
+ protected SqlString OrderBy(IList<OuterJoinableAssociation> associations)
{
- StringBuilder buf = new StringBuilder();
+ SqlStringBuilder buf = new SqlStringBuilder();
OuterJoinableAssociation last = null;
foreach (OuterJoinableAssociation oj in associations)
@@ -612,7 +625,7 @@
if (queryableCollection.HasOrdering)
{
string orderByString = queryableCollection.GetSQLOrderByString(oj.RHSAlias);
- buf.Append(orderByString).Append(StringHelper.CommaSpace);
+ buf.Add(orderByString).Add(StringHelper.CommaSpace);
}
}
else
@@ -627,7 +640,7 @@
if (queryableCollection.HasManyToManyOrdering)
{
string orderByString = queryableCollection.GetManyToManyOrderByString(oj.RHSAlias);
- buf.Append(orderByString).Append(StringHelper.CommaSpace);
+ buf.Add(orderByString).Add(StringHelper.CommaSpace);
}
}
}
@@ -636,10 +649,11 @@
last = oj;
}
- if (buf.Length > 0)
- buf.Length = buf.Length - 2;
+ if (buf.Count > 0) {
+ buf.RemoveAt(buf.Count-1);
+ }
- return buf.ToString();
+ return buf.ToSqlString();
}
/// <summary>
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -17,7 +17,7 @@
private SqlString outerJoinsAfterFrom;
private SqlString whereClause;
private SqlString outerJoinsAfterWhere;
- private string orderByClause;
+ private SqlString orderByClause;
private string groupByClause;
private SqlString havingClause;
private LockMode lockMode;
@@ -72,7 +72,7 @@
/// </summary>
/// <param name="orderByClause">The orderByClause to set</param>
/// <returns>The SqlSelectBuilder</returns>
- public SqlSelectBuilder SetOrderByClause(string orderByClause)
+ public SqlSelectBuilder SetOrderByClause(SqlString orderByClause)
{
this.orderByClause = orderByClause;
return this;
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -1675,5 +1675,22 @@
t.Rollback();
s.Close();
}
+
+ [Test]
+ public void OrderProjectionTest() {
+ using (ISession session = this.OpenSession()) {
+ ICriteria criteria = session.CreateCriteria(typeof (Student), "c");
+
+ criteria
+ .AddOrder(Order.Asc(
+ Projections.Conditional(
+ Restrictions.Eq("StudentNumber", (long)1),
+ Projections.Constant(0),
+ Projections.Constant(1)
+ )));
+
+ criteria.List();
+ }
+ }
}
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Fixture.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -0,0 +1,63 @@
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Criterion;
+using NHibernate.Dialect.Function;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1502
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnTearDown()
+ {
+ base.OnTearDown();
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Person");
+ tx.Commit();
+ }
+ }
+ }
+
+ protected override void OnSetUp()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Person e1 = new Person("Joe", 10, 9);
+ Person e2 = new Person("Sally", 100, 8);
+ Person e3 = new Person("Tim", 20, 7); //20
+ Person e4 = new Person("Fred", 40, 40);
+ Person e5 = new Person("Mike", 50, 50);
+ s.Save(e1);
+ s.Save(e2);
+ s.Save(e3);
+ s.Save(e4);
+ s.Save(e5);
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void OrderProjectionTest()
+ {
+ ISQLFunction arithmaticMultiplication = new VarArgsSQLFunction("(", "*", ")");
+ using (ISession session = this.OpenSession()) {
+ ICriteria criteria = session.CreateCriteria(typeof (Person), "c");
+
+ criteria.AddOrder(Order.Asc(
+ Projections.SqlFunction(arithmaticMultiplication, NHibernateUtil.GuessType(typeof (int)),
+ Projections.Property("IQ"), Projections.Constant(-1))));
+ IList<Person> results=criteria.List<Person>();
+ Assert.AreEqual(5, results.Count);
+ Assert.AreEqual("Sally", results[0].Name);
+ Assert.AreEqual("Joe", results[4].Name);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Mappings.hbm.xml 2008-09-26 23:25:05 UTC (rev 3784)
@@ -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.NH1502">
+
+ <class name="Person" lazy="false">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ <property name="IQ"/>
+ <property name="ShoeSize"/>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1502/Person.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -0,0 +1,51 @@
+using System.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH1502
+{
+ public class Person
+ {
+ private int id;
+ private int iq;
+ private string name;
+ private IList pets;
+ private int shoeSize;
+
+ public Person()
+ {
+ pets = new ArrayList();
+ }
+
+ public Person(string name, int iq, int shoeSize)
+ {
+ this.name = name;
+ this.iq = iq;
+ this.shoeSize = shoeSize;
+ pets = new ArrayList();
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual int IQ
+ {
+ get { return iq; }
+ set { iq = value; }
+ }
+
+ public virtual int ShoeSize
+ {
+ get { return shoeSize; }
+ set { shoeSize = value; }
+ }
+
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-3.5.csproj 2008-09-26 23:25:05 UTC (rev 3784)
@@ -494,6 +494,8 @@
<Compile Include="NHSpecificTest\NH1499\Document.cs" />
<Compile Include="NHSpecificTest\NH1499\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1499\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1502\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1502\Person.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1470,6 +1472,9 @@
<EmbeddedResource Include="NHSpecificTest\NH1499\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH1502\Mappings.hbm.xml" />
+ </ItemGroup>
+ <ItemGroup>
<Folder Include="Properties\" />
<Folder Include="Unionsubclass2\" />
</ItemGroup>
Modified: trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlSelectBuilderFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlSelectBuilderFixture.cs 2008-09-26 20:18:17 UTC (rev 3783)
+++ trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlSelectBuilderFixture.cs 2008-09-26 23:25:05 UTC (rev 3784)
@@ -27,7 +27,7 @@
select.SetOuterJoins(
new SqlString(" LEFT OUTER JOIN before ON select_test_alias.column1 = before.column1"),
new SqlString(" after.some_field = after.another_field "));
- select.SetOrderByClause("column1 DESC");
+ select.SetOrderByClause(new SqlString("column1 DESC"));
select.SetWhereClause("select_test_alias", new string[] {"identity_column"}, NHibernateUtil.Int64);
@@ -49,4 +49,4 @@
Assert.AreEqual(1, sqlString.GetParameterCount(), "One parameter");
}
}
-}
\ 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...> - 2008-09-29 12:20:32
|
Revision: 3796
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3796&view=rev
Author: fabiomaulo
Date: 2008-09-29 12:20:13 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Merge r3795 (revert NH-1179; fix NH-1293, NH-1488, NH-1490, NH-1488)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-09-28 22:40:10 UTC (rev 3795)
+++ trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -185,11 +185,11 @@
condition = on;
}
//Start NH1179 ************
- if (string.IsNullOrEmpty(condition))
- {
- string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters);
- joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition);
- }
+ //if (string.IsNullOrEmpty(condition))
+ //{
+ // string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters);
+ // joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition);
+ //}
//End NH1179 ************
if (withClauseFragment != null)
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -11,9 +11,11 @@
get { return "NH1179"; }
}
- [Test]
+ [Test, Ignore("Not supported.")]
public void ApplyFilterExplicitJoin()
{
+ // Note: if we fix this we must fix it for Criteria too (NH-1293)
+
RelatedClass rc1 = new RelatedClass(1);
RelatedClass rc2 = new RelatedClass(2);
RelatedClass rc11 = new RelatedClass(1);
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1293
+{
+ public class Customer
+ {
+ private int id;
+ private string name;
+ private Category category;
+ private bool isActive;
+ public Customer() {}
+ public Customer(string name)
+ {
+ this.name = name;
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual Category Category
+ {
+ get { return category; }
+ set { category = value; }
+ }
+
+ public virtual bool IsActive
+ {
+ get { return isActive; }
+ set { isActive = value; }
+ }
+ }
+
+ public class Category
+ {
+ private int id;
+ private string name;
+ private bool isActive;
+ public Category() {}
+ public Category(string name)
+ {
+ this.name = name;
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual bool IsActive
+ {
+ get { return isActive; }
+ set { isActive = value; }
+ }
+ }
+}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1293
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void Criteria_Does_Not_Equal_To_HQL()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Customer c = new Customer("Somebody");
+ c.Category = new Category("User");
+ s.Save(c.Category);
+ c.IsActive = true;
+ c.Category.IsActive = false; // this cause diff in query results
+ s.Save(c);
+ tx.Commit();
+ }
+ }
+
+ using (ISession s = OpenSession())
+ {
+ s.DisableFilter("onlyActive");
+ IFilter fltr = s.EnableFilter("onlyActive");
+ fltr.SetParameter("activeFlag", 1);
+
+ // with HQL, Category.IsActive=true filter applied, result count=2
+ IQuery hqlQuery = s.CreateQuery("from Customer c where c.Category.Name = ?");
+ hqlQuery.SetParameter(0, "User"); // note using positional parameters because of NH-1490
+ IList<Customer> hqlResult = hqlQuery.List<Customer>();
+ Console.WriteLine(hqlResult.Count);
+
+ // with ICriteria, no Category.IsActive filter applied, result count=1
+ ICriteria criteria = s.CreateCriteria(typeof (Customer), "cust").CreateCriteria("Category", "cat");
+ criteria.Add(Restrictions.Eq("cat.Name", "User"));
+ IList<Customer> criteriaResult = criteria.List<Customer>();
+
+ Console.WriteLine(criteriaResult.Count);
+
+ Assert.That(hqlResult.Count == criteriaResult.Count);
+ }
+
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from Customer");
+ s.Delete("from Category");
+ tx.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1293">
+ <class name="Customer" table="Customer">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+ <many-to-one name="Category" lazy="false" column="Category_Id" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <class name="Category" table="Category" mutable="true">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <filter-def name="onlyActive">
+ <filter-param name="activeFlag" type="int"/>
+ </filter-def>
+
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -37,8 +37,8 @@
}
}
- [Test, Ignore("Not supported.")]
- public void PerhapsBug()
+ [Test]
+ public void Bug()
{
using (ISession s = OpenSession())
using (ITransaction tx = s.BeginTransaction())
@@ -66,4 +66,4 @@
}
}
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml 2008-09-28 22:40:10 UTC (rev 3795)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796)
@@ -3,7 +3,7 @@
assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.NH1488">
- <class name="Category" table="Category" abstract="true">
+ <class name="Category" table="Category" mutable="true" abstract="true">
<id name="Id" column="Id">
<generator class="native" />
</id>
@@ -17,9 +17,9 @@
<generator class="native" />
</id>
<property name="Name" not-null="true" />
- <many-to-one name="Category" lazy="false" column="Category_Id"/>
+ <many-to-one name="Category" lazy="false" class="CustomerCategory" column="Category_Id" />
</class>
-
+
<class name="CustomerNoSmart" table="CustomerNoSmart">
<id name="Id" column="Id">
<generator class="native" />
@@ -27,4 +27,4 @@
<property name="Name" not-null="true" />
<many-to-one name="Category" lazy="false" column="Category_Id"/>
</class>
-</hibernate-mapping>
+</hibernate-mapping>
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,69 @@
+namespace NHibernate.Test.NHSpecificTest.NH1490
+{
+ public class Customer
+ {
+ private int id;
+ private string name;
+ private Category category;
+ private bool isActive;
+ public Customer() {}
+ public Customer(string name)
+ {
+ this.name = name;
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual Category Category
+ {
+ get { return category; }
+ set { category = value; }
+ }
+
+ public virtual bool IsActive
+ {
+ get { return isActive; }
+ set { isActive = value; }
+ }
+ }
+
+ public class Category
+ {
+ private int id;
+ private string name;
+ private bool isActive;
+ public Category() {}
+ public Category(string name)
+ {
+ this.name = name;
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual bool IsActive
+ {
+ get { return isActive; }
+ set { isActive = value; }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,119 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1490
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void Can_Translate_Correctly_Without_Filter()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Customer c = new Customer("Somebody");
+ c.Category = new Category("User");
+ c.IsActive = true;
+ c.Category.IsActive = true;
+ s.Save(c.Category);
+ s.Save(c);
+ tx.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName");
+ query.SetParameter("catName", "User");
+ IList<Customer> customers = query.List<Customer>();
+
+ Assert.That(customers.Count, Is.EqualTo(1), "Can apply condition on Customer without IFilter");
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from Customer");
+ s.Delete("from Category");
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void Also_Works_With_Filter()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Customer c = new Customer("Somebody");
+ c.Category = new Category("User");
+ s.Save(c.Category);
+ c.IsActive = true;
+ c.Category.IsActive = true;
+ s.Save(c);
+ tx.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ s.DisableFilter("onlyActive");
+ IFilter fltr = s.EnableFilter("onlyActive");
+ fltr.SetParameter("activeFlag", 1);
+
+ // Customer is parametrized
+ IQuery query = s.CreateQuery("from Customer c where c.Name = :customerName");
+ query.SetParameter("customerName", "Somebody");
+ IList<Customer> customers = query.List<Customer>();
+
+ Assert.That(customers.Count, Is.EqualTo(1), "IFilter applied and Customer parametrized on Name also works");
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from Customer");
+ s.Delete("from Category");
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void Incorrect_SQL_Translated_Params_Bug()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Customer c = new Customer("Somebody");
+ c.Category = new Category("User");
+ s.Save(c.Category);
+ c.IsActive = true;
+ c.Category.IsActive = true;
+ s.Save(c);
+ tx.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ s.DisableFilter("onlyActive");
+ IFilter fltr = s.EnableFilter("onlyActive");
+ fltr.SetParameter("activeFlag", 1);
+ // related entity Customer.Category is parametrized
+ IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName");
+ query.SetParameter("catName", "User");
+
+ IList<Customer> customers = query.List<Customer>();
+
+ Assert.That(customers.Count, Is.EqualTo(1), "IFIlter applied and Customer parametrized on Category.Name DOES NOT work");
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from Customer");
+ s.Delete("from Category");
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1490">
+
+ <class name="Customer" table="Customer">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+ <many-to-one name="Category" lazy="false" column="Category_Id" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <class name="Category" table="Category" mutable="true">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <filter-def name="onlyActive">
+ <filter-param name="activeFlag" type="int"/>
+ </filter-def>
+</hibernate-mapping>
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,38 @@
+namespace NHibernate.Test.NHSpecificTest.NH1492
+{
+ public class ChildEntity
+ {
+ private string _description;
+ private int _id;
+ private Entity _parent;
+ public ChildEntity() {}
+
+ public ChildEntity(Entity parent, string description)
+ {
+ _description = description;
+ if (parent != null)
+ {
+ _parent = parent;
+ _parent.Childs.Add(this);
+ }
+ }
+
+ public virtual int Id
+ {
+ get { return _id; }
+ set { _id = value; }
+ }
+
+ public virtual string Description
+ {
+ get { return _description; }
+ set { _description = value; }
+ }
+
+ public virtual Entity Parent
+ {
+ get { return _parent; }
+ set { _parent = value; }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1492
+{
+ public class Entity
+ {
+ private IList<ChildEntity> _childs = new List<ChildEntity>();
+ private int _code;
+ private string _deleted;
+ private string _description;
+ private int _id;
+ public Entity() {}
+
+ public Entity(int code, string description)
+ {
+ _code = code;
+ _description = description;
+ }
+
+ public virtual int Id
+ {
+ get { return _id; }
+ set { _id = value; }
+ }
+
+ public virtual int Code
+ {
+ get { return _code; }
+ set { _code = value; }
+ }
+
+ public virtual string Description
+ {
+ get { return _description; }
+ set { _description = value; }
+ }
+
+ public virtual string Deleted
+ {
+ get { return _deleted; }
+ set { _deleted = value; }
+ }
+
+ public virtual IList<ChildEntity> Childs
+ {
+ get { return _childs; }
+ set { _childs = value; }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,46 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1492
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void RetrieveEntities()
+ {
+ Entity eDel = new Entity(1, "DeletedEntity");
+ eDel.Deleted = "Y";
+
+ Entity eGood = new Entity(2, "GoodEntity");
+ eGood.Childs.Add(new ChildEntity(eGood, "GoodEntityChild"));
+
+ // Make "Deleted" entity persistent
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(eDel);
+ s.Save(eGood);
+ t.Commit();
+ }
+
+ // Retrive (check if the entity was well persisted)
+ IList<ChildEntity> childs;
+ using (ISession s = OpenSession())
+ {
+ s.EnableFilter("excludeDeletedRows").SetParameter("deleted", "Y");
+
+ IQuery q = s.CreateQuery("FROM ChildEntity c WHERE c.Parent.Code = :parentCode").SetParameter("parentCode", 2);
+ childs= q.List<ChildEntity>();
+ }
+ Assert.AreEqual(1, childs.Count);
+
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Delete("from Entity");
+ t.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1492"
+ default-access="field.camelcase-underscore">
+
+ <class name="Entity" table="EntityTable">
+ <id name="Id" column="EntityID">
+ <generator class="native" />
+ </id>
+
+ <property name="Code" column="Code" />
+ <property name="Description" column="Description" />
+ <property name="Deleted" column="Deleted" />
+
+ <bag name="Childs" lazy="true" table="ChildsTable" generic="true" inverse="true" cascade="all-delete-orphan">
+ <key column="ParentID" />
+ <one-to-many class="ChildEntity" />
+ </bag>
+
+ <filter name="excludeDeletedRows" condition="(Deleted IS NULL OR Deleted != :deleted)"/>
+ </class>
+
+ <class name="ChildEntity" table="ChildEntityTable">
+ <id name="Id" column="ChildEntityID">
+ <generator class="native" />
+ </id>
+
+ <property name="Description" column="Description" />
+
+ <many-to-one name="Parent" column="ParentID" class="Entity" />
+
+ </class>
+
+ <filter-def name="excludeDeletedRows">
+ <filter-param name="deleted" type="String"/>
+ </filter-def>
+
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-28 22:40:10 UTC (rev 3795)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 12:20:13 UTC (rev 3796)
@@ -430,6 +430,8 @@
<Compile Include="NHSpecificTest\NH1291AnonExample\Home.cs" />
<Compile Include="NHSpecificTest\NH1291AnonExample\NH1291AnonExampleFixture.cs" />
<Compile Include="NHSpecificTest\NH1291AnonExample\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1293\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1293\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1297\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1297\Model.cs" />
<Compile Include="NHSpecificTest\NH1301\Domain.cs">
@@ -480,6 +482,11 @@
<Compile Include="NHSpecificTest\NH1483\SubClass.cs" />
<Compile Include="NHSpecificTest\NH1488\Domain.cs" />
<Compile Include="NHSpecificTest\NH1488\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1490\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1490\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1492\ChildEntity.cs" />
+ <Compile Include="NHSpecificTest\NH1492\Entity.cs" />
+ <Compile Include="NHSpecificTest\NH1492\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1499\Document.cs" />
<Compile Include="NHSpecificTest\NH1499\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1499\Person.cs" />
@@ -1472,6 +1479,9 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1492\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1499\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1502\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1488\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-29 22:46:41
|
Revision: 3807
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3807&view=rev
Author: fabiomaulo
Date: 2008-09-29 22:46:17 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Fix NH-1173 new feature Generic Ordered Set support (by Sean Carpenter)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/Set.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs
trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/
trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs
trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs
trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Mapping/Set.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Set.cs 2008-09-29 22:14:24 UTC (rev 3806)
+++ trunk/nhibernate/src/NHibernate/Mapping/Set.cs 2008-09-29 22:46:17 UTC (rev 3807)
@@ -34,8 +34,7 @@
}
else if (HasOrder)
{
- throw new MappingException(
- "Cannot use order-by with generic set, no appropriate collection implementation is available");
+ return TypeFactory.GenericOrderedSet(Role, ReferencedPropertyName, this.GenericArguments[0]);
}
else
{
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 22:14:24 UTC (rev 3806)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 22:46:17 UTC (rev 3807)
@@ -1062,6 +1062,7 @@
<Compile Include="Type\CollectionType.cs" />
<Compile Include="Type\CustomCollectionType.cs" />
<Compile Include="Type\EmbeddedComponentType.cs" />
+ <Compile Include="Type\GenericOrderedSetType.cs" />
<Compile Include="Type\ICacheAssembler.cs" />
<Compile Include="Type\OrderedSetType.cs" />
<Compile Include="Type\OrderedMapType.cs" />
Added: trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs 2008-09-29 22:46:17 UTC (rev 3807)
@@ -0,0 +1,31 @@
+using System;
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// An <see cref="IType"/> that maps a sorted <see cref="ISet{T}"/> collection
+ /// to the database.
+ /// </summary>
+ [Serializable]
+ public class GenericOrderedSetType<T> : GenericSetType<T>
+ {
+ /// <summary>
+ /// Initializes a new instance of a <see cref="GenericOrderedSetType{T}"/> class for
+ /// a specific role.
+ /// </summary>
+ /// <param name="role">The role the persistent collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ public GenericOrderedSetType(string role, string propertyRef)
+ : base(role, propertyRef)
+ {
+ }
+
+ public override object Instantiate(int anticipatedSize)
+ {
+ return new OrderedSet<T>();
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2008-09-29 22:14:24 UTC (rev 3806)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2008-09-29 22:46:17 UTC (rev 3807)
@@ -33,8 +33,8 @@
PrecisionScale
}
- private static readonly char[] precisionScaleSplit = new char[] {'(', ')', ','};
- private static readonly char[] lengthSplit = new char[] {'(', ')'};
+ private static readonly char[] precisionScaleSplit = new char[] { '(', ')', ',' };
+ private static readonly char[] lengthSplit = new char[] { '(', ')' };
/*
* Maps the string representation of the type to the IType. The string
@@ -59,7 +59,7 @@
private static readonly IDictionary<string, IType> typeByTypeOfName =
new ThreadSafeDictionary<string, IType>(new Dictionary<string, IType>());
- private static readonly IDictionary<string, GetNullableTypeWithLength> getTypeDelegatesWithLength =
+ private static readonly IDictionary<string, GetNullableTypeWithLength> getTypeDelegatesWithLength =
new ThreadSafeDictionary<string, GetNullableTypeWithLength>(new Dictionary<string, GetNullableTypeWithLength>());
private static readonly IDictionary<string, GetNullableTypeWithPrecision> getTypeDelegatesWithPrecision =
@@ -241,7 +241,7 @@
// Use the basic name (such as String or String(255)) to get the
// instance of the IType object.
IType returnType;
- if (typeByTypeOfName.TryGetValue(name,out returnType))
+ if (typeByTypeOfName.TryGetValue(name, out returnType))
{
return returnType;
}
@@ -259,7 +259,7 @@
if (parsedName.Length < 4)
{
throw new ArgumentOutOfRangeException("TypeClassification.PrecisionScale", name,
- "It is not a valid Precision/Scale name");
+ "It is not a valid Precision/Scale name");
}
typeName = parsedName[0].Trim();
@@ -372,8 +372,8 @@
{
parsedTypeName = typeName.Split(lengthSplit);
}
- else
- parsedTypeName = typeClassification == TypeClassification.PrecisionScale ? typeName.Split(precisionScaleSplit) : new string[] {typeName};
+ else
+ parsedTypeName = typeClassification == TypeClassification.PrecisionScale ? typeName.Split(precisionScaleSplit) : new string[] { typeName };
System.Type typeClass;
@@ -392,7 +392,7 @@
{
try
{
- type = (IType) Activator.CreateInstance(typeClass);
+ type = (IType)Activator.CreateInstance(typeClass);
}
catch (Exception e)
{
@@ -439,11 +439,11 @@
private static Boolean IsNullableEnum(System.Type typeClass)
{
if (!typeClass.IsGenericType) return false;
- System.Type nullable = typeof (Nullable<>);
+ System.Type nullable = typeof(Nullable<>);
if (!nullable.Equals(typeClass.GetGenericTypeDefinition())) return false;
System.Type genericClass = typeClass.GetGenericArguments()[0];
- return genericClass.IsSubclassOf(typeof (Enum));
+ return genericClass.IsSubclassOf(typeof(Enum));
}
@@ -604,12 +604,12 @@
/// <summary>
/// A one-to-one association type for the given class and cascade style.
/// </summary>
- public static EntityType OneToOne(string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName,
+ public static EntityType OneToOne(string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName,
bool lazy, bool unwrapProxy, bool isEmbeddedInXML, string entityName, string propertyName)
{
return
new OneToOneType(persistentClass, foreignKeyType, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML,
- entityName, propertyName);
+ entityName, propertyName);
}
/// <summary>
@@ -633,7 +633,7 @@
/// <summary>
/// A many-to-one association type for the given class and cascade style.
/// </summary>
- public static EntityType ManyToOne(string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy,
+ public static EntityType ManyToOne(string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy,
bool isEmbeddedInXML, bool ignoreNotFound)
{
return new ManyToOneType(persistentClass, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML, ignoreNotFound);
@@ -796,15 +796,17 @@
return new OrderedSetType(role, propertyRef, embedded);
}
+
+
private static CollectionType CreateCollectionType(
System.Type genericCollectionType,
string role,
string propertyRef,
params System.Type[] typeArguments)
{
- return (CollectionType) Activator.CreateInstance(
- genericCollectionType.MakeGenericType(typeArguments),
- role, propertyRef);
+ return (CollectionType)Activator.CreateInstance(
+ genericCollectionType.MakeGenericType(typeArguments),
+ role, propertyRef);
}
private static CollectionType CreateSortedCollectionType(
@@ -814,11 +816,20 @@
object comparer,
params System.Type[] typeArguments)
{
- return (CollectionType) Activator.CreateInstance(
- genericCollectionType.MakeGenericType(typeArguments),
- role, propertyRef, comparer);
+ return (CollectionType)Activator.CreateInstance(
+ genericCollectionType.MakeGenericType(typeArguments),
+ role, propertyRef, comparer);
}
+ private static CollectionType CreateOrderedCollectionType(System.Type genericCollectionType,
+ string role,
+ string propertyRef,
+ params System.Type[] typeArguments)
+ {
+ return
+ (CollectionType)Activator.CreateInstance(genericCollectionType.MakeGenericType(typeArguments), role, propertyRef);
+ }
+
/// <summary>
/// Creates a new <see cref="CollectionType"/> for an
/// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics.
@@ -901,24 +912,24 @@
/// A <see cref="MapType"/> for the specified role.
/// </returns>
public static CollectionType GenericMap(string role, string propertyRef, System.Type indexClass,
- System.Type elementClass)
+ System.Type elementClass)
{
return CreateCollectionType(typeof(GenericMapType<,>), role, propertyRef, indexClass, elementClass);
}
public static CollectionType GenericSortedList(string role, string propertyRef, object comparer,
- System.Type indexClass, System.Type elementClass)
+ System.Type indexClass, System.Type elementClass)
{
return
CreateSortedCollectionType(typeof(GenericSortedListType<,>), role, propertyRef, comparer, indexClass, elementClass);
}
public static CollectionType GenericSortedDictionary(string role, string propertyRef, object comparer,
- System.Type indexClass, System.Type elementClass)
+ System.Type indexClass, System.Type elementClass)
{
return
CreateSortedCollectionType(typeof(GenericSortedDictionaryType<,>), role, propertyRef, comparer, indexClass,
- elementClass);
+ elementClass);
}
/// <summary>
@@ -946,11 +957,26 @@
/// <param name="elementType">The type of the elements in the set.</param>
/// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
public static CollectionType GenericSortedSet(string role, string propertyRef, object comparer,
- System.Type elementType)
+ System.Type elementType)
{
return CreateSortedCollectionType(typeof(GenericSortedSetType<>), role, propertyRef, comparer, elementType);
}
+ /// <summary>
+ /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />.
+ /// </summary>
+ /// <param name="role">The role the collection is in.</param>
+ /// <param name="propertyRef">The name of the property in the
+ /// owner object containing the collection ID, or <see langword="null" /> if it is
+ /// the primary key.</param>
+ /// <param name="elementType">The type of the elements in the set.</param>
+ /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns>
+ public static CollectionType GenericOrderedSet(string role, string propertyRef,
+ System.Type elementType)
+ {
+ return CreateOrderedCollectionType(typeof(GenericOrderedSetType<>), role, propertyRef, elementType);
+ }
+
/// <summary> Deep copy a series of values from one array to another... </summary>
/// <param name="values">The values to copy (the source) </param>
/// <param name="types">The value types </param>
@@ -1137,7 +1163,7 @@
/// <param name="copiedAlready">Represent a cache of already replaced state </param>
/// <returns> The replaced state </returns>
public static object[] Replace(object[] original, object[] target, IType[] types, ISessionImplementor session,
- object owner, IDictionary copiedAlready)
+ object owner, IDictionary copiedAlready)
{
object[] copied = new object[original.Length];
for (int i = 0; i < original.Length; i++)
@@ -1159,7 +1185,7 @@
/// <param name="copyCache">A map representing a cache of already replaced state </param>
/// <param name="foreignKeyDirection">FK directionality to be applied to the replacement </param>
/// <returns> The replaced state </returns>
- public static object[] Replace(object[] original, object[] target, IType[] types,
+ public static object[] Replace(object[] original, object[] target, IType[] types,
ISessionImplementor session, object owner, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection)
{
object[] copied = new object[original.Length];
@@ -1192,7 +1218,7 @@
/// If the corresponding type is a component type, then apply <see cref="ReplaceAssociations"/>
/// across the component subtypes but do not replace the component value itself.
/// </remarks>
- public static object[] ReplaceAssociations(object[] original, object[] target, IType[] types,
+ public static object[] ReplaceAssociations(object[] original, object[] target, IType[] types,
ISessionImplementor session, object owner, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection)
{
object[] copied = new object[original.Length];
@@ -1205,14 +1231,14 @@
else if (types[i].IsComponentType)
{
// need to extract the component values and check for subtype replacements...
- IAbstractComponentType componentType = (IAbstractComponentType) types[i];
+ IAbstractComponentType componentType = (IAbstractComponentType)types[i];
IType[] subtypes = componentType.Subtypes;
object[] origComponentValues = original[i] == null
- ? new object[subtypes.Length]
- : componentType.GetPropertyValues(original[i], session);
+ ? new object[subtypes.Length]
+ : componentType.GetPropertyValues(original[i], session);
object[] targetComponentValues = componentType.GetPropertyValues(target[i], session);
ReplaceAssociations(origComponentValues, targetComponentValues, subtypes, session, null, copyCache,
- foreignKeyDirection);
+ foreignKeyDirection);
copied[i] = target[i];
}
else if (!types[i].IsAssociationType)
@@ -1242,7 +1268,7 @@
CustomCollectionType result = new CustomCollectionType(typeClass, role, propertyRef, embedded);
if (typeParameters != null)
{
- InjectParameters(result.UserType, (IDictionary) typeParameters);
+ InjectParameters(result.UserType, (IDictionary)typeParameters);
}
return result;
}
@@ -1251,7 +1277,7 @@
{
if (type is IParameterizedType)
{
- ((IParameterizedType) type).SetParameterValues(parameters);
+ ((IParameterizedType)type).SetParameterValues(parameters);
}
else if (parameters != null && !(parameters.Count == 0))
{
Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs 2008-09-29 22:46:17 UTC (rev 3807)
@@ -0,0 +1,19 @@
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.GenericTest.OrderedSetGeneric
+{
+ public class A
+ {
+ private ISet<B> _items = new OrderedSet<B>();
+
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+
+ public virtual ISet<B> Items
+ {
+ get { return _items; }
+ set { _items = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs 2008-09-29 22:46:17 UTC (rev 3807)
@@ -0,0 +1,13 @@
+namespace NHibernate.Test.GenericTest.OrderedSetGeneric
+{
+ public class B
+ {
+ public virtual int Id { get; set; }
+
+ public virtual int OrderBy { get; set; }
+
+ public virtual string Name { get; set; }
+
+ public virtual int AId { get; set; }
+ }
+}
Property changes on: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs 2008-09-29 22:46:17 UTC (rev 3807)
@@ -0,0 +1,64 @@
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.GenericTest.OrderedSetGeneric
+{
+ [TestFixture]
+ public class OrderedSetFixture : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"GenericTest.OrderedSetGeneric.OrderedSetFixture.hbm.xml"}; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from B");
+ s.Delete("from A");
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void OrderedSetIsInOrder()
+ {
+ var names = new[] {"First B", "Second B"};
+ const int TheId = 100;
+
+ var a = new A {Name = "First", Id = TheId};
+
+ var b = new B {Name = names[1], OrderBy = 3, AId = TheId};
+ a.Items.Add(b);
+
+ var b2 = new B {Name = names[0], OrderBy = 1, AId = TheId};
+ a.Items.Add(b2);
+
+ ISession s = OpenSession();
+ s.Save(a);
+ s.Flush();
+ s.Close();
+
+ s = OpenSession();
+ var newA = s.Get<A>(a.Id);
+
+ Assert.AreEqual(2, newA.Items.Count);
+ int counter = 0;
+ foreach (B item in newA.Items)
+ {
+ Assert.AreEqual(names[counter], item.Name);
+ counter++;
+ }
+ s.Close();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml 2008-09-29 22:46:17 UTC (rev 3807)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.GenericTest.OrderedSetGeneric">
+
+ <class name="A" table="a" lazy="false">
+ <id name="Id" column="id">
+ <generator class="assigned" />
+ </id>
+ <property name="Name" column="aname" />
+ <set name="Items" cascade="save-update" order-by="OrderBy ASC">
+ <key column="aid"/>
+ <one-to-many class="B"/>
+ </set>
+ </class>
+
+ <class name="B" table="b">
+ <id name="Id" column="id">
+ <generator class="native" />
+ </id>
+ <property name="AId" column="aid" />
+ <property name="OrderBy" column="orderby" />
+ <property name="Name" column="aname" />
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 22:14:24 UTC (rev 3806)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 22:46:17 UTC (rev 3807)
@@ -257,6 +257,9 @@
<Compile Include="GenericTest\MapGeneric\B.cs" />
<Compile Include="GenericTest\MapGeneric\MapGenericFixture.cs" />
<Compile Include="GenericTest\Methods\Fixture.cs" />
+ <Compile Include="GenericTest\OrderedSetGeneric\A.cs" />
+ <Compile Include="GenericTest\OrderedSetGeneric\B.cs" />
+ <Compile Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.cs" />
<Compile Include="GenericTest\Overall\A.cs" />
<Compile Include="GenericTest\Overall\Fixture.cs" />
<Compile Include="GenericTest\SetGeneric\A.cs" />
@@ -1478,6 +1481,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1492\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-10-03 14:57:20
|
Revision: 3809
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3809&view=rev
Author: tehlike
Date: 2008-10-03 14:57:14 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
Spelling correction (Fix 1511)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/Property.cs
trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs
trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -189,8 +189,8 @@
public virtual bool IsBasicPropertyAccessor
{
- // NH Different behavior : see IPropertyAccessor.CanAccessTroughReflectionOptimizer (ref. NH-1304)
- get { return PropertyAccessor.CanAccessTroughReflectionOptimizer; }
+ // NH Different behavior : see IPropertyAccessor.CanAccessThroughReflectionOptimizer (ref. NH-1304)
+ get { return PropertyAccessor.CanAccessThroughReflectionOptimizer; }
}
public IDictionary<string, MetaAttribute> MetaAttributes
Modified: trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -30,7 +30,7 @@
return new BackrefSetter();
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -60,7 +60,7 @@
return result;
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return true; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -48,7 +48,7 @@
throw new PropertyNotFoundException(theClass, propertyName, "setter");
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -19,7 +19,7 @@
return new EmbeddedSetter(theClass);
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -86,7 +86,7 @@
return new FieldSetter(GetField(theClass, fieldName), theClass, fieldName);
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return true; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -39,7 +39,7 @@
/// <summary>
/// Allow embedded and custom accessors to define if the ReflectionOptimizer can be used.
/// </summary>
- bool CanAccessTroughReflectionOptimizer { get;}
+ bool CanAccessThroughReflectionOptimizer { get;}
#endregion
}
}
Modified: trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -32,7 +32,7 @@
throw new NotImplementedException();
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -18,7 +18,7 @@
return new MapSetter(propertyName);
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -66,7 +66,7 @@
return new FieldAccessor.FieldSetter(FieldAccessor.GetField(type, fieldName), type, fieldName);
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return true; }
}
Modified: trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -19,7 +19,7 @@
return new NoopSetter();
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs 2008-10-03 14:50:43 UTC (rev 3808)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs 2008-10-03 14:57:14 UTC (rev 3809)
@@ -53,7 +53,7 @@
return new CustomSetter(propertyName);
}
- public bool CanAccessTroughReflectionOptimizer
+ public bool CanAccessThroughReflectionOptimizer
{
get { return false; }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-10-03 21:13:55
|
Revision: 3811
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3811&view=rev
Author: tehlike
Date: 2008-10-03 21:13:49 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
Added throw NotSupportedException statement when ISQLQuery is added. This fix doesn't solve the issue NH-1508, just temporarily let the user know about situation.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-10-03 21:11:48 UTC (rev 3810)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-10-03 21:13:49 UTC (rev 3811)
@@ -797,12 +797,17 @@
private int AddQueryForLaterExecutionAndReturnIndexOfQuery(IQuery query)
{
+ ThrowNotSupportedIfSqlQuery(query);
((AbstractQueryImpl)query).SetIgnoreUknownNamedParameters(true);
queries.Add(query);
return queries.Count - 1;
}
+ protected void ThrowNotSupportedIfSqlQuery(IQuery query)
+ {
+ if (query is ISQLQuery)
+ throw new NotSupportedException("Sql queries in MultiQuery are currently not supported.");
+ }
-
#endregion
}
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs 2008-10-03 21:13:49 UTC (rev 3811)
@@ -0,0 +1,27 @@
+namespace NHibernate.Test.NHSpecificTest.NH1508
+{
+ public class Document
+ {
+ private int id;
+ private Person person;
+ private string title;
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Title
+ {
+ get { return title; }
+ set { title = value; }
+ }
+
+ public virtual Person Person
+ {
+ get { return person; }
+ set { person = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs 2008-10-03 21:13:49 UTC (rev 3811)
@@ -0,0 +1,92 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+using NHibernate.Criterion;
+
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1508
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ Person john = new Person();
+ john.Name = "John";
+
+ Document doc1 = new Document();
+ doc1.Person = john;
+ doc1.Title = "John's Doc";
+
+ Document doc2 = new Document();
+ doc2.Title = "Spec";
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Save(john);
+ session.Save(doc1);
+ session.Save(doc2);
+
+ tx.Commit();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Person");
+ session.Delete("from Document");
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void DoesntThrowExceptionWhenHqlQueryIsGiven()
+ {
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ IQuery sqlQuery = session.CreateQuery("from Document");
+ IMultiQuery q = session
+ .CreateMultiQuery()
+ .Add(sqlQuery);
+ q.List();
+ }
+ }
+
+ [Test]
+ [ExpectedException(typeof(NotSupportedException))]
+ public void ThrowsExceptionWhenSqlQueryIsGiven()
+ {
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ ISQLQuery sqlQuery = session.CreateSQLQuery("select * from Document");
+ IMultiQuery q = session
+ .CreateMultiQuery()
+ .Add(sqlQuery);
+ q.List();
+ }
+ }
+
+ [Test]
+ [ExpectedException(typeof(NotSupportedException))]
+ public void ThrowsExceptionWhenNamedSqlQueryIsGiven()
+ {
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+
+ IMultiQuery q = session
+ .CreateMultiQuery()
+ .AddNamedQuery("SampleSqlQuery");
+ q.List();
+ }
+ }
+
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml 2008-10-03 21:13:49 UTC (rev 3811)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1508">
+
+ <class name="Document">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <many-to-one name="Person" column="PersonID"/>
+ <property name="Title"/>
+ </class>
+
+ <class name="Person">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ </class>
+ <sql-query name="SampleSqlQuery">
+ <![CDATA[
+ SELECT PersonId from Document
+ ]]>
+ </sql-query>
+ <query name="SampleHqlQuery">
+ <![CDATA[
+ from Document
+ ]]>
+ </query>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs 2008-10-03 21:13:49 UTC (rev 3811)
@@ -0,0 +1,20 @@
+namespace NHibernate.Test.NHSpecificTest.NH1508
+{
+ public class Person
+ {
+ private int id;
+ private string name;
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-03 21:11:48 UTC (rev 3810)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-03 21:13:49 UTC (rev 3811)
@@ -495,6 +495,9 @@
<Compile Include="NHSpecificTest\NH1499\Person.cs" />
<Compile Include="NHSpecificTest\NH1502\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1502\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1508\Document.cs" />
+ <Compile Include="NHSpecificTest\NH1508\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1508\Person.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1481,6 +1484,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1508\Mappings.hbm.xml" />
<EmbeddedResource Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-27 12:43:22
|
Revision: 3789
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3789&view=rev
Author: fabiomaulo
Date: 2008-09-27 12:43:16 +0000 (Sat, 27 Sep 2008)
Log Message:
-----------
Corrections on VS2005
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-09-27 11:56:36 UTC (rev 3788)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-09-27 12:43:16 UTC (rev 3789)
@@ -148,7 +148,7 @@
{
for (int i = 0; i < results.Count; i++)
{
- var critImp = criteriaQueries[i] as CriteriaImpl;
+ CriteriaImpl critImp = criteriaQueries[i] as CriteriaImpl;
if(critImp==null || critImp.ResultTransformer==null)
continue;
results[i] = critImp.ResultTransformer.TransformList((IList)results[i]);
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-27 11:56:36 UTC (rev 3788)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-27 12:43:16 UTC (rev 3789)
@@ -475,6 +475,11 @@
<Compile Include="NHSpecificTest\NH1483\SubClass.cs" />
<Compile Include="NHSpecificTest\NH1488\Domain.cs" />
<Compile Include="NHSpecificTest\NH1488\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1499\Document.cs" />
+ <Compile Include="NHSpecificTest\NH1499\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1499\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1502\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1502\Person.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1462,6 +1467,8 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <Content Include="NHSpecificTest\NH1499\Mappings.hbm.xml" />
+ <Content Include="NHSpecificTest\NH1502\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1488\Mappings.hbm.xml" />
<EmbeddedResource Include="Extendshbm\allinone.hbm.xml" />
<EmbeddedResource Include="Extendshbm\allseparateinone.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-29 19:44:12
|
Revision: 3799
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3799&view=rev
Author: fabiomaulo
Date: 2008-09-29 19:43:50 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Fix NH-1446
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2008-09-29 17:25:31 UTC (rev 3798)
+++ trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2008-09-29 19:43:50 UTC (rev 3799)
@@ -12,10 +12,6 @@
/// </summary>
public class CastFunction : ISQLFunction, IFunctionGrammar
{
- public CastFunction()
- {
- }
-
#region ISQLFunction Members
public IType ReturnType(IType columnType, IMapping mapping)
@@ -42,7 +38,7 @@
throw new QueryException("cast() requires two arguments");
}
string typeName = args[1].ToString();
- string sqlType = string.Empty;
+ string sqlType;
IType hqlType = TypeFactory.HeuristicType(typeName);
if (hqlType != null)
{
@@ -86,7 +82,7 @@
bool IFunctionGrammar.IsSeparator(string token)
{
- return "as".Equals(token);
+ return "as".Equals(token, StringComparison.InvariantCultureIgnoreCase);
}
bool IFunctionGrammar.IsKnownArgument(string token)
Modified: trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs 2008-09-29 17:25:31 UTC (rev 3798)
+++ trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs 2008-09-29 19:43:50 UTC (rev 3799)
@@ -667,6 +667,27 @@
}
[Test]
+ public void CastNH1446()
+ {
+ IgnoreIfNotSupported("cast");
+ using (ISession s = OpenSession())
+ {
+ Animal a1 = new Animal("abcdef", 1.3f);
+ s.Save(a1);
+ s.Flush();
+ }
+ using (ISession s = OpenSession())
+ {
+ // Rendered in SELECT using a property
+ string hql = "select cast(a.BodyWeight As Double) from Animal a";
+ IList l = s.CreateQuery(hql).List();
+ Assert.AreEqual(1, l.Count);
+ Assert.AreEqual(1.3f, l[0]);
+ }
+ }
+
+
+ [Test]
public void Current_TimeStamp()
{
IgnoreIfNotSupported("current_timestamp");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-09-29 20:11:18
|
Revision: 3800
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3800&view=rev
Author: fabiomaulo
Date: 2008-09-29 20:10:50 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Fix NH-1468
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs 2008-09-29 19:43:50 UTC (rev 3799)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs 2008-09-29 20:10:50 UTC (rev 3800)
@@ -1,4 +1,3 @@
-
using System;
using System.Collections;
using NHibernate.Util;
@@ -10,11 +9,11 @@
/// </summary>
public class InFragment
{
- public static readonly string Null = "null";
public static readonly string NotNull = "not null";
+ public static readonly string Null = "null";
+ private readonly ArrayList values = new ArrayList();
private string columnName;
- private ArrayList values = new ArrayList();
/// <summary>
/// Add a value to the value list. Value may be a string,
@@ -27,39 +26,27 @@
return this;
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="columnName"></param>
- /// <returns></returns>
- public InFragment SetColumn(string columnName)
+ public InFragment SetColumn(string colName)
{
- this.columnName = columnName;
+ columnName = colName;
return this;
}
- /// <summary>
- ///
- /// </summary>
- /// <param name="alias"></param>
- /// <param name="columnName"></param>
- /// <returns></returns>
- public InFragment SetColumn(string alias, string columnName)
+ public InFragment SetColumn(string alias, string colName)
{
- this.columnName = alias + StringHelper.Dot + columnName;
- return SetColumn(this.columnName);
+ columnName = alias + StringHelper.Dot + colName;
+ return SetColumn(columnName);
}
public InFragment SetFormula(string alias, string formulaTemplate)
{
- this.columnName = StringHelper.Replace(formulaTemplate, Template.Placeholder, alias);
- return SetColumn(this.columnName);
+ columnName = StringHelper.Replace(formulaTemplate, Template.Placeholder, alias);
+ return SetColumn(columnName);
}
- /// <summary></summary>
public SqlString ToFragmentString()
{
- SqlStringBuilder buf = new SqlStringBuilder(values.Count * 5);
+ var buf = new SqlStringBuilder(values.Count * 5);
buf.Add(columnName);
if (values.Count > 1)
@@ -82,7 +69,7 @@
}
else if (NotNull.Equals(value))
{
- throw new ArgumentOutOfRangeException("not null makes no sense for in expression");
+ throw new NotSupportedException(string.Format("not null makes no sense for in expression (column:{0})",columnName));
}
else
{
@@ -112,16 +99,15 @@
// SqlString "is null or [column] (" + [rest of sqlstring here] + ")"
if (allowNull)
{
- buf.Insert(0, " is null or ")
- .Insert(0, columnName)
- .Insert(0, StringHelper.OpenParen)
- .Add(StringHelper.ClosedParen);
+ buf.Insert(0, " is null or ").Insert(0, columnName).Insert(0, StringHelper.OpenParen).Add(StringHelper.ClosedParen);
}
}
else
{
- if(values.Count == 0)
- throw new ArgumentOutOfRangeException("Attempting to parse a null value into an sql string.");
+ if (values.Count == 0)
+ {
+ throw new NotSupportedException(string.Format("Attempting to parse a null value into an sql string (column:{0}).", columnName));
+ }
object value = values[0];
if (Null.Equals(value))
{
@@ -139,4 +125,4 @@
return buf.ToSqlString();
}
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 19:43:50 UTC (rev 3799)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 20:10:50 UTC (rev 3800)
@@ -783,7 +783,6 @@
<Compile Include="Assertions\HaveSerializableAttributeAsserter.cs" />
<Compile Include="SessionCacheTest.cs" />
<Compile Include="SqlLogSpy.cs" />
- <Compile Include="SqlCommandTest\InFragmentFixture.cs" />
<Compile Include="SqlCommandTest\SqlDeleteBuilderFixture.cs" />
<Compile Include="SqlCommandTest\SqlInsertBuilderFixture.cs" />
<Compile Include="SqlCommandTest\SqlSelectBuilderFixture.cs" />
Deleted: trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs 2008-09-29 19:43:50 UTC (rev 3799)
+++ trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs 2008-09-29 20:10:50 UTC (rev 3800)
@@ -1,17 +0,0 @@
-using System;
-
-namespace NHibernate.Test.SqlCommandTest
-{
- /// <summary>
- /// Summary description for InFragmentFixture.
- /// </summary>
- public class InFragmentFixture
- {
- public InFragmentFixture()
- {
- //
- // TODO: Add constructor logic here
- //
- }
- }
-}
\ 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...> - 2008-09-29 20:27:13
|
Revision: 3801
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3801&view=rev
Author: fabiomaulo
Date: 2008-09-29 20:26:50 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
Fix NH-1503 (Sybase.AdoNet2 Dialect&Drire by Nathan Blair)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs
trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs
Added: trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs 2008-09-29 20:26:50 UTC (rev 3801)
@@ -0,0 +1,99 @@
+using NHibernate.Cfg;
+
+namespace NHibernate.Dialect
+{
+ /// <summary>
+ /// An SQL dialect compatible with Sybase.
+ /// </summary>
+ /// <remarks>
+ /// <p>
+ /// This dialect probably will not work with schema-export. If anyone out there
+ /// can fill in the ctor with DbTypes to Strings that would be helpful.
+ /// </p>
+ /// The SybaseDialect 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.SybaseClientDriver" /></description>
+ /// </item>
+ /// <item>
+ /// <term>prepare_sql</term>
+ /// <description><see langword="false" /></description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ public class SybaseAdoNet12Dialect : Dialect
+ {
+ /// <summary></summary>
+ public SybaseAdoNet12Dialect()
+ {
+ DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.SybaseAdoNet12ClientDriver";
+ DefaultProperties[Environment.PrepareSql] = "true";
+ }
+
+ /// <summary></summary>
+ public override string AddColumnString
+ {
+ get { return "add"; }
+ }
+
+ /// <summary></summary>
+ public override string NullColumnString
+ {
+ get { return " null"; }
+ }
+
+ /// <summary></summary>
+ public override bool QualifyIndexName
+ {
+ get { return false; }
+ }
+
+ /// <summary></summary>
+ public override string ForUpdateString
+ {
+ get { return string.Empty; }
+ }
+
+ /// <summary></summary>
+ public override bool SupportsIdentityColumns
+ {
+ get { return true; }
+ }
+
+ /// <summary></summary>
+ public override string IdentitySelectString
+ {
+ get { return "select @@identity"; }
+ }
+
+ /// <summary></summary>
+ public override string IdentityColumnString
+ {
+ get { return "IDENTITY NOT NULL"; }
+ }
+
+ /// <summary></summary>
+ public override string NoColumnsInsertString
+ {
+ get { return "DEFAULT VALUES"; }
+ }
+
+ /// <remarks>
+ /// Sybase does not support quoted aliases, this function thus returns
+ /// <c>aliasName</c> as is.
+ /// </remarks>
+ public override string QuoteForAliasName(string aliasName)
+ {
+ return aliasName;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs 2008-09-29 20:26:50 UTC (rev 3801)
@@ -0,0 +1,49 @@
+namespace NHibernate.Driver
+{
+ /// <summary>
+ /// The SybaseClientDriver Driver provides a database driver for Sybase.
+ /// </summary>
+ /// <remarks>
+ /// It has been reported to work with the <see cref="Dialect.MsSql2000Dialect"/>.
+ /// </remarks>
+ public class SybaseAdoNet12ClientDriver : ReflectionBasedDriver
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SybaseClientDriver"/> class.
+ /// </summary>
+ /// <exception cref="HibernateException">
+ /// Thrown when the Sybase.Data.AseClient assembly can not be loaded.
+ /// </exception>
+ public SybaseAdoNet12ClientDriver()
+ : base(
+ "Sybase.AdoNet2.AseClient",
+ "Sybase.Data.AseClient.AseConnection",
+ "Sybase.Data.AseClient.AseCommand")
+ {
+ }
+
+ /// <summary>
+ /// Sybase.Data.AseClient uses named parameters in the sql.
+ /// </summary>
+ /// <value><see langword="true" /> - Sybase uses <c>@</c> in the sql.</value>
+ public override bool UseNamedPrefixInSql
+ {
+ get { return true; }
+ }
+
+ /// <summary></summary>
+ public override bool UseNamedPrefixInParameter
+ {
+ get { return true; }
+ }
+
+ /// <summary>
+ /// Sybase.Data.AseClient use the <c>@</c> to locate parameters in sql.
+ /// </summary>
+ /// <value><c>@</c> is used to locate parameters in sql.</value>
+ public override string NamedPrefix
+ {
+ get { return "@"; }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 20:10:50 UTC (rev 3800)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 20:26:50 UTC (rev 3801)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.50727</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -598,10 +598,12 @@
<Compile Include="Dialect\Schema\MsSqlMetaData.cs" />
<Compile Include="Dialect\Schema\OracleMetaData.cs" />
<Compile Include="Dialect\Sybase11Dialect.cs" />
+ <Compile Include="Dialect\SybaseAdoNet12Dialect.cs" />
<Compile Include="Driver\ASA10ClientDriver.cs" />
<Compile Include="Driver\ISqlParameterFormatter.cs" />
<Compile Include="Driver\SqlStringFormatter.cs" />
<Compile Include="Criterion\SubqueryProjection.cs" />
+ <Compile Include="Driver\SybaseAdoNet12ClientDriver.cs" />
<Compile Include="EmptyInterceptor.cs" />
<Compile Include="Engine\ActionQueue.cs" />
<Compile Include="Engine\AssociationKey.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-10-04 19:28:01
|
Revision: 3814
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3814&view=rev
Author: tehlike
Date: 2008-10-04 19:27:55 +0000 (Sat, 04 Oct 2008)
Log Message:
-----------
Fix for NH-1505 by Jaroslav Mart?\195?\161sek
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs
trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs
trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2008-10-04 19:20:12 UTC (rev 3813)
+++ trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2008-10-04 19:27:55 UTC (rev 3814)
@@ -46,7 +46,7 @@
}
}
- private static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria,
+ internal static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria,
IDictionary<string, IFilter> enabledFilters)
{
SqlString sqlString = projection.ToSqlString(criteria,
Modified: trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2008-10-04 19:20:12 UTC (rev 3813)
+++ trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2008-10-04 19:27:55 UTC (rev 3814)
@@ -17,15 +17,14 @@
[Serializable]
public class LikeExpression : AbstractCriterion
{
- private readonly string propertyName;
private readonly string value;
private char? escapeChar;
private readonly bool ignoreCase;
- private readonly IProjection _projection;
+ private readonly IProjection projection;
public LikeExpression(string propertyName, string value, char? escapeChar, bool ignoreCase)
{
- this.propertyName = propertyName;
+ this.projection = Projections.Property(propertyName);
this.value = value;
this.escapeChar = escapeChar;
this.ignoreCase = ignoreCase;
@@ -33,7 +32,7 @@
public LikeExpression(IProjection projection, string value, MatchMode matchMode)
{
- _projection = projection;
+ this.projection = projection;
this.value = matchMode.ToMatchString(value);
}
@@ -57,21 +56,23 @@
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
{
- string[] columns = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
+ SqlString[] columns = CriterionUtil.GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters);
if (columns.Length != 1)
- throw new HibernateException("Like may only be used with single-column properties");
+ throw new HibernateException("Like may only be used with single-column properties / projections.");
SqlStringBuilder lhs = new SqlStringBuilder(6);
- if(ignoreCase)
+ if (ignoreCase)
{
Dialect.Dialect dialect = criteriaQuery.Factory.Dialect;
- lhs.Add(dialect.LowercaseFunction).Add(StringHelper.OpenParen).Add(columns[0]).Add(
- StringHelper.ClosedParen);
+ lhs.Add(dialect.LowercaseFunction)
+ .Add(StringHelper.OpenParen)
+ .Add(columns[0])
+ .Add(StringHelper.ClosedParen);
}
- else
+ else
lhs.Add(columns[0]);
-
+
criteriaQuery.AddUsedTypedValues(GetTypedValues(criteria, criteriaQuery));
lhs.Add(" like ").AddParameter();
if (escapeChar.HasValue)
@@ -81,23 +82,21 @@
public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
{
- return new TypedValue[] {criteriaQuery.GetTypedValue(criteria, propertyName, ignoreCase ? value.ToLower() : value)};
+ return new TypedValue[] {
+ new TypedValue(NHibernateUtil.String, value, EntityMode.Poco),
+ };
}
public override IProjection[] GetProjections()
{
- if(_projection != null)
- {
- return new IProjection[] {_projection};
- }
- return null;
+ return new IProjection[] { projection };
}
#endregion
public override string ToString()
{
- return (_projection != null ? _projection.ToString() : propertyName) + " like " + value;
+ return projection + " like " + value;
}
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-10-04 19:20:12 UTC (rev 3813)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-10-04 19:27:55 UTC (rev 3814)
@@ -1655,8 +1655,8 @@
t.Commit();
}
}
-
+
[Test]
public void TransformToRowCountTest()
{
@@ -1677,9 +1677,11 @@
}
[Test]
- public void OrderProjectionTest() {
- using (ISession session = this.OpenSession()) {
- ICriteria criteria = session.CreateCriteria(typeof (Student), "c");
+ public void OrderProjectionTest()
+ {
+ using (ISession session = this.OpenSession())
+ {
+ ICriteria criteria = session.CreateCriteria(typeof(Student), "c");
criteria
.AddOrder(Order.Asc(
@@ -1692,5 +1694,67 @@
criteria.List();
}
}
+
+ [Test]
+ public void LikeProjectionTest()
+ {
+ Student john = new Student { Name = "John" };
+ using (ISession session = this.OpenSession())
+ {
+ session.Save(john);
+ session.Flush();
+ }
+
+
+ using (ISession session = this.OpenSession())
+ {
+ ICriteria criteria = session.CreateCriteria(typeof(Student), "c");
+
+ criteria.Add(new LikeExpression(Projections.Property("Name"), "John", MatchMode.Anywhere));
+
+ Assert.AreEqual(1, criteria.List().Count);
+ }
+
+ using (ISession session = this.OpenSession())
+ {
+ ICriteria criteria = session.CreateCriteria(typeof(Student), "c");
+
+ criteria.Add(new LikeExpression("Name", "John"));
+
+ Assert.AreEqual(1, criteria.List().Count);
+ }
+
+ using (ISession session = this.OpenSession())
+ {
+ session.Delete(john);
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void LikeProjectionUsingRestrictionsTest()
+ {
+ using (ISession session = this.OpenSession())
+ {
+ ICriteria criteria = session.CreateCriteria(typeof(Student), "c");
+
+ criteria.Add(Restrictions.Like(Projections.Constant("Name"), "John", MatchMode.Anywhere));
+
+ criteria.List();
+ }
+ }
+
+ [Test]
+ public void InsensitiveLikeProjectionUsingRestrictionsTest()
+ {
+ using (ISession session = this.OpenSession())
+ {
+ ICriteria criteria = session.CreateCriteria(typeof(Student), "c");
+
+ criteria.Add(Restrictions.InsensitiveLike(Projections.Constant("Name"), "John", MatchMode.Anywhere));
+
+ criteria.List();
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-10-08 15:17:06
|
Revision: 3816
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3816&view=rev
Author: fabiomaulo
Date: 2008-10-08 15:16:52 +0000 (Wed, 08 Oct 2008)
Log Message:
-----------
Log info per Operation Threshold in statistics (from H3.2.6)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs
trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs
trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs
trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs
trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs
trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs
trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs
trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs
trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs
trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs
trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs
trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs
trunk/nhibernate/src/NHibernate/Loader/Loader.cs
trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs
trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs
trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs
trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs
trunk/nhibernate/src/NHibernate.Test/Stats/StatsFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Collection;
using NHibernate.Engine;
using NHibernate.Event;
@@ -13,8 +14,18 @@
: base(persister, collection, key, session) { }
/// <summary> Execute this action</summary>
+ /// <remarks>
+ /// This method is called when a new non-null collection is persisted
+ /// or when an existing (non-null) collection is moved to a new owner
+ /// </remarks>
public override void Execute()
{
+ bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
IPersistentCollection collection = Collection;
PreRecreate();
@@ -26,10 +37,10 @@
Evict();
PostRecreate();
-
- if (Session.Factory.Statistics.IsStatisticsEnabled)
+ if (statsEnabled)
{
- Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role);
+ stopWath.Stop();
+ Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Collection;
using NHibernate.Engine;
using NHibernate.Event;
@@ -56,6 +57,13 @@
public override void Execute()
{
+ bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
PreRemove();
if (!emptySnapshot)
@@ -73,9 +81,10 @@
PostRemove();
- if (Session.Factory.Statistics.IsStatisticsEnabled)
+ if (statsEnabled)
{
- Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role);
+ stopWath.Stop();
+ Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Cache;
using NHibernate.Cache.Entry;
using NHibernate.Collection;
@@ -29,6 +30,13 @@
IPersistentCollection collection = Collection;
bool affectedByFilters = persister.IsAffectedByEnabledFilters(session);
+ bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
PreUpdate();
if (!collection.WasInitialized)
@@ -72,9 +80,10 @@
PostUpdate();
- if (Session.Factory.Statistics.IsStatisticsEnabled)
+ if (statsEnabled)
{
- Session.Factory.StatisticsImplementor.UpdateCollection(Persister.Role);
+ stopWath.Stop();
+ Session.Factory.StatisticsImplementor.UpdateCollection(Persister.Role, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Cache;
using NHibernate.Engine;
using NHibernate.Event;
@@ -34,6 +35,13 @@
ISessionImplementor session = Session;
object instance = Instance;
+ bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
bool veto = PreDelete();
object tmpVersion = version;
@@ -83,9 +91,10 @@
PostDelete();
- if (Session.Factory.Statistics.IsStatisticsEnabled && !veto)
+ if (statsEnabled && !veto)
{
- Session.Factory.StatisticsImplementor.DeleteEntity(Persister.EntityName);
+ stopWath.Stop();
+ Session.Factory.StatisticsImplementor.DeleteEntity(Persister.EntityName, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Engine;
using NHibernate.Event;
using NHibernate.Persister.Entity;
@@ -57,6 +58,13 @@
IEntityPersister persister = Persister;
object instance = Instance;
+ bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
bool veto = PreInsert();
// Don't need to lock the cache here, since if someone
@@ -84,9 +92,10 @@
}*/
PostInsert();
- if (Session.Factory.Statistics.IsStatisticsEnabled && !veto)
+ if (statsEnabled && !veto)
{
- Session.Factory.StatisticsImplementor.InsertEntity(Persister.EntityName);
+ stopWath.Stop();
+ Session.Factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Cache;
using NHibernate.Cache.Entry;
using NHibernate.Engine;
@@ -41,6 +42,13 @@
object instance = Instance;
object id = Id;
+ bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
bool veto = PreInsert();
// Don't need to lock the cache here, since if someone
@@ -87,9 +95,10 @@
PostInsert();
- if (factory.Statistics.IsStatisticsEnabled && !veto)
+ if (statsEnabled && !veto)
{
- factory.StatisticsImplementor.InsertEntity(Persister.EntityName);
+ stopWath.Stop();
+ factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using NHibernate.Cache;
using NHibernate.Cache.Entry;
using NHibernate.Engine;
@@ -46,6 +47,13 @@
IEntityPersister persister = Persister;
object instance = Instance;
+ bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
bool veto = PreUpdate();
ISessionFactoryImplementor factory = Session.Factory;
@@ -119,9 +127,10 @@
PostUpdate();
- if (factory.Statistics.IsStatisticsEnabled && !veto)
+ if (statsEnabled && !veto)
{
- factory.StatisticsImplementor.UpdateEntity(Persister.EntityName);
+ stopWath.Stop();
+ factory.StatisticsImplementor.UpdateEntity(Persister.EntityName, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
+using System.Diagnostics;
using Iesi.Collections.Generic;
using log4net;
using NHibernate.Cache;
@@ -238,6 +239,13 @@
ISessionImplementor session = LoadContext.PersistenceContext.Session;
EntityMode em = session.EntityMode;
+ bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
bool hasNoQueuedAdds = lce.Collection.EndRead(persister); // warning: can cause a recursive calls! (proxy initialization)
if (persister.CollectionType.HasHolder(em))
@@ -268,9 +276,10 @@
log.Debug("collection fully initialized: " + MessageHelper.InfoString(persister, lce.Key, session.Factory));
}
- if (session.Factory.Statistics.IsStatisticsEnabled)
+ if (statsEnabled)
{
- session.Factory.StatisticsImplementor.LoadCollection(persister.Role);
+ stopWath.Stop();
+ session.Factory.StatisticsImplementor.LoadCollection(persister.Role, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,3 +1,4 @@
+using System.Diagnostics;
using log4net;
using NHibernate.Cache;
using NHibernate.Cache.Entry;
@@ -47,6 +48,14 @@
public static void InitializeEntity(object entity, bool readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent, PostLoadEvent postLoadEvent)
{
//TODO: Should this be an InitializeEntityEventListener??? (watch out for performance!)
+
+ bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
IPersistenceContext persistenceContext = session.PersistenceContext;
EntityEntry entityEntry = persistenceContext.GetEntry(entity);
if (entityEntry == null)
@@ -140,9 +149,10 @@
if (log.IsDebugEnabled)
log.Debug("done materializing entity " + MessageHelper.InfoString(persister, id, session.Factory));
- if (factory.Statistics.IsStatisticsEnabled)
+ if (statsEnabled)
{
- factory.StatisticsImplementor.LoadEntity(persister.EntityName);
+ stopWath.Stop();
+ factory.StatisticsImplementor.LoadEntity(persister.EntityName, stopWath.Elapsed);
}
}
Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using log4net;
using NHibernate.Cache;
using NHibernate.Cache.Entry;
@@ -20,6 +21,13 @@
IPersistentCollection collection = @event.Collection;
ISessionImplementor source = @event.Session;
+ bool statsEnabled = source.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
CollectionEntry ce = source.PersistenceContext.GetCollectionEntry(collection);
if (ce == null)
throw new HibernateException("collection was evicted");
@@ -43,9 +51,10 @@
ce.LoadedPersister.Initialize(ce.LoadedKey, source);
log.Debug("collection initialized");
- if (source.Factory.Statistics.IsStatisticsEnabled)
+ if (statsEnabled)
{
- source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role);
+ stopWath.Stop();
+ source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role, stopWath.Elapsed);
}
}
}
Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using log4net;
using NHibernate.Cache;
using NHibernate.Cache.Entry;
@@ -328,11 +329,20 @@
protected virtual object LoadFromDatasource(LoadEvent @event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)
{
ISessionImplementor source = @event.Session;
+
+ bool statsEnabled = source.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
object entity = persister.Load(@event.EntityId, @event.InstanceToLoad, @event.LockMode, source);
- if (@event.IsAssociationFetch && source.Factory.Statistics.IsStatisticsEnabled)
+ if (@event.IsAssociationFetch && statsEnabled)
{
- source.Factory.StatisticsImplementor.FetchEntity(@event.EntityClassName);
+ stopWath.Stop();
+ source.Factory.StatisticsImplementor.FetchEntity(@event.EntityClassName, stopWath.Elapsed);
}
return entity;
Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Data;
+using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
@@ -1288,11 +1289,14 @@
public IEnumerable GetEnumerable(QueryParameters parameters, ISessionImplementor session)
{
- bool stats = session.Factory.Statistics.IsStatisticsEnabled;
- long startTime = 0;
- if (stats)
- startTime = DateTime.Now.Ticks;
+ bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
+ {
+ stopWath.Start();
+ }
+
IDbCommand cmd = PrepareQueryCommand(parameters, false, session);
// This IDataReader is disposed of in EnumerableImpl.Dispose
@@ -1301,12 +1305,13 @@
HolderInstantiator.CreateClassicHolderInstantiator(holderConstructor, parameters.ResultTransformer);
IEnumerable result =
new EnumerableImpl(rs, cmd, session, ReturnTypes, ScalarColumnNames, parameters.RowSelection, hi);
- if (stats)
+ if (statsEnabled)
{
- session.Factory.StatisticsImplementor.QueryExecuted("HQL: " + queryString, 0, (DateTime.Now.Ticks - startTime));
+ stopWath.Stop();
+ session.Factory.StatisticsImplementor.QueryExecuted("HQL: " + queryString, 0, stopWath.Elapsed);
// NH: Different behavior (H3.2 use QueryLoader in AST parser) we need statistic for orginal query too.
// probably we have a bug some where else for statistic RowCount
- session.Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, 0, (DateTime.Now.Ticks - startTime));
+ session.Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, 0, stopWath.Elapsed);
}
return result;
}
Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
+using System.Diagnostics;
using System.Runtime.CompilerServices;
using Iesi.Collections;
using Iesi.Collections.Generic;
@@ -1686,11 +1687,11 @@
/// <returns></returns>
protected IList DoList(ISessionImplementor session, QueryParameters queryParameters)
{
- bool stats = Factory.Statistics.IsStatisticsEnabled;
- long startTime = 0;
- if (stats)
+ bool statsEnabled = Factory.Statistics.IsStatisticsEnabled;
+ var stopWath = new Stopwatch();
+ if (statsEnabled)
{
- startTime = DateTime.Now.Ticks;
+ stopWath.Start();
}
IList result;
@@ -1708,9 +1709,10 @@
throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, sqle, "could not execute query", SqlString,
queryParameters.PositionalParameterValues, queryParameters.NamedParameters);
}
- if (stats)
+ if (statsEnabled)
{
- Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, result.Count, (DateTime.Now.Ticks - startTime));
+ stopWath.Stop();
+ Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, result.Count, stopWath.Elapsed);
}
return result;
}
Modified: trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,12 +1,11 @@
using System;
+using System.Diagnostics;
namespace NHibernate.Stat
{
/// <summary>
- /// Statistics for a particular <tt>SessionFactory</tt>.
- /// Beware of milliseconds metrics, they are dependent of the JVM precision:
- /// you may then encounter a 10 ms approximation depending on your OS platform.
- /// Please refer to the JVM documentation for more information.
+ /// Statistics for a particular <see cref="ISessionFactory"/>.
+ /// Beware of metrics, they are dependent of the <see cref="Stopwatch"/> precision:
/// </summary>
public interface IStatistics
{
@@ -28,8 +27,8 @@
/// <summary> Global number of executed queries</summary>
long QueryExecutionCount { get;}
- /// <summary> The time in milliseconds of the slowest query.</summary>
- long QueryExecutionMaxTime { get;}
+ /// <summary> The <see cref="TimeSpan"/> of the slowest query.</summary>
+ TimeSpan QueryExecutionMaxTime { get; }
/// <summary> The query string for the slowest query.</summary>
string QueryExecutionMaxTimeQueryString { get;}
@@ -141,5 +140,11 @@
/// <summary> log in info level the main statistics</summary>
void LogSummary();
+
+ /// <summary>
+ /// The OperationThreshold to a value greater than <see cref="TimeSpan.MinValue"/> to enable logging of long running operations.
+ /// </summary>
+ /// <remarks>Operations that exceed the level will be logged.</remarks>
+ TimeSpan OperationThreshold { get; set; }
}
}
Modified: trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,3 +1,4 @@
+using System;
namespace NHibernate.Stat
{
/// <summary> Statistics SPI for the NHibernate core </summary>
@@ -7,20 +8,20 @@
void CloseSession();
void Flush();
void Connect();
- void LoadEntity(string entityName);
- void FetchEntity(string entityName);
- void UpdateEntity(string entityName);
- void InsertEntity(string entityName);
- void DeleteEntity(string entityName);
- void LoadCollection(string role);
- void FetchCollection(string role);
- void UpdateCollection(string role);
- void RecreateCollection(string role);
- void RemoveCollection(string role);
+ void LoadEntity(string entityName, TimeSpan time);
+ void FetchEntity(string entityName, TimeSpan time);
+ void UpdateEntity(string entityName, TimeSpan time);
+ void InsertEntity(string entityName, TimeSpan time);
+ void DeleteEntity(string entityName, TimeSpan time);
+ void LoadCollection(string role, TimeSpan time);
+ void FetchCollection(string role, TimeSpan time);
+ void UpdateCollection(string role, TimeSpan time);
+ void RecreateCollection(string role, TimeSpan time);
+ void RemoveCollection(string role, TimeSpan time);
void SecondLevelCachePut(string regionName);
void SecondLevelCacheHit(string regionName);
void SecondLevelCacheMiss(string regionName);
- void QueryExecuted(string hql, int rows, long time);
+ void QueryExecuted(string hql, int rows, TimeSpan time);
void QueryCacheHit(string hql, string regionName);
void QueryCacheMiss(string hql, string regionName);
void QueryCachePut(string hql, string regionName);
Modified: trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -13,9 +13,9 @@
internal long cachePutCount;
private long executionCount;
private long executionRowCount;
- private long executionAvgTime;
- private long executionMaxTime;
- private long executionMinTime;
+ private TimeSpan executionAvgTime;
+ private TimeSpan executionMaxTime;
+ private TimeSpan executionMinTime = TimeSpan.MaxValue;
public QueryStatistics(string categoryName) : base(categoryName) { }
@@ -44,17 +44,17 @@
get { return executionRowCount; }
}
- public long ExecutionAvgTime
+ public TimeSpan ExecutionAvgTime
{
get { return executionAvgTime; }
}
- public long ExecutionMaxTime
+ public TimeSpan ExecutionMaxTime
{
get { return executionMaxTime; }
}
- public long ExecutionMinTime
+ public TimeSpan ExecutionMinTime
{
get { return executionMinTime; }
}
@@ -62,7 +62,7 @@
/// <summary> Add statistics report of a DB query </summary>
/// <param name="rows">rows count returned </param>
/// <param name="time">time taken </param>
- internal void Executed(long rows, long time)
+ internal void Executed(long rows, TimeSpan time)
{
if (time < executionMinTime)
executionMinTime = time;
@@ -70,7 +70,7 @@
executionMaxTime = time;
executionCount++;
executionRowCount += rows;
- executionAvgTime = (executionAvgTime * executionCount + time) / executionCount;
+ executionAvgTime = TimeSpan.FromTicks((executionAvgTime.Ticks * executionCount + time.Ticks) / executionCount);
}
public override string ToString()
Modified: trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs 2008-10-05 13:07:29 UTC (rev 3815)
+++ trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs 2008-10-08 15:16:52 UTC (rev 3816)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
+using System.Text;
using System.Threading;
using log4net;
using NHibernate.Cache;
@@ -20,8 +21,10 @@
private long entityLoadCount;
private long entityFetchCount;
private long entityUpdateCount;
+ // log operations that take longer than this value
+ private TimeSpan operationThreshold = TimeSpan.MaxValue;
private long queryExecutionCount;
- private long queryExecutionMaxTime;
+ private TimeSpan queryExecutionMaxTime;
private string queryExecutionMaxTimeQueryString;
private long queryCacheHitCount;
private long queryCacheMissCount;
@@ -39,7 +42,6 @@
private long collectionRemoveCount;
private long collectionRecreateCount;
private DateTime startTime;
- private bool isStatisticsEnabled;
private long commitedTransactionCount;
private long transactionCount;
private long prepareStatementCount;
@@ -54,8 +56,22 @@
// entity statistics per query string (HQL or SQL)
private readonly Dictionary<string, QueryStatistics> queryStatistics = new Dictionary<string, QueryStatistics>();
+ internal const string OperationLoad = "load ";
+ internal const string OperationFetch = "fetch ";
+ internal const string OperationUpdate = "update ";
+ internal const string OperationInsert = "insert ";
+ internal const string OperationDelete = "delete ";
+ internal const string OperationLoadCollection = "loadCollection ";
+ internal const string OperationFetchCollection = "fetchCollection ";
+ internal const string OperationUpdateCollection = "updateCollection ";
+ internal const string OperationRecreateCollection = "recreateCollection ";
+ internal const string OperationRemoveCollection = "removeCollection ";
+ internal const string OperationExecuteQuery = "executeQuery ";
+ internal const string OperationEndTransaction = "endTransaction ";
+
public StatisticsImpl()
{
+ Clear();
}
public StatisticsImpl(ISessionFactoryImplementor sessionFactory)
@@ -107,7 +123,7 @@
get { return queryExecutionCount; }
}
- public long QueryExecutionMaxTime
+ public TimeSpan QueryExecutionMaxTime
{
get { return queryExecutionMaxTime; }
}
@@ -197,17 +213,13 @@
get { return startTime; }
}
- public bool IsStatisticsEnabled
- {
- get { return isStatisticsEnabled; }
- set { isStatisticsEnabled = value; }
- }
+ public bool IsStatisticsEnabled { get; set; }
public string[] Queries
{
get
{
- string[] result = new string[queryStatistics.Keys.Count];
+ var result = new string[queryStatistics.Keys.Count];
queryStatistics.Keys.CopyTo(result,0);
return result;
}
@@ -219,7 +231,7 @@
{
if (sessionFactory == null)
{
- string[] result = new string[entityStatistics.Keys.Count];
+ var result = new string[entityStatistics.Keys.Count];
entityStatistics.Keys.CopyTo(result, 0);
return result;
}
@@ -236,14 +248,14 @@
{
if (sessionFactory == null)
{
- string[] result = new string[collectionStatistics.Keys.Count];
+ var result = new string[collectionStatistics.Keys.Count];
collectionStatistics.Keys.CopyTo(result, 0);
return result;
}
else
{
ICollection<string> kc = sessionFactory.GetAllCollectionMetadata().Keys;
- string[] result = new string[kc.Count];
+ var result = new string[kc.Count];
kc.CopyTo(result, 0);
return result;
}
@@ -256,7 +268,7 @@
{
if (sessionFactory == null)
{
- string[] result = new string[secondLevelCacheStatistics.Keys.Count];
+ var result = new string[secondLevelCacheStatistics.Keys.Count];
secondLevelCacheStatistics.Keys.CopyTo(result, 0);
return result;
}
@@ -323,7 +335,7 @@
queryExecutionCount = 0;
queryCacheHitCount = 0;
- queryExecutionMaxTime = 0;
+ queryExecutionMaxTime = TimeSpan.MinValue;
queryExecutionMaxTimeQueryString = null;
queryCacheMissCount = 0;
queryCachePutCount = 0;
@@ -348,8 +360,7 @@
lock (SyncRoot)
{
EntityStatistics es;
- entityStatistics.TryGetValue(entityName, out es);
- if (es == null)
+ if (!entityStatistics.TryGetValue(entityName, out es))
{
es = new EntityStatistics(entityName);
entityStatistics[entityName] = es;
@@ -364,8 +375,7 @@
lock (SyncRoot)
{
CollectionStatistics cs;
- collectionStatistics.TryGetValue(role, out cs);
- if (cs == null)
+ if (!collectionStatistics.TryGetValue(role, out cs))
{
cs = new CollectionStatistics(role);
collectionStatistics[role] = cs;
@@ -380,8 +390,8 @@
lock (SyncRoot)
{
SecondLevelCacheStatistics slcs;
- secondLevelCacheStatistics.TryGetValue(regionName, out slcs);
- if (slcs == null)
+
+ if (!secondLevelCacheStatistics.TryGetValue(regionName, out slcs))
{
if (sessionFactory == null)
return null;
@@ -401,8 +411,7 @@
lock (SyncRoot)
{
QueryStatistics qs;
- queryStatistics.TryGetValue(queryString, out qs);
- if (qs == null)
+ if (!queryStatistics.TryGetValue(queryString, out qs))
{
qs = n...
[truncated message content] |