Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A possible bug #3568

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using NUnit.Framework;

/* 项目“NHibernate.Test (net48)”的未合并的更改
在此之前:
using NHibernate.Test.NHSpecificTest;
在此之后:
using NHibernate.Test.NHSpecificTest;
using NHibernate;
using NHibernate.Test;
using NHibernate.Test.MappingTest;
using NHibernate.Test.NHSpecificTest.GH3569;
*/
using NHibernate.Test.NHSpecificTest;

namespace NHibernate.Test.NHSpecificTest.GH3569
{







[TestFixture]
internal class ManyToOneFixtureAsync : BugTestCase
{
[Test]
public async Task AccessIdOfManyToOneInEmbeddableAsync()
{
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
Parent p = new Parent();
p.ContainedChildren.Add(new ContainedChild(new Child()));
await (s.PersistAsync(p));
await (t.CommitAsync());
var list = await (s.CreateQuery("from Parent p join p.ContainedChildren c where c.Child.Id is not null").ListAsync());
Assert.AreNotEqual(0, list.Count);
await (s.DeleteAsync(p));
await (t.CommitAsync());
s.Close();
}
}
}
18 changes: 18 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3569/Child.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NHibernate.Test.NHSpecificTest.GH3569
{
public class Child
{
private int id;
public virtual int Id
{
get { return id; }
set { id = value; }
}
}
}
35 changes: 35 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3569/ContainedChild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NHibernate.UserTypes;

namespace NHibernate.Test.NHSpecificTest.GH3569
{
public class ContainedChild
{
private int id;
public virtual int Id
{
get { return id; }
set { id = value; }
}
private Child child;

public ContainedChild()
{
}

public ContainedChild(Child child)
{
this.child = child;
}

public virtual Child Child
{
get { return child; }
set { child = value; }
}
}
}
49 changes: 49 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3569/ManyToOneFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using NUnit.Framework;

/* 项目“NHibernate.Test (net48)”的未合并的更改
在此之前:
using NHibernate.Test.NHSpecificTest;
在此之后:
using NHibernate.Test.NHSpecificTest;
using NHibernate;
using NHibernate.Test;
using NHibernate.Test.MappingTest;
using NHibernate.Test.NHSpecificTest.GH3569;
*/
using NHibernate.Test.NHSpecificTest;

namespace NHibernate.Test.NHSpecificTest.GH3569
{







[TestFixture]
internal class ManyToOneFixture : BugTestCase
{
[Test]
public void AccessIdOfManyToOneInEmbeddable()
{
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
Parent p = new Parent();
p.ContainedChildren.Add(new ContainedChild(new Child()));
s.Persist(p);
t.Commit();
var list = s.CreateQuery("from Parent p join p.ContainedChildren c where c.Child.Id is not null").List();
Assert.AreNotEqual(0, list.Count);
s.Delete(p);
t.Commit();
s.Close();
}
}
}
31 changes: 31 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3569/Mappings.hbm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.GH3569">

<class name="Child">
<id name="Id">
<generator class="native" />
</id>
</class>

<class name="ContainedChild">
<id name="Id">
<generator class="native" />
</id>
<many-to-one name="Child" cascade="all" not-null="true" />
</class>

<class name="Parent">
<id name="Id">
<generator class="native"/>
</id>
<many-to-one name="ContainedChild" cascade="all" />
<set name="ContainedChildren" inverse="true" cascade="all">
<key column="Parent" />
<one-to-many class="ContainedChild" />
</set>
</class>


</hibernate-mapping>
32 changes: 32 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3569/Parent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NHibernate.Test.NHSpecificTest.GH3569
{
public class Parent
{
private int id;
private ContainedChild containedChild;
private ISet<ContainedChild> containedChildren = new HashSet<ContainedChild>();

public virtual int Id
{
get { return id; }
set { id = value; }
}

public virtual ContainedChild ContainedChild
{
get { return containedChild; }
set { containedChild = value; }
}
public virtual ISet<ContainedChild> ContainedChildren
{
get { return containedChildren; }
set { containedChildren = value; }
}
}
}