From a901f3da093e6aea23995c498fe69210f76293c7 Mon Sep 17 00:00:00 2001 From: Oleg Volkov Date: Thu, 19 Feb 2015 17:58:54 +0200 Subject: [PATCH 1/2] Added a test case for bug with component of entity-name mapped entity (NH-3757) --- .../NHSpecificTest/NH3757/Fixture.cs | 36 +++++++++++++++++++ .../NHSpecificTest/NH3757/Mappings.hbm.xml | 12 +++++++ .../NHSpecificTest/NH3757/Money.cs | 9 +++++ src/NHibernate.Test/NHibernate.Test.csproj | 3 ++ 4 files changed, 60 insertions(+) create mode 100644 src/NHibernate.Test/NHSpecificTest/NH3757/Fixture.cs create mode 100644 src/NHibernate.Test/NHSpecificTest/NH3757/Mappings.hbm.xml create mode 100644 src/NHibernate.Test/NHSpecificTest/NH3757/Money.cs diff --git a/src/NHibernate.Test/NHSpecificTest/NH3757/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3757/Fixture.cs new file mode 100644 index 00000000000..ac9ecd4eda6 --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/NH3757/Fixture.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH3757 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateSQLQuery("delete from EntityName").ExecuteUpdate(); + tx.Commit(); + } + } + } + + [Test] + public void ShouldBePossibleToHaveComponentInEntityNameMappedEntity() + { + using (ISession session = OpenSession()) + using (ITransaction transaction = session.BeginTransaction()) + { + var e1 = new Dictionary(); + e1["Money"] = new Money { Amount = 100m, Currency = "USD" }; + session.Save("EntityName", e1); + + session.Flush(); + transaction.Commit(); + } + } + } +} \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH3757/Mappings.hbm.xml b/src/NHibernate.Test/NHSpecificTest/NH3757/Mappings.hbm.xml new file mode 100644 index 00000000000..55d39756ced --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/NH3757/Mappings.hbm.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH3757/Money.cs b/src/NHibernate.Test/NHSpecificTest/NH3757/Money.cs new file mode 100644 index 00000000000..b00e71ac4a8 --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/NH3757/Money.cs @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH3757 +{ + public class Money + { + public virtual decimal Amount { get; set; } + + public virtual string Currency { get; set; } + } +} diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index f21597364cf..a3aafcda21a 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -1321,6 +1321,8 @@ + + @@ -3221,6 +3223,7 @@ Designer + From e32dcc6594d82f331fbd95de1c793a34cad8e94e Mon Sep 17 00:00:00 2001 From: Oleg Volkov Date: Thu, 19 Feb 2015 18:47:05 +0200 Subject: [PATCH 2/2] Added a fix for a bug with a component of dynamic entity (NH-3757) --- .../Tuple/Component/ComponentEntityModeToTuplizerMapping.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs b/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs index 8b4fd90691b..4734e508a75 100644 --- a/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs +++ b/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs @@ -46,7 +46,7 @@ public ComponentEntityModeToTuplizerMapping(Mapping.Component component) userSuppliedTuplizerImpls.TryGetValue(EntityMode.Poco, out tempObject2); userSuppliedTuplizerImpls.Remove(EntityMode.Poco); tuplizerImpl = tempObject2; - if (owner.HasPocoRepresentation && component.HasPocoRepresentation) + if (component.HasPocoRepresentation) { if (tuplizerImpl == null) {