|
From: <fab...@us...> - 2010-10-06 18:58:19
|
Revision: 5233
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5233&view=rev
Author: fabiomaulo
Date: 2010-10-06 18:58:13 +0000 (Wed, 06 Oct 2010)
Log Message:
-----------
Fix NH-2364
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2010-10-06 17:40:17 UTC (rev 5232)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2010-10-06 18:58:13 UTC (rev 5233)
@@ -600,6 +600,11 @@
// and take the System.Type directly from the persister (className have high probability to be entityName)
if (entityPersisters.TryGetValue(className, out checkPersister))
{
+ if(!checkPersister.EntityMetamodel.HasPocoRepresentation)
+ {
+ // we found the persister but it is a dynamic entity without class
+ return new[] { className };
+ }
// NH : take care with this because we are forcing the Poco EntityMode
clazz = checkPersister.GetMappedClass(EntityMode.Poco);
}
Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs 2010-10-06 17:40:17 UTC (rev 5232)
+++ trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs 2010-10-06 18:58:13 UTC (rev 5233)
@@ -125,7 +125,7 @@
bool foundInsertGeneratedValue = false;
bool foundUpdateGeneratedValue = false;
bool foundNonIdentifierPropertyNamedId = false;
-
+ HasPocoRepresentation = persistentClass.HasPocoRepresentation;
foreach (Mapping.Property prop in persistentClass.PropertyClosureIterator)
{
// NH: A lazy property is a simple property marked with lazy=true or a relation (in this case many-to-one or one-to-one marked as "no-proxy")
@@ -301,6 +301,8 @@
tuplizerMapping = new EntityEntityModeToTuplizerMapping(persistentClass, this);
}
+ public bool HasPocoRepresentation { get; private set; }
+
private static void VerifyCanInterceptPropertiesForLazyOrGhostProperties(PersistentClass persistentClass)
{
foreach (var prop in persistentClass.PropertyClosureIterator)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Fixture.cs 2010-10-06 18:58:13 UTC (rev 5233)
@@ -0,0 +1,79 @@
+using System.Collections;
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.EntityNameWithFullName
+{
+ public class Fixture : BugTestCase
+ {
+ protected override void OnTearDown()
+ {
+ using (var s = OpenSession())
+ {
+ using (var tx = s.BeginTransaction())
+ {
+ s.CreateSQLQuery("delete from Parent").ExecuteUpdate();
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void CanPersistAndRead()
+ {
+ using (var s = OpenSession())
+ {
+ using (var tx = s.BeginTransaction())
+ {
+ s.Save("NHibernate.Test.NHSpecificTest.EntityNameWithFullName.Parent", new Dictionary<string, object>
+ {
+ {"SomeData", "hello"}
+ });
+ tx.Commit();
+ }
+ }
+ using (var s = OpenSession())
+ {
+ using (s.BeginTransaction())
+ {
+ var p = (IDictionary)s.CreateQuery(@"select p from NHibernate.Test.NHSpecificTest.EntityNameWithFullName.Parent p where p.SomeData = :data")
+ .SetString("data", "hello")
+ .List()[0];
+ Assert.AreEqual("hello", p["SomeData"]);
+ }
+ }
+ }
+
+ [Test]
+ public void OnlyOneSelect()
+ {
+ using (var s = OpenSession())
+ {
+ var sf = s.SessionFactory;
+ var onOffBefore = turnOnStatistics(s);
+ try
+ {
+ using (s.BeginTransaction())
+ {
+ s.CreateQuery(@"select p from NHibernate.Test.NHSpecificTest.EntityNameWithFullName.Parent p where p.SomeData = :data")
+ .SetString("data", "hello")
+ .List();
+ }
+ Assert.AreEqual(1, sf.Statistics.QueryExecutionCount);
+ }
+ finally
+ {
+ sf.Statistics.IsStatisticsEnabled = onOffBefore;
+ }
+ }
+ }
+
+ private static bool turnOnStatistics(ISession session)
+ {
+ var onOff = session.SessionFactory.Statistics.IsStatisticsEnabled;
+ session.SessionFactory.Statistics.IsStatisticsEnabled = true;
+ session.SessionFactory.Statistics.Clear();
+ return onOff;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameWithFullName/Mappings.hbm.xml 2010-10-06 18:58:13 UTC (rev 5233)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test">
+ <class entity-name="NHibernate.Test.NHSpecificTest.EntityNameWithFullName.Parent">
+ <id name="Id" type="Int32">
+ <generator class="native"/>
+ </id>
+ <property name="SomeData" type="string"/>
+ </class>
+
+ <!-- just a dummy mapping here to show the problem -->
+ <class entity-name="NHibernate.Test.NHSpecificTest.EntityNameWithFullName.Parent2">
+ <id name="Id" type="Int32">
+ <generator class="native"/>
+ </id>
+ <property name="SomeOtherData" type="string"/>
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-10-06 17:40:17 UTC (rev 5232)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-10-06 18:58:13 UTC (rev 5233)
@@ -455,6 +455,7 @@
<Compile Include="Logging\Log4NetLoggerTest.cs" />
<Compile Include="Logging\LoggerProviderTest.cs" />
<Compile Include="NHSpecificTest\EntityNameAndCompositeId\Fixture.cs" />
+ <Compile Include="NHSpecificTest\EntityNameWithFullName\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1136\Address.cs" />
<Compile Include="NHSpecificTest\NH1136\FeeMatrixType.cs" />
<Compile Include="NHSpecificTest\NH1136\Fixture.cs" />
@@ -2320,6 +2321,7 @@
<EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" />
<EmbeddedResource Include="DriverTest\EntityForMs2008.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\EntityNameWithFullName\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2361\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\EntityNameAndCompositeId\Mappings.hbm.xml" />
<EmbeddedResource Include="PolymorphicGetAndLoad\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|