-->
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.  [ 5 posts ] 
Author Message
 Post subject: ScrollableResults
PostPosted: Wed Nov 19, 2008 3:24 am 
Newbie

Joined: Wed Nov 12, 2008 8:21 am
Posts: 4
Hi I am having problems with ScrollableResults. It appears to me that hibernate is not scrolling throught the results and is instead fetching everything into memory at once.

Does any body know why this may be happening. I am using Hibernate 3.2.6 with mysql Ver 14.12 Distrib 5.0.45,
and mysql-connector-java-5.1.7-bin.jar.

My query looks like this

Code:
return logReadOnlySession.createQuery(
   "from AuditLog as agentLog" +
   " where agentLog.timestamp" +
   " between :startTime and :endTime" +
   " order by agentLog.userID")
   .setLong("startTime", summary.getStartTime())
   .setLong("endTime", summary.getEndTime())
   .setCacheMode(CacheMode.IGNORE)
   .setFetchSize(AUDIT_LOGS_FETCH_SIZE)
   .scroll(ScrollMode.FORWARD_ONLY);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 5:42 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I think it's the JDBC driver that does this. We had lots of problems with this until MySQL implemented cursors on the server. But this requires some special settings in the connection url. Here is what we have:

Code:
jdbc:mysql://localhost/dbname?useCursorFetch=true&defaultFetchSize=100&useServerPrepStmts=true


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 8:23 am 
Newbie

Joined: Wed Nov 12, 2008 8:21 am
Posts: 4
I have always specified a fetch size when suing scrollableResults do you think defaultFetchSize=100 is neccesary then. Also is useServerPrepStmts=true useful?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 8:27 am 
Newbie

Joined: Wed Nov 12, 2008 8:21 am
Posts: 4
One more thing, how can I know that the cursor is working fine as of now. Thanks a tonne again.

Parag


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 8:42 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
We had memory problems with the MySQL JDBC driver. After adding the three options to the connection string the problem has gone away. I recall that we didn't have useServerPrepStmts=true at first, but at some time we needed to add that also. It was some time ago, so I don't remember all the details, but it may have because of different default values depending on MySQL version.


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

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.