-->
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.  [ 1 post ] 
Author Message
 Post subject: How to process Exception in DAO?
PostPosted: Thu Mar 10, 2005 11:50 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

I want to know how to process Exception in DAO layer. For example.there are two method to do this:
one method:


Code:
public class PersonDAOImpl implements PersonDAO{
   
       public void updatePerson(Person p){
             ...........................................
             try{
                       session.update(p);
                       tx.commit();
                  }catch(HibernateException ex){
                          tx.rollback();
                          ex.printStackTrace();
                    }finally{
                            session.close();
                      }
                  ....................................


Two method:
Code:
public void updatePerson(Person p){
             ...........................................
             try{
                       session.update(p);
                       tx.commit();
                  }catch(HibernateException ex){
                         throw new MyException("HibernateEx");
                    }


If I use the first one,I can't catch the Exception in Servlet ,So I can't send redirect to the specific error page.
Which is better ? Shoud I process exception in DAO Layer or web layer? Thks!

_________________
You are not alone...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.