-->
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.  [ 8 posts ] 
Author Message
 Post subject: Using Session.clear() to recover from HibernateException
PostPosted: Tue Jun 14, 2005 3:33 pm 
Newbie

Joined: Tue Mar 15, 2005 1:07 am
Posts: 5
The Hibernate documentation recommends closing the Session and opening a new one when a HibernateException is thrown.

But Spring 1.2 calls Session.clear() when it rollbacks the transaction.
Is that sufficient to reset the Session to a consistent (ie. empty) state that allows it to be reused in a new transaction?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 4:16 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Then don't use Spring, easy.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 4:20 pm 
Newbie

Joined: Tue Mar 15, 2005 1:07 am
Posts: 5
christian wrote:
Then don't use Spring, easy.


I wasn't asking whether Spring calling Session.clear() causes problems.

What I was asking is whether an application can reliably use a Session in a new transaction after calling Session.clear() and rolling back the original transaction.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 4:23 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No! That's why the Hibernate _reference_ is quite clear on it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 4:26 pm 
Newbie

Joined: Tue Mar 15, 2005 1:07 am
Posts: 5
christian wrote:
No! That's why the Hibernate _reference_ is quite clear on it.


Thanks. It would be helpful if you could describe the kinds of problems that are not solved by causing Session.clear().


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 4:29 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Check the source code.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 6:00 pm 
Newbie

Joined: Tue Mar 15, 2005 1:07 am
Posts: 5
christian wrote:
Check the source code.


Christian,

I know that you are incredibly busy but it would be extremely helpful if you could spend a minute or two describing some of the problems that can occur if an application continues to use a session after an exception is thrown.

Thanks

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 6:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Dude, here's the thing. It may well be that *no* problems will occur (I will have to check the code myself). But that is completely irrelevant. Hibernate defines a lifecycle for the Session. I assume that lifecycle when I change the code of Hibernate. So if you don't want a future version of Hibernate to break your application, you should obey the lifecycle we define.


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