Skip to content

Commit c6640f2

Browse files
tohidemynamehazzik
tohidemyname
authored andcommitted
A possible bug
1 parent a998c11 commit c6640f2

File tree

5 files changed

+165
-0
lines changed

5 files changed

+165
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace NHibernate.Test.NHSpecificTest.NHNewBug
8+
{
9+
public class Child
10+
{
11+
private int id;
12+
public virtual int Id
13+
{
14+
get { return id; }
15+
set { id = value; }
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using NHibernate.UserTypes;
7+
8+
namespace NHibernate.Test.NHSpecificTest.NHNewBug
9+
{
10+
public class ContainedChild
11+
{
12+
private int id;
13+
public virtual int Id
14+
{
15+
get { return id; }
16+
set { id = value; }
17+
}
18+
private Child child;
19+
20+
public ContainedChild()
21+
{
22+
}
23+
24+
public ContainedChild(Child child)
25+
{
26+
this.child = child;
27+
}
28+
29+
public virtual Child Child
30+
{
31+
get { return child; }
32+
set { child = value; }
33+
}
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using NUnit.Framework;
8+
9+
/* 项目“NHibernate.Test (net48)”的未合并的更改
10+
在此之前:
11+
using NHibernate.Test.NHSpecificTest;
12+
在此之后:
13+
using NHibernate.Test.NHSpecificTest;
14+
using NHibernate;
15+
using NHibernate.Test;
16+
using NHibernate.Test.MappingTest;
17+
using NHibernate.Test.NHSpecificTest.NHNewBug;
18+
*/
19+
using NHibernate.Test.NHSpecificTest;
20+
21+
namespace NHibernate.Test.NHSpecificTest.NHNewBug
22+
{
23+
24+
25+
26+
27+
28+
29+
30+
[TestFixture]
31+
internal class ManyToOneFixture : BugTestCase
32+
{
33+
[Test]
34+
public void AccessIdOfManyToOneInEmbeddable()
35+
{
36+
ISession s = OpenSession();
37+
ITransaction t = s.BeginTransaction();
38+
Parent p = new Parent();
39+
p.ContainedChildren.Add(new ContainedChild(new Child()));
40+
s.Persist(p);
41+
t.Commit();
42+
var list = s.CreateQuery("from Parent p join p.ContainedChildren c where c.Child.Id is not null").List();
43+
Assert.AreNotEqual(0, list.Count);
44+
s.Delete(p);
45+
t.Commit();
46+
s.Close();
47+
}
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
3+
assembly="NHibernate.Test"
4+
namespace="NHibernate.Test.NHSpecificTest.NHNewBug">
5+
6+
<class name="Child">
7+
<id name="Id">
8+
<generator class="native" />
9+
</id>
10+
</class>
11+
12+
<class name="ContainedChild">
13+
<id name="Id">
14+
<generator class="native" />
15+
</id>
16+
<many-to-one name="Child" cascade="all" not-null="true" />
17+
</class>
18+
19+
<class name="Parent">
20+
<id name="Id">
21+
<generator class="native"/>
22+
</id>
23+
<many-to-one name="ContainedChild" cascade="all" />
24+
<set name="ContainedChildren" inverse="true" cascade="all">
25+
<key column="Parent" />
26+
<one-to-many class="ContainedChild" />
27+
</set>
28+
</class>
29+
30+
31+
</hibernate-mapping>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace NHibernate.Test.NHSpecificTest.NHNewBug
8+
{
9+
public class Parent
10+
{
11+
private int id;
12+
private ContainedChild containedChild;
13+
private ISet<ContainedChild> containedChildren = new HashSet<ContainedChild>();
14+
15+
public virtual int Id
16+
{
17+
get { return id; }
18+
set { id = value; }
19+
}
20+
21+
public virtual ContainedChild ContainedChild
22+
{
23+
get { return containedChild; }
24+
set { containedChild = value; }
25+
}
26+
public virtual ISet<ContainedChild> ContainedChildren
27+
{
28+
get { return containedChildren; }
29+
set { containedChildren = value; }
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)