users@glassfish.java.net

Re: Frustrating and Confusing Exceptions

From: Dobes Vandermeer <dobesv_at_gmail.com>
Date: Mon, 2 Feb 2009 09:37:37 -0800 (PST)

You may just have to check beforehand whether the object exists - in
hibernate the database errors that come back, like constraint violations,
tend to get eaten up and are hard to get access to. You could catch
EJBException and then you have to call getCause(), getNextException() in
unpredictable orders ..



glassfish-2 wrote:
>
> Hi,
>
> We have a method that runs within a new transaction that stores an entity
> to the database. We're using this method from a normal stateless session
> bean. Since the data we're storing is coming from an external source we
> accept that sometimes we might try to store an entity that's already in
> the database table. We'd like to be able to catch this exception so that
> we can continue processing other entities. Unfortunately the only way
> we've been able to do this is to catch a very generic exception, for
> example, ejbexception and with this we also get a lot of error messages in
> our log. All I want to be able to do is to find out which exception we
> should be catching and turn this into an applicationexception so that
> hopefully no ugly error log messages will appear. I've tried making
> several persistenceexceptions application exceptions and attempted to
> catch them but it doesn't seem to work.
>
> We're using hibernate as the persistence provider in our ejb application.
> I'm not sure if this has anything to do with hibernate or ejb/jpa in
> general.
>
> Could anyone please give me some advice?
> [Message sent by forum member 'woel' (woel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=328361
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/Frustrating-and-Confusing-Exceptions-tp21683637p21794294.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.