[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2430) select count(a), a fom Entity a where a.class in (Entity,EntitySubclass)

jose (JIRA) noreply at atlassian.com
Fri Feb 16 19:37:47 EST 2007


select count(a),a fom Entity a where a.class in (Entity,EntitySubclass)
-----------------------------------------------------------------------

         Key: HHH-2430
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2430
     Project: Hibernate3
        Type: Bug

 Environment: HHH-3.2.x (Sybase)
    Reporter: jose



select count(c),c fom Child c 
inner join fetch c.parent
inner join fetch c. mother
where c.class in (Child,ChildSubclass) 

sql syntax error: duplicate IDs in SELECT clause for Child entity and all fetched relations (not collection)

Exist any formula to get a rowcount() to a named query? (without writing new query and without Criteria API)

   myNamedQuery.count()  -> possible solution: select count(*) from (SQL_OF_NAMED_QUERY)

Inefficient solution: query.scroll().last().getRowNumber(); 

note: as most drivers (including Oracle, MySQL...) basically read all the data on the client side in order 
to calculate the number of rows.

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