|
From: <fab...@us...> - 2009-01-10 20:36:35
|
Revision: 3993
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3993&view=rev
Author: fabiomaulo
Date: 2009-01-10 20:36:28 +0000 (Sat, 10 Jan 2009)
Log Message:
-----------
Fix NH-1640
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-10 15:56:55 UTC (rev 3992)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-10 20:36:28 UTC (rev 3993)
@@ -48,13 +48,17 @@
{
CheckAndUpdateSessionStatus();
IEntityPersister persister = Factory.GetEntityPersister(entityName);
+ object loaded = temporaryPersistenceContext.GetEntity(new EntityKey(id, persister, EntityMode.Poco));
+ if(loaded != null)
+ {
+ return loaded;
+ }
if (!eager && persister.HasProxy)
{
return persister.CreateProxy(id, this);
}
- object loaded = temporaryPersistenceContext.GetEntity(new EntityKey(id, persister, EntityMode.Poco));
//TODO: if not loaded, throw an exception
- return loaded ?? Get(entityName, id);
+ return Get(entityName, id);
}
public override object ImmediateLoad(string entityName, object id)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Entity.cs 2009-01-10 20:36:28 UTC (rev 3993)
@@ -0,0 +1,11 @@
+namespace NHibernate.Test.NHSpecificTest.NH1640
+{
+ public class Entity
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string Name { get; set; }
+
+ public virtual Entity Child { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs 2009-01-10 20:36:28 UTC (rev 3993)
@@ -0,0 +1,41 @@
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1640
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void FetchJoinShouldNotReturnProxyTest()
+ {
+ int savedId;
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ var sub = new Entity {Id = 2, Name = "Child 2"};
+ savedId = (int) session.Save(new Entity {Id = 1, Name = "Parent 1", Child = sub});
+ tx.Commit();
+ }
+ }
+
+ using (IStatelessSession session = sessions.OpenStatelessSession())
+ {
+ var parent =
+ session.CreateQuery("from Entity p join fetch p.Child where p.Id=:pId").SetInt32("pId", savedId).UniqueResult
+ <Entity>();
+ Assert.That(parent.Child,Is.TypeOf(typeof (Entity)));
+ }
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Entity");
+ tx.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1640/Mappings.hbm.xml 2009-01-10 20:36:28 UTC (rev 3993)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1640">
+
+ <class name="Entity">
+ <id name="Id">
+ <generator class="assigned"/>
+ </id>
+ <property name="Name" />
+ <many-to-one name="Child" cascade="all"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 15:56:55 UTC (rev 3992)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 20:36:28 UTC (rev 3993)
@@ -576,6 +576,8 @@
<Compile Include="NHSpecificTest\NH1621\Model.cs" />
<Compile Include="NHSpecificTest\NH1632\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1632\Model.cs" />
+ <Compile Include="NHSpecificTest\NH1640\Entity.cs" />
+ <Compile Include="NHSpecificTest\NH1640\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1597,6 +1599,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1584\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1612\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|