Skip to content

Commit

Permalink
A possible bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tohidemyname committed Jun 29, 2024
1 parent 7ed5bc8 commit 686abf1
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/NHNewBug/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.NHNewBug
{
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/NHNewBug/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.NHNewBug
{
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/NHNewBug/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.NHNewBug;
*/
using NHibernate.Test.NHSpecificTest;

namespace NHibernate.Test.NHSpecificTest.NHNewBug
{







[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/NHNewBug/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.NHNewBug">

<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/NHNewBug/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.NHNewBug
{
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; }
}
}
}

0 comments on commit 686abf1

Please sign in to comment.