openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "robert burrell donkin" <>
Subject Re: why not an EntityExistsException was thrown?
Date Wed, 04 Apr 2007 16:56:39 GMT
On 4/4/07, Craig L Russell <> wrote:
> If you look at the exception that is thrown from the database, it's a
> pretty general exception.
> "The statement was aborted because it would have caused a duplicate
> key  value in a unique or primary key constraint or unique index
> identified by  'SQL070403054930170' defined on 'BSC'."
> This might have been caused by a unique constraint, which would not
> be properly reported as EntityExistsException.
> Sadly, there is no standard SQL exception that specifically tells the
> provider (OpenJPA) that there was a primary key constraint violation.
> And you might also note that every database has its own way to report
> exceptions like this.
> What the EntityExistsException does is to report that there is
> already an entity with the same primary key in the persistence
> context. It doesn't report that there was a problem writing the
> entity to the database.


> If you're keen on "fixing" this situation, I'd encourage you to
> volunteer to look at the databases and how they report unique and
> primary key constraint violations and see if it's possible to parse
> the sql code and report string to positively identify a primary key
> constraint violation.

an pluggable exception factory (in open-jpa) might make this approach
a little easier

- robert

View raw message