That is the native pagination of MsSQL (FirstOrDefault is the cause)...Probably
we can change the dialect in order to use only "TOP" when the MaxResults is
not set.

2009/2/27 Peter Morris <[email protected]>

>
> Here is the SQL generated:
>
> SELECT TOP 1 ID1_0_, Title1_0_, Body1_0_, PostedOn1_0_ FROM (SELECT
> ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.ID1_0_,
> query.Title1_0_, query.Body1_0_, query.PostedOn1_0_,
> query.__hibernate_sort_expr_0__ FROM (SELECT this_.ID as ID1_0_,
> this_.Title
> as Title1_0_, this_.Body as Body1_0_, this_.PostedOn as PostedOn1_0_,
> CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM BlogEntries this_ WHERE
> this_.ID = @p0) query ) page WHERE page.row > 0 ORDER BY
> __hibernate_sort_expr_0__
>
>
> This is the LINQ I use.
>
> return session.Linq<BlogEntry>().Where(entry => entry.ID ==
> id).FirstOrDefault();
>
>
> and here is the mapping for BlogEntry...
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"
> assembly="PeterLeslieMorris.Domain" namespace="PeterLeslieMorris.Domain">
>  <class name="BlogEntry" lazy="false" table="BlogEntries">
>    <id name="ID" access="nosetter.lowercase">
>      <generator class="native"/>
>    </id>
>    <property name="Title" column="Title" access="nosetter.camelcase"/>
>    <property name="Body" column="Body" access="nosetter.camelcase"/>
>    <property name="PostedOn" column="PostedOn" access="nosetter.camelcase"
> />
>    <set name="comments" access="field" cascade="all-delete-orphan"
> inverse="true">
>      <key column="BlogEntry"/>
>      <one-to-many class="Comment"/>
>    </set>
>  </class>
> </hibernate-mapping>
>
> Why am I seeing such a bizarre SQL statement?
>
>
> Pete
> ====
> http://mrpmorris.blogspot.com
>
>
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to