FetchMode.SubSelect - in addition to the mapping-level fetch mode of sub select
Description
Environment
Attachments
- 03 Sep 2010, 06:02 AM
- 02 Sep 2010, 04:14 PM
Activity
ns December 1, 2010 at 1:46 PM
Could you please explain the downside?
ns October 28, 2010 at 10:07 PM
Whats the downside of it?
it lets you easily solve the problem of fetching all the children of a root entity in some business proccesses, when in others you don't want this behaviour.
there isn't too much work to do per session, because its not something that should happen all the time, but only in rare cases when the batch size should be overriden, it is will be possible to do something dirtier to give a performance boost.
Fabio Maulo October 23, 2010 at 1:18 PM
I would avoid the apply of this kind of things at least for NH3.
I don't think that the "variable batch-fetch-size" per session per association is a nice idea, there is too much work to do per each session.
The issue and the patch can be useful for some personal fork or for some future NH versions.
ns October 14, 2010 at 10:54 AM
hi fabio, could the patch (the updated one) be applied soon?
ns September 3, 2010 at 6:02 AM
the updated patch has few additions like strongly typed collection batch size setting, and a bit more documentation
today there's a fetch="subselect" option that can be set via the hbm.
it cannot be overriden with fetchmode lazy, which makes it hard to use if fetch mode is only neccessary in some situations.
also, the query generated by this looks like this
first query over the father entities - lets call it q1, and lets say its where clause is w1
second query:
from Children c
where c.Father.Id in (select Id from Fathers where w1)
the problem with this (in addition to the not-overridable-with-regular-laziness) is
that w1 might have sub selects and joins, making the second query very inefficient.
NHibernate could in theory take the ids of the fathers from the first query and create the following query
from Children c
where c.Father.Id in (x1,x2,x3...) // x1,x2... the ids returned by the query over the fathers
making this very efficient.
having a FetchMode.SubSelect can help easily get a whole object graph, by setting the subselect fetch mode for a given criteria\hql query\linq query\any other query object for a set (or all) of the associations of the root entity.
It sounds like not very trivial task, but a very helpful one.