diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2714/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2714/Fixture.cs
new file mode 100644
index 00000000000..3f36005ebe0
--- /dev/null
+++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2714/Fixture.cs
@@ -0,0 +1,76 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by AsyncGenerator.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2714
+{
+ using System.Threading.Tasks;
+ [TestFixture]
+ public class FixtureAsync : BugTestCase
+ {
+ private const int ExtraId = 500;
+
+ protected override void OnTearDown()
+ {
+ using (ISession s = OpenSession())
+ {
+ s.Delete($"from {nameof(Item)}");
+ s.Flush();
+ s.Delete($"from {nameof(Information)}");
+ s.Flush();
+ }
+ }
+
+ [Test]
+ public async Task PropertyRefUsesOtherColumnsAsync()
+ {
+ var information = new Information {Name = "First", ExtraId = ExtraId};
+
+ var item = new Item {Id = 1, Name = information.Name, ExtraId = information.ExtraId};
+
+ using (ISession session = OpenSession())
+ {
+ await (session.SaveAsync(information));
+ await (session.SaveAsync(item));
+ await (session.FlushAsync());
+ }
+
+ using (ISession session = OpenSession())
+ {
+ var otherInformation = await (session.GetAsync(information.Id));
+ Assert.That(otherInformation.Items.Count, Is.EqualTo(1));
+ }
+ }
+
+ [Test]
+ public async Task ChildKeyPropertiesOfParentAreRetrievedAsync()
+ {
+ var information = new Information {Name = "First", ExtraId = ExtraId};
+
+ var item = new Item {Id = 1, Name = information.Name, ExtraId = information.ExtraId};
+
+ using (ISession session = OpenSession())
+ {
+ await (session.SaveAsync(information));
+ await (session.SaveAsync(item));
+ await (session.FlushAsync());
+ }
+
+ using (ISession session = OpenSession())
+ {
+ var otherInformation = await (session.GetAsync(information.Id));
+
+ Assert.That(otherInformation.Name, Is.EqualTo(information.Name));
+ Assert.That(otherInformation.ExtraId, Is.EqualTo(information.ExtraId));
+ }
+ }
+ }
+}
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2714/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2714/Fixture.cs
new file mode 100644
index 00000000000..3f8123d48c3
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2714/Fixture.cs
@@ -0,0 +1,65 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2714
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ private const int ExtraId = 500;
+
+ protected override void OnTearDown()
+ {
+ using (ISession s = OpenSession())
+ {
+ s.Delete($"from {nameof(Item)}");
+ s.Flush();
+ s.Delete($"from {nameof(Information)}");
+ s.Flush();
+ }
+ }
+
+ [Test]
+ public void PropertyRefUsesOtherColumns()
+ {
+ var information = new Information {Name = "First", ExtraId = ExtraId};
+
+ var item = new Item {Id = 1, Name = information.Name, ExtraId = information.ExtraId};
+
+ using (ISession session = OpenSession())
+ {
+ session.Save(information);
+ session.Save(item);
+ session.Flush();
+ }
+
+ using (ISession session = OpenSession())
+ {
+ var otherInformation = session.Get(information.Id);
+ Assert.That(otherInformation.Items.Count, Is.EqualTo(1));
+ }
+ }
+
+ [Test]
+ public void ChildKeyPropertiesOfParentAreRetrieved()
+ {
+ var information = new Information {Name = "First", ExtraId = ExtraId};
+
+ var item = new Item {Id = 1, Name = information.Name, ExtraId = information.ExtraId};
+
+ using (ISession session = OpenSession())
+ {
+ session.Save(information);
+ session.Save(item);
+ session.Flush();
+ }
+
+ using (ISession session = OpenSession())
+ {
+ var otherInformation = session.Get(information.Id);
+
+ Assert.That(otherInformation.Name, Is.EqualTo(information.Name));
+ Assert.That(otherInformation.ExtraId, Is.EqualTo(information.ExtraId));
+ }
+ }
+ }
+}
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2714/Information.cs b/src/NHibernate.Test/NHSpecificTest/NH2714/Information.cs
new file mode 100644
index 00000000000..fbff5a49650
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2714/Information.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH2714
+{
+ public class Information
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual int ExtraId { get; set; }
+ public virtual ISet- Items { get; set; } = new HashSet
- ();
+ }
+}
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2714/Item.cs b/src/NHibernate.Test/NHSpecificTest/NH2714/Item.cs
new file mode 100644
index 00000000000..db4128a4276
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2714/Item.cs
@@ -0,0 +1,9 @@
+namespace NHibernate.Test.NHSpecificTest.NH2714
+{
+ public class Item
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual int ExtraId { get; set; }
+ }
+}
diff --git a/src/NHibernate.Test/NHSpecificTest/NH2714/Mappings.hbm.xml b/src/NHibernate.Test/NHSpecificTest/NH2714/Mappings.hbm.xml
new file mode 100644
index 00000000000..eb4f07ee80d
--- /dev/null
+++ b/src/NHibernate.Test/NHSpecificTest/NH2714/Mappings.hbm.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/NHibernate/Type/EmbeddedComponentType.cs b/src/NHibernate/Type/EmbeddedComponentType.cs
index 0964217419d..5fe81b36a76 100644
--- a/src/NHibernate/Type/EmbeddedComponentType.cs
+++ b/src/NHibernate/Type/EmbeddedComponentType.cs
@@ -19,9 +19,12 @@ public override bool IsEmbedded
public override object Instantiate(object parent, ISessionImplementor session)
{
- bool useParent= false;
- // NH Different implementation : since we are not sure about why H3.2 use the "parent"
- //useParent = parent != null && base.ReturnedClass.IsInstanceOfType(parent);
+ var useParent =
+ parent != null &&
+ //TODO: Yuck! This is not quite good enough, it's a quick
+ //hack around the problem of having a to-one association
+ //that refers to an embedded component:
+ ReturnedClass.IsInstanceOfType(parent);
return useParent ? parent : base.Instantiate(parent, session);
}