Skip to content

Commit 9b48a2e

Browse files
committed
Unit Test for #2614
Polymorphic query with limit
1 parent c7accf3 commit 9b48a2e

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Collections;
2+
using System.Threading.Tasks;
3+
using NUnit.Framework;
4+
5+
namespace NHibernate.Test.NHSpecificTest.GH2614
6+
{
7+
public class Fixture : BugTestCase
8+
{
9+
[Test]
10+
public async Task TestOk()
11+
{
12+
using (ISession s = OpenSession())
13+
{
14+
using (ITransaction t = s.BeginTransaction())
15+
{
16+
try
17+
{
18+
{
19+
s.Save(new ConcreteClass1 {Name = "C1"});
20+
s.Save(new ConcreteClass2 {Name = "C2"});
21+
}
22+
{
23+
var query = s.CreateQuery(@"
24+
SELECT Name FROM NHibernate.Test.NHSpecificTest.GH2614.BaseClass ROOT");
25+
query.SetMaxResults(5);
26+
IList listAsync = await query.ListAsync();
27+
Assert.AreEqual(2, listAsync.Count);
28+
Assert.AreEqual(2, query.List().Count);
29+
}
30+
}
31+
finally
32+
{
33+
s.Delete("from ConcreteClass1");
34+
s.Delete("from ConcreteClass2");
35+
t.Commit();
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
3+
namespace="NHibernate.Test.NHSpecificTest.GH2614"
4+
assembly="NHibernate.Test"
5+
>
6+
<class name="ConcreteClass1" >
7+
<id name="Id">
8+
<generator class="increment"/>
9+
</id>
10+
<property name="Name"/>
11+
</class>
12+
13+
<class name="ConcreteClass2" >
14+
<id name="Id">
15+
<generator class="increment"/>
16+
</id>
17+
<property name="Name"/>
18+
</class>
19+
20+
</hibernate-mapping>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
3+
namespace NHibernate.Test.NHSpecificTest.GH2614
4+
{
5+
public abstract class BaseClass
6+
{
7+
public virtual int Id { get; set; }
8+
public virtual string Name { get; set; }
9+
}
10+
11+
public class ConcreteClass1 : BaseClass
12+
{
13+
}
14+
15+
public class ConcreteClass2 : BaseClass
16+
{
17+
}
18+
}

0 commit comments

Comments
 (0)