[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-544) select new ... results in n+1 selects

Adam Skobodzinski (JIRA) noreply at atlassian.com
Tue Mar 29 11:31:08 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=41886#action_41886 ] 

Adam Skobodzinski commented on HHH-544:
---------------------------------------

I was wondering if there are any plans to fix it. Due to n+1 problem it is really not feasible to use the constructor form at the moment. Btw. I am using hibernate 3.6.0

> select new ... results in n+1 selects
> -------------------------------------
>
>                 Key: HHH-544
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-544
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.0.5
>         Environment: Hibernate 3.0.5, Oracle 8i, JDK 1.4.2
>            Reporter: Salvatore Insalaco
>            Priority: Minor
>
> Using collection constructors in select clause of HQL (e.g. new map(...)) generates n + 1 SQL statements (one for primary keys, one for each object).
> This is a problem when there're clauses as "distinct" and "order by":
> select distinct o from MyEntity o order by o.description
> works, because in the generated SQL all the columns are mapped in the select clause; but:
> select distinct new map (o as result) from MyEntity o order by o.description
> doesn't work, because the first line of generated SQL is like:
> select distinct id from MyTable order by description
> and that's invalid sql (at least in Oracle): description shoud be placed in select clause.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list