Lazy collection retrieval should use proxies
--------------------------------------------
Key: NH-855
URL: http://jira.nhibernate.org/browse/NH-855
Project: NHibernate
Type: Improvement
Components: Core =20
Versions: 1.2.0.Beta2 =20
Reporter: Andr=C3=A9s G. Aragoneses
Priority: Minor
Attachments: NHibBugAboutDataRetrieval.zip
When retrieving a lazy collection I've noted that there is much information=
retrieved from the DB that may not be needed. For example, if we only need=
the Count property of the collection, NHibernate retrieves full objects in=
stead of just proxies (object with only the ID property filled).
I am attaching a testcase.
Note the folling C# lines in the testcase:
IList aParameters =3D oSession.CreateCriteria(typeof(Parameter)).List();
if (aParameters.Count =3D=3D 0)
{
return;
}
Parameter oParameter =3D aParameters[0] as Parameter;
//the Group is a proxy object, so this instruction does not retrieve anythi=
ng from DB
int iIdGroup =3D oParameter.Group.Id;
//this instruction unproxies the object because it is filled with its prope=
rties
string sName =3D oParameter.Group.Name;
//why don't we retrieve here only proxies? because we only need to know how=
many rows, their ID's
int iCount =3D oParameter.Group.Terminals.Count;
//if in the last instruction NHibernate would have retrieved proxies instea=
d of full objects
//this instruction would generate a new query
string sName2 =3D oParameter.Group.Terminals[0].Name;
I know that maybe this is a too specific feature and perhaps, to be impleme=
nted, it should be done so by adding a new configuration parameter, for exa=
mple: RetrievalMode.Minimal.
What do you think?
P.S.: You may add the NHib libs to the Lib subdir of the ZIP file attached,=
before building it.
--=20
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.nhibernate.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
|