-->
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.  [ 4 posts ] 
Author Message
 Post subject: Application locks out during session.flush()
PostPosted: Thu Nov 18, 2004 12:38 pm 
Newbie

Joined: Thu Nov 18, 2004 12:24 pm
Posts: 2
Hibernate version:
2.1
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I have a large java object which I save to database using hibernate. I think I am using the hibernate interface properly.

This java object has 4 collections
when I try to save this campaign it works fine most of the times but, sometimes it locks the application and I find that Session.finalize() has kicked in at the time.

It is a simple case, but it is huge java object with 4 collections

I am not sure how to fix this problem. Hoping to see some responses.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 18, 2004 1:07 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
The problem probably is that the session gets to big.
Iterate over the collections in java and save/update the elements per element to the session. Flush and clear the session in the code. Something like this:

Code:
int counter=0;
Iterator it = myObj.myLargeCollection().iterator();
while(it.hasNext()){
   counter++;
   session.saveOrUpdate(it.next());
    if((counter % 50) == 0){
       // Empty session cache
      session.flush();
      session.clear();
    }
}

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 18, 2004 1:09 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is a very wild guess. I'd say the problem can't be found until the original poster reads the red box.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 18, 2004 5:24 pm 
Newbie

Joined: Thu Nov 18, 2004 12:24 pm
Posts: 2
I am the one who posted the question.

The large object I have is

Object A --> has B, C, D, E
B, C, D, E are collections
Object A itself has around 40 elements.

I like one of the suggestions that was about trying to go for itermediate flushes.

So, in my case what is happenning is, when I do a flush

It has to save the whole 40 elements in Object A
and then do the flush of each of these collections.

So, it is only one object save(), So, I cannot do an intermediate flush I think. So, what do you think the problem / solution in this case?


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