SubselectFetch doesn't take into account paging
Description
Environment
Activity

Dawid Ciecierski May 17, 2014 at 9:37 AM
Still seeing similar behaviour with the latest stable, 3.3.3SP1. Related: NH-2296, NH-3616.

AgrineiS November 1, 2010 at 8:26 PM
The problem still exists in 3.0.0_Beta2.
I've created a test case to demonstrate the issue:
[Test]
public void SubselectFetchPaging()
{
ISession s = OpenSession();
ITransaction t = s.BeginTransaction();
for (int i = 0; i < 10; i++)
{
string pName = "p" + i.ToString().PadLeft(2, '0');
Parent p = new Parent(pName);
for (int j = 0; j < 10; j++)
{
string cName = pName + '_' + j.ToString().PadLeft(2, '0');
p.Children.Add(new Child(cName));
}
s.Save(p);
}
t.Commit();
s.Close();
s = OpenSession();
t = s.BeginTransaction();
sessions.Statistics.Clear();
IList parents = s.CreateCriteria(typeof(Parent))
.SetFirstResult(3)
.SetMaxResults(4)
.List();
Parent px = (Parent)parents[0];
int childCount = px.Children.Count;
Assert.AreEqual(10, childCount);
// We should have 44 entities loaded ( 4 parents + 40 children ) but
// currently it loads 104 entities ( 4 parents and 100 (ALL) children )
Assert.AreEqual(44, sessions.Statistics.EntityLoadCount);
parents = s.CreateCriteria(typeof(Parent)).List();
foreach (Parent pToDelete in parents)
{
s.Delete(pToDelete);
}
t.Commit();
s.Close();
}

Fabio Maulo October 13, 2010 at 5:11 AM
Same... it was re-resolved in 3.0.0AlphaX

Fabio Maulo November 10, 2008 at 5:31 AM
Patch reverted because break all Dialect are supporting "variable-limits".

Former user September 29, 2007 at 11:51 PM
Reopening to fix in 1.2.1
Details
Details
Assignee
Reporter

See for a description of the problem.
Basically, this turn the subselect into too eager, potentially loading great amounts of data needlessly.