From: <leg...@at...> - 2003-06-11 13:15:22
|
Message: The following issue has been closed. Resolver: Gavin King Date: Wed, 11 Jun 2003 8:15 AM fixed now, with a testcase - this also affected postgres --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-129 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-129 Summary: Query.iterate() using setFirstResult and setMaxResult Type: Bug Status: Closed Priority: Major Resolution: FIXED Project: Hibernate2 Components: core Fix Fors: 2.0.1 Versions: 2.0 final Assignee: Gavin King Reporter: David Howe Created: Wed, 11 Jun 2003 5:49 AM Updated: Wed, 11 Jun 2003 8:15 AM Description: I am getting some strange behaviour when using Query.iterate() with setFirstResult and setMaxResult. When the following code is run, the number of rows returned is the sum of the first result and the max result (ie. 15 rows): Query q = session.createQuery("from com.logicacmg.waf.FixedCode as fixedCode"); q.setFirstResult(5); q.setMaxResults(10); Iterator iter = q.iterate(); while (iter.hasNext()) { // Do the processing } The following SQL statement is generated for the initial query: select fixedcod0_.fixed_code_id as x0_0_ from FIXED_CODE fixedcod0_ limit ?, ? The behaviour of the number of rows returned being the sum of the first result and the max results seems to be consistent. If I remove using the query.iterate() and go back to using a query.list(), everything works perfectly and I get 10 rows i.e.: q.setFirstResult(5); q.setMaxResults(10); iter = q.list().iterator(); while (iter.hasNext()) { // Do the processing } This generates the following SQL: select fixedcod0_.fixed_code_id as fixed_code_id, fixedcod0_.last_updated_sequence as last_upd2_, fixedcod0_.column_name as column_n3_, fixedcod0_.code as code, fixedcod0_.description as descript5_, fixedcod0_.sort_sequence as sort_seq6_, fixedcod0_.CREATED_USER_ID as CREATED_7_, fixedcod0_.CREATED_DT_TM as CREATED_8_, fixedcod0_.LAST_UPDATED_USER_ID as LAST_UPD9_, fixedcod0_.LAST_UPDATED_DT_TM as LAST_UP10_ from FIXED_CODE fixedcod0_ limit ?, ? I am running with Hibernate 2 (just upgraded) and MySQL 3.23. The above code was existing code that worked under Hibernate 1. By: oneovthafew ( Gavin King ) RE: Query.iterate() setFirstResult problem 2003-06-11 01:35 Oh bloody hell this is a pretty bad bug. Damn! ah well ..... Hibernate 2.0.1 here we come.... P.S. you can work around this by overriding supportsLimit() on MySQLDialect. >> If I remove using the query.iterate() and go back to using a query.list(), everything works perfectly and I get 10 rows << yah, the test suite only covers *this* case :( By: oneovthafew ( Gavin King ) RE: Query.iterate() setFirstResult problem 2003-06-11 01:38 please submit this to JIRA TIA I will fix it tonight anyway.... --------------------------------------------------------------------- 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/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |