openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Defoy" <christian.de...@gmail.com>
Subject Re: Detection of constraint violations
Date Tue, 21 Aug 2007 19:58:06 GMT
Patrick,

When I step into the code, I do see ReferentialIntegrityException
being created but they get converted to PersistenceException at some
point in PersistenceExceptions.translateStoreException().  My guess is
that no equivalent exception exists in the JPA spec...

I also only look for SQLState 23000.  I have nothing special to add to
that list...

Thanks!

Christian

On 8/21/07, Patrick Linskey <plinskey@gmail.com> wrote:
> When we can, we try to wrap such exceptions in a
> ReferentialIntegrityException. I think that we just look for SQLState
> of 23000 currently, though.
>
> Can you post stacks that correspond to codes that we should also be catching?
>
> -Patrick
>
> On 8/21/07, Christian Defoy <christian.defoy@gmail.com> wrote:
> > Hello,
> >
> > I am looking for a way of programatically detecting whether an
> > exception was caused by a constraint violation.  What is the best way
> > to do that?
> >
> > The only way I have found so far is to navigate up the cause chain of
> > the exception and see if one happens to be an SQLException and if so,
> > get the SQLState and see if it is 23xxx.
> >
> > Is there a simpler way?
> >
> > Oh, by the way, example 12.2 of the manual states that we can put
> > @Unique annotations in the @Table one but it turns out that type must
> > be @UniqueConstraint.
> >
> > Thanks in advance!
> >
> > Christian
> >
>
>
> --
> Patrick Linskey
> 202 669 5907
>

Mime
View raw message