-->
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: ScrollableResults flush causes data download
PostPosted: Wed Apr 13, 2011 1:05 pm 
Newbie

Joined: Wed Apr 13, 2011 12:42 pm
Posts: 1
Hello,

I'm using MS SQL server 2008.

I'm trying to modify a table with millions of rows of data using ScrollableResults. With a "regular" session.
The problem is that doing a flush ends with a out of memory error, even when I do the flush after changing the first row.
From the network activity, it seems that my application starts to download data while the flush() is executing.

If I don't change any data and just scroll through the rows, the problem does not occur (probably due to the fact, that there is nothing to flush). Memory usage stays low.

Using a StatelessSession seems to also fix the problem, allowing me to change data. Why is flushing downloading all this data, is there a setting or a bug I should know about?

Code:
ScrollableResults results = session.createQuery("SELECT user FROM User user")
            .setReadOnly(false).setCacheable(false).scroll(ScrollMode.FORWARD_ONLY);

while (results.next()) {
   User user = (User)results.get()[0];
   
   user.setComment("Testing");

   session.flush();
   session.clear();
}


the last line in the log is

DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1

edit: it seems that changing the ScrollMode.FORWARD_ONLY TO ScrollMode.SCROLL_SENSITIVE OR ScrollMode.SCROLL_INSENSITIVE did the trick and now it does not hang on flushing.
From debugging I can see that the select query that hibernate does in the 2 modes takes much longer to complete.

I still don't understand why it behaves like this and can't find a decent description of the varios scrollmodes. (SCROLL_INSENSITIVE scrolls a snapshot?)


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.