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: Basic hibernate questions
PostPosted: Fri Dec 31, 2010 4:50 pm 
Newbie

Joined: Fri Dec 31, 2010 12:00 pm
Posts: 1
Hi,

I am new to hibernate, oracle and even Java, I need answers on following questions

1. Is getHibernateTemplate().saveOrUpdate() call asynchronous?
2. As per HibernateTemplate documentation, one can not handle checked exceptions in DAO layer. What does this mean? Where am I supposed to catch the exceptions thrown by getHibernateTemplate().saveOrUpdate() (Ex. DataIntegrityViolationException)?
3. What are the best practices to handle hibernate exceptions?

Thanks


Top
 Profile  
 
 Post subject: Re: Basic hibernate questions
PostPosted: Sat Jan 01, 2011 9:46 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
hi, welcome.

Quote:
1. Is getHibernateTemplate().saveOrUpdate() call asynchronous?

no, changes immediately affect your model state in the session, but changes on database might be deferred until an invocation of flush(), and autoflush event, or commit of transaction.

Quote:
2. As per HibernateTemplate documentation, one can not handle checked exceptions in DAO layer. What does this mean? Where am I supposed to catch the exceptions thrown by getHibernateTemplate().saveOrUpdate() (Ex. DataIntegrityViolationException)?

sorry but both HibernateTemplate and DataIntegrityViolationException are not part of Hibernate code. I personally don't use them but rely on EntityManager, so can't tell.

Quote:
3. What are the best practices to handle hibernate exceptions?

propagate them up to the layer controlling transactions, at least, so that everything can be rolled back and state cleaned up (close the Session and get a new one).
Webapps usually propagate the error up to an error message to the user.

I'd suggest reading some books on the subject. there are some suggestions on the banners above.

_________________
Sanne
http://in.relation.to/


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.