-->
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.  [ 2 posts ] 
Author Message
 Post subject: session.clear() and second level cache problem?
PostPosted: Wed May 30, 2007 10:48 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
Hi all,

I'm having problems when clearing the session for batch processing. I'm iterating over a long result set and doing something for each entity in it. If I clear the session every BATCH_SIZE entities, I get "org.hibernate.LazyInitializationException: could not initialize proxy - no Session" after the first batch. If I don't clear the session everything goes fine, except that memory is leaked. I think the problem has to do with second level cache because it started happening after I enabled this cache. Below is my configuration for the cache, and the code that is failing to execute.

Thank you in advance.
Cheers,
Carlos

Cache configuration:
Code:
configuration.setProperty("hibernate.cache.provider_class", 
     "org.hibernate.cache.HashtableCacheProvider");
configuration.setProperty(
     "hibernate.cache.use_query_cache", "true");



Batch processing:
Code:
        while (iterator.hasNext()) {
            Product product = iterator.next();
            index.store(product);
            if (++productCount % BATCH_SIZE == 0) {
                session.clear(); // <-- it works if I comment this line
            }
        }


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 31, 2007 12:11 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
Mh, now I remember that I have upgraded to 3.2.4.SP1. Maybe the problem is related to this and not to the second level cache.

Does anyone else has this problem when iterating results on top of a clear()'ed session?


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