-->
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: NullPointerException when not-null association is null
PostPosted: Mon Nov 17, 2003 2:25 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
I see there already was a discussion about this topic: http://forum.hibernate.org/viewtopic.ph ... rexception

Just upgraded from 2.0.3 to 2.1beta6 and start getting NPEs.

According to the documentation "If the Session throws an exception (including any SQLException), you should immediately rollback the transaction, call Session.close() and discard the Session instance".

In my code I always catch HibernateException and act appropriately. But obviously, my code is not filled with catch (NullPointerException). Since I'm using variation of Thread Local pattern, this may cause session will not be closed and transaction will not be rolled back.

The question is: should I start catching NPEs or another exception will be used for the same purpose in 2.1 release?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The Hibernate documentation tells you to catch Exception. You need to rollback the session no matter what exception occurs. And besides, LazyInitializationExceptions are not HibernateExceptions.


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.