-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Exception when RowSelection.setMaxRows == INTEGER.MAX_VALUE
PostPosted: Fri Jul 10, 2009 5:38 am 
Newbie

Joined: Fri Jul 10, 2009 5:09 am
Posts: 1
When I limit a query by setting the maximum rows to INTEGER.MAX_VALUE and set a first row > 0, (I admit that's not very "limiting") the following messages are logged:

    2009-07-10 10:43:43,348 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 20000, SQLState: XJ063
    2009-07-10 10:43:43,348 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Invalid parameter value '-2,147,483,647' for
    Statement.setMaxRows(int maxRows). Parameter value must be >= 0.

By debugging I ended up in /core/trunk/core/src/main/java/org/hibernate/loader/Loader.java in the setMaxRows method where

    RowSelection.maxRows == INTEGER.MAX_VALUE and RowSelection.firstRow == 2

Here is the code for our revision (3.3.0 SP1):
Code:
   private void setMaxRows(
         final PreparedStatement st,
         final RowSelection selection) throws SQLException {
      if ( hasMaxRows( selection ) ) {
         st.setMaxRows( selection.getMaxRows().intValue() + getFirstRow( selection ) );
      }
   }

Revision 17061 is almost the same:
Code:
   private void setMaxRows(
         final PreparedStatement st,
         final RowSelection selection) throws SQLException {
      if ( hasMaxRows( selection ) ) {
         st.setMaxRows( selection.getMaxRows().intValue() + interpretFirstRow( getFirstRow( selection ) ) );
      }
   }

The by adding RowSelection.maxRows and RowSelection.firstRow, int data type overflows to a negative value and setMaxRows of course complains.

I didn't find this behavior mentioned in the forums or JIRA.

Larry


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.