Issue Details (XML | Word | Printable)

Key: DERBY-3397
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dag H. Wanvik
Reporter: Michael Lossos
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Derby 10.3.1.4 and 10.3.2.1 break scrollable result sets? Hibernate Query.setFirstResult and/or setMaxResults

Created: 08/Feb/08 06:28 AM   Updated: 30/Jun/09 03:55 PM
Return to search
Component/s: JDBC
Affects Version/s: 10.3.1.4, 10.3.2.1, 10.4.2.0, 10.5.1.1
Fix Version/s: 10.4.2.0, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-3397-2a-junit_reg_test.diff 2008-04-22 09:22 AM Kristian Waagan 2 kB
Zip Archive Licensed for inclusion in ASF works DERBY-3397-reproduction-case.zip 2008-04-16 04:37 PM Michael Lossos 8.00 MB
File Licensed for inclusion in ASF works derby-3397.diff 2008-04-20 05:07 PM Dag H. Wanvik 0.5 kB
Environment: Derby 10.3.1.4 and 10.3.2.1, Hibernate 3.2.5

Urgency: Normal
Bug behavior facts: Regression
Resolution Date: 01/May/08 08:54 PM


 Description  « Hide
I am attempting to upgrade our product from Derby 10.2.2.0 to 10.3.2.1. With all other things held constant, if I change the derby.jar from 10.2.2 to 10.3.2.1, our calls to set the (JDBC) first result and max results (max rows) no longer function properly, such that no results are returned beyond first result 200, max results 100 (max rows 300), even when the table has over 1000 rows. 2 of the 11 columns of this table are indexed

We use Hibernate's result pagination via Query.setFirstResult and setMaxResults which, in org.hibernate.loader.Loader.advance(), uses java.sql.ResultSet.advance when scrollable result sets are available, and as expected org.apache.derby.impl.jdbc.EmbedDatabaseMetaData reports that scrollable result sets are available for both Derby 10.2.2 and 10.3.2.1.

The following is pseudo code for what we're doing with Hibernate:

int pageSize = 100;
int count = ... // select count(*) from OURTABLE;
for( int firstResult = 0; firstResult < count; firstResult += pageSize) {
        Query query = session.createQuery( "from OurHibernateObject"); // select * from OURTABLE
        query.setFirstResult( firstResult );
        query.setMaxResults( pageSize );
        List objList = query.list();
        // results are fine for firstResult 100 and 200,
        // but beyond that no results are returned with a >1000 row table!
}

When settings max results, Hibernate correctly sets max rows as follows from org.hibernate.loader.Loader.setMaxRows:

st.setMaxRows( selection.getMaxRows().intValue() + getFirstRow( selection ) );

Which is calling into org.apache.derby.impl.jdbc.EmbedPreparedStatement40. This code path doesn't change between Derby 10.2.2 and 10.3.2.1.

I've tried completely recreating the database to remove any possible problems with soft / full upgrades, but this didn't fix the problem. I tried 10.3.1.4 but this also exhibits the bug.

This seems like a fairly basic regression (surely a Derby test would fail if scrollable results were broken). I'm wondering if there's another factor at work here? Please help me to describe whatever else is necessary for you to reproduce this. (I can't post our table schema or our code.) I apologize in advance if this our own mistake but as I said, I'm only updating the derby.jar.

Thanks for all the hard work on Derby!


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael Lossos made changes - 16/Apr/08 04:37 PM
Field Original Value New Value
Attachment DERBY-3397-reproduction-case.zip [ 12380309 ]
Dag H. Wanvik made changes - 20/Apr/08 05:07 PM
Attachment derby-3397.diff [ 12380580 ]
Dag H. Wanvik made changes - 20/Apr/08 05:08 PM
Derby Info [Regression] [Patch Available, Regression]
Kristian Waagan made changes - 22/Apr/08 09:22 AM
Attachment derby-3397-2a-junit_reg_test.diff [ 12380674 ]
Kristian Waagan made changes - 22/Apr/08 09:33 AM
Priority Critical [ 2 ] Major [ 3 ]
Derby Info [Regression, Patch Available] [Patch Available, Regression]
Urgency Urgent Normal
Affects Version/s 10.5.0.0 [ 12313010 ]
Affects Version/s 10.4.1.4 [ 12313112 ]
Kristian Waagan made changes - 23/Apr/08 08:48 AM
Fix Version/s 10.5.0.0 [ 12313010 ]
Derby Info [Regression, Patch Available] [Regression]
Assignee Dag H. Wanvik [ dagw ]
Kristian Waagan made changes - 01/May/08 08:54 PM
Fix Version/s 10.4.1.4 [ 12313112 ]
Resolution Fixed [ 1 ]
Fix Version/s 10.3.2.2 [ 12312885 ]
Status Open [ 1 ] Resolved [ 5 ]
Rick Hillegas made changes - 04/Aug/08 08:24 PM
Fix Version/s 10.4.1.4 [ 12313112 ]
Fix Version/s 10.4.2.0 [ 12313345 ]
Fix Version/s 10.3.3.0 [ 12313142 ]
Myrna van Lunteren made changes - 04/May/09 06:22 PM
Fix Version/s 10.5.0.0 [ 12313010 ]
Fix Version/s 10.5.1.1 [ 12313771 ]
Affects Version/s 10.5.0.0 [ 12313010 ]
Affects Version/s 10.5.1.1 [ 12313771 ]
Dag H. Wanvik made changes - 30/Jun/09 03:55 PM
Bug behavior facts [Regression]