The following comment has been added to this issue:
Author: Paul Rivers
Created: Wed, 6 Aug 2003 4:25 PM
Body:
No, it's not fixed. I'm looking directly at the documentation for 2.0.2
The FIRST entry under section 9.13 is correct, it says:
You can count the number of query results without actually returning them:
( (Integer) session.iterate("select count(*) from ....").next() ).intValue()
The LAST entry under 9.13 says:
You can find the size of a collection without initializing it:
Integer size = (Integer) s.filter( collection, "select count(*)" ).get(0);
Perhaps these are duplicates? Either way, the SECOND listed way is incorrect. (And I am looking at the documentation provided with 2.0.2 - it also exists on the hibernate website docs - http://hibernate.bluemars.net/hib_docs/reference/html/query-language.html#query-language-s11)
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-238
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-238
Summary: Documentation Bug - Retrieving the size of a collection
Type: Improvement
Status: Closed
Priority: Trivial
Resolution: FIXED
Project: Hibernate2
Components:
core
Fix Fors:
2.0.2
Versions:
2.0.2
Assignee:
Reporter: Paul Rivers
Created: Wed, 6 Aug 2003 2:23 PM
Updated: Wed, 6 Aug 2003 3:52 PM
Description:
In the documentation in section 9.13, the is says:
You can count the number of query results without actually returning them:
Integer size = (Integer) s.filter( collection, "select count(*)" ).get(0);
The query, session.filter() returns a collection, not a list! So the call to .get(0) results in a compile error. Instead, the correct way to do it is listed in the faq:
( (Integer) s.createFilter( collection, "select count(*)" ).iterate().next() ).intValue()
---------------------------------------------------------------------
JIRA INFORMATION:
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
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|