Why no enumeration over criterias and sql-queries?

264 views
Skip to first unread message

ajaishankar

unread,
Dec 12, 2009, 11:57:55 AM12/12/09
to nhusers
Why isn't there a Enumerate for Criteria queries?

Also enumeration over a sql-query is currently not implemented!

I think it would be extremely useful to have these to enable ETL kind
of processing using NH for large data sets.

That way we could use NH to build queries using detached criteria and
do fancy SSIS kind of stuff like merge joins etc in code/Linq.

By enabling these we could have a good alternative to crappy products
like SSIS...

Thanks

Ajai

Jason Meckley

unread,
Dec 12, 2009, 3:12:34 PM12/12/09
to nhusers
If you want ETL without SSIS look into Rhino.ETL (http://github.com/
ayende/rhino-etl). NH is meant to be an ETL framework it's an ORM.

ajaishankar

unread,
Dec 12, 2009, 5:01:46 PM12/12/09
to nhusers
I understand - but is there a particular reason for not enabling
enumerable over criteria or sql queries?

I feel the querying + data to object mapping capabilities combined
with streaming result behavior will be quite useful.

Unless I'm missing something, not being able to enumerate over the
results of a criteria seems to be an artificial restriction.

Ajai

Fabio Maulo

unread,
Dec 13, 2009, 9:22:13 AM12/13/09
to nhu...@googlegroups.com
Not so "artificial" if you think that you can traverse an obj graph, activating lazy load, for each iteration...
Activating multi-opened-resultset for MsSQL2008 perhaps we can implement it... for all others dialects I'm not so sure.

2009/12/12 ajaishankar <ajai.s...@gmail.com>
--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.





--
Fabio Maulo

Jason Meckley

unread,
Dec 13, 2009, 9:23:02 AM12/13/09
to nhusers
var objects = session.CreateCriteria().Add().List();
foreach(var obj in objects)
{
> > > Ajai- Hide quoted text -
>
> - Show quoted text -

ajaishankar

unread,
Dec 13, 2009, 10:10:02 AM12/13/09
to nhusers
Thanks!

I think Enumeration is currently enabled for HQL queries; looking at
QueryTranslator & NHibernate.Impl.EnumerableImpl

Wouldn't the lazy-load Fabio explained affect that too?

Not trying to argue here - just getting an understanding...

Couldn't the burden of eager fetching be offloaded to the user since
enumerating might be a "specialized" usage?

Ajai

Fabio Maulo

unread,
Dec 13, 2009, 10:12:50 AM12/13/09
to nhu...@googlegroups.com
If I well remember that impl. is only a mirage ;) (not a real enumerable where each row is converted only during enumeration).

2009/12/13 ajaishankar <ajai.s...@gmail.com>
--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.





--
Fabio Maulo

ajaishankar

unread,
Dec 13, 2009, 10:46:29 AM12/13/09
to nhusers
Pulling this in reflector:

SessionImpl.Enumeration()
HQLQueryPlan.DoIterate
NHibernate.Hql.Classic.QueryTranslator.GetEnumerable()

What is currently returned is a true enumerable :-)

If I wanted to request this feature (enumeration for criteria & sql
query) which group would I need to post to?

The scenario I have where this would be super useful is:

http://groups.google.com/group/nhusers/browse_thread/thread/8ba75a088ae58d0e/2c9ca99ba33851da#2c9ca99ba33851da

Ajai

On Dec 13, 9:12 am, Fabio Maulo <fabioma...@gmail.com> wrote:
> If I well remember that impl. is only a mirage ;) (not a real enumerable
> where each row is converted only during enumeration).
>
> 2009/12/13 ajaishankar <ajai.shan...@gmail.com>
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > .

Fabio Maulo

unread,
Dec 13, 2009, 11:25:50 AM12/13/09
to nhu...@googlegroups.com
Yes it is but not for that line... 
we are truly wrapping the datareader inside the QueryLoader, btw I never have tested it to check the behaviour initializing some lazyloading relationship.
If you have time please try it.
Thanks.

2009/12/13 ajaishankar <ajai.s...@gmail.com>
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.





--
Fabio Maulo

ajaishankar

unread,
Dec 13, 2009, 1:40:55 PM12/13/09
to nhusers
Tried it - surprisingly lazy loading worked without problems!

Like you said it is a mirage :-)

Think the SqlDataReader is wrapped in a Driver.NDataReader which loads
everything into an internal list!

So ultimately even calling Enumerable loads everything in memory - no
way to stream results currently in NH :-(

Thanks

Ajai

On Dec 13, 10:25 am, Fabio Maulo <fabioma...@gmail.com> wrote:
> Yes it is but not for that line...
> we are truly wrapping the datareader inside the QueryLoader, btw I never
> have tested it to check the behaviour initializing some lazyloading
> relationship.
> If you have time please try it.
> Thanks.
>
> 2009/12/13 ajaishankar <ajai.shan...@gmail.com>
>
>
>
> > Pulling this in reflector:
>
> > SessionImpl.Enumeration()
> >   HQLQueryPlan.DoIterate
> >       NHibernate.Hql.Classic.QueryTranslator.GetEnumerable()
>
> > What is currently returned is a true enumerable :-)
>
> > If I wanted to request this feature (enumeration for criteria & sql
> > query) which group would I need to post to?
>
> > The scenario I have where this would be super useful is:
>
> >http://groups.google.com/group/nhusers/browse_thread/thread/8ba75a088...
> > <nhusers%2Bunsu...@googlegroups.com<nhusers%252Buns...@googlegroups.com>

Fabio Maulo

unread,
Dec 13, 2009, 6:17:21 PM12/13/09
to nhu...@googlegroups.com
Ah ok... The IEnumerable is only a mirage

2009/12/13 ajaishankar <ajai.s...@gmail.com>
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.





--
Fabio Maulo

Reply all
Reply to author
Forward
0 new messages