A more easy demo is the result of NHibernate.Linq based in CriteriaAPI.Btw I
don't understand the target of the question...
Criteria is for dynamic queries
HQL is for static queries
The better place for static query is the mapping where you can even set
cache matters (with Criteria the cache is defined inside the code). After
BuildSessionFactory all named queries are translated and prepared
(compiled). HQLs that are not in the mapping will be translated in a MRU
cache (256 queries) so... in general a HQL is translated only one time where
the Criteria is translated each time.
Criteria and HQL are only two ways to do OO-queries, nothing more. The
existing NH-LINQ (in contrib) and the other NH-LINQ (in trunk) are only two
others ways to do OO-queries using NH and nothing more.
Which use ?
The best, for you, for what you are doing in a specific code place.
If you are using Criteria everywhere or you are using HQL everywhere there
is something wrong in your application.
There are some place where you can use HQL only because the query look more
understandable ("the best for you").
In IT not all things are boolean.
2009/5/19 Roger Kratz <[email protected]>
>
> Really? Sure?
>
> I thought it was called the same when returning (possibly a huge amout of)
> duplicated rows due to multiple outer joins, not only when doing cross
> joins. But I'm obviously wrong here...
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf
> Of Stefan Steinegger
> Sent: den 19 maj 2009 13:57
> To: nhusers
> Subject: [nhusers] Re: HQL vs Criterion
>
>
> Roger, this is not a cartesian product, this is a join.
>
> On 19 Mai, 13:50, Ken Egozi <[email protected]> wrote:
> > it creates joins from Foo to everywhere.
> > all with an "ON" clause on the join.
> >
> > SELECT ...
> > FROM Table1, Table2 -- (no join)
> > -- (no rel restricting WHERE)
> >
> > this can be done in HQL, and afaik not in Criteria
> >
> > On Tue, May 19, 2009 at 2:48 PM, Roger Kratz <[email protected]
> >wrote:
> >
> >
> >
> >
> >
> > > << you can not make cartesian products with criteria.>>
> >
> > > ?
> > > aCartesianProduct = s.CreateCriteria(typeof(Foo))
> > > .SetFetchMode("ACollection", FetchMode.Join)
> > > .SetFetchMode("BCollection", FetchMode.Join)
> > > .SetFetchMode("CCollection", FetchMode.Join)
> > > .SetFetchMode("DCollection", FetchMode.Join)
> > > .List<Foo>();
> >
> > > -----Original Message-----
> > > From: [email protected] [mailto:[email protected]] On
> Behalf
> > > Of Stefan Steinegger
> > > Sent: den 19 maj 2009 13:33
> > > To: nhusers
> > > Subject: [nhusers] Re: HQL vs Criterion
> >
> > > Forgot to mention: you can not make cartesian products with criteria.
> > > So you can't select columns from different tables if they don't have a
> > > mapped reference. This could be important for reports or when using
> > > legacy databases.
> >
> > > On 19 Mai, 13:30, Stefan Steinegger <[email protected]> wrote:
> > > > This is not a trivial question at all. I still don't know many
> > > > differences between hql and criteria features, and hope you get some
> > > > good answers here :-)
> >
> > > > AFAIK, you don't have these pseudo-properties or functions like
> > > > elements and class, and you don't have the index operator [] on
> lists.
> >
> > > > I do as much as possible with criteria, because it is more stable
> then
> > > > hql, that is evaluated at runtime. And I have a lot of dynamic
> > > > queries, which would be a pain to build up with hql. I really hope
> > > > that criteria will be as powerful as hql in the future.
> >
> > > > On 19 Mai, 12:18, dnagir <[email protected]> wrote:
> >
> > > > > Hi,
> >
> > > > > I read somewhere that HQL is a bit more powerful that Criteria API.
> >
> > > > > Just wondering what we cannot do in HQL and cannot in Criteria API.
> > > > > And vice versa.
> >
> > > > > I'm very new to NH so soryy of this is too obvious question.
> > > > > For me it looks like Criteria API is much more powerful (though
> > > > > usually requires a bit more code to write) and I like it.
> >
> > > > > Cheers,
> > > > > Dmitriy.
> >
> > --
> > Ken Egozi.
> http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il
>
>
>
> >
>
--
Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---