-->
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.  [ 7 posts ] 
Author Message
 Post subject: How can I flush the session cache?
PostPosted: Wed Jul 20, 2005 4:15 am 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
My understanding is calling Session.flush() will cause it to commit transaction, but what if I want to flush the session's cache? As a matter of fact, what if I want to disable that cache completely?

It's just that the program I'm working on stores huges amounts of data into database, but it's not performance-focused, so I chose to use Hibernate, but I'm worried that it will keep storing up stuff in session's cache and give me an out of memory exception..

thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 6:34 am 
Beginner
Beginner

Joined: Fri Feb 11, 2005 12:03 pm
Posts: 48
Location: Kiel, Germany
The javadoc of Session.flush() says
Quote:
Force the Session to flush. Must be called at the end of a unit of work, before commiting the transaction and closing the session (Transaction.commit() calls this method). Flushing is the process of synchronising the underlying persistent store with persistable state held in memory.


So it is just the other way round: the commit includes Session.flush()

You cannot disable the first-level-cache (the Session).

If you want to clear the first-level-cache use Session.clear().


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 5:03 pm 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
Oh thanks!

Is there any documentation on how big the session cache will grow? Maybe I won't have to do it at all..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 2:13 am 
Beginner
Beginner

Joined: Fri Feb 11, 2005 12:03 pm
Posts: 48
Location: Kiel, Germany
According to this article from Gavin the size of the Session is not limited:

http://blog.hibernate.org/cgi-bin/blosxom.cgi/Gavin%20King/batch.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 3:08 pm 
Newbie

Joined: Thu Aug 11, 2005 3:01 pm
Posts: 2
Location: Salt Lake City, Utah, USA
I'm running into memory problems, and this older thread might be a place to discuss.

My program chews through a large database, and verifies a bunch of data. I never commit anything. I would love to disable the cache, but it seems I cannot. So instead, I implemented the Session.clear() as described in this thread.

Guess what? It doesn't help at all. I run out of memory, whether or not I call that clear() method between batches of records.

I ran it with a profiler (JMP) and the usage doesn't even dip when that is called.

Any ideas?

_________________
\/\/ /-\ [)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 3:16 pm 
Newbie

Joined: Thu Aug 11, 2005 3:01 pm
Posts: 2
Location: Salt Lake City, Utah, USA
Okay, I guess I should have read that post from Gavin (linked above) before posting. I added a Session.flush() to my existing Session.clear(). We'll try that out now...

_________________
\/\/ /-\ [)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 3:53 pm 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
Also don't forget to consider the option that it might not be Hibernate but your program :)

When working with large chunks of data don't forget to nullify references... I am not sure if calling garbage collect method does anything...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.