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 <[EMAIL PROTECTED]> 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
