ERXValidationException out of a Unique Constraint Violation
ERXValidationException out of a Unique Constraint Violation
- Subject: ERXValidationException out of a Unique Constraint Violation
- From: Paul Stringer <email@hidden>
- Date: Tue, 27 May 2008 11:45:09 +0200
Hi,
I'm following the PracticalWebObjects advice to handle unique values
validation at the database and then handle it in thrown
EOGeneralAdaptorExceptions. Wish I'd checked this before I wasted time
pre-checking for all this in validateKey() which was my first
approach, follow the advice don't do it! :)
First thing I found when implementing this was you don't get a nice
EOAdaptorFailureKey on a unique constraint so I'm having to check the
error for a 'Integrity constraint violation' string but so far so
good. What I wanted then was a nice ERXValidationException with the
Value and KeyPath to be able to display something meaningful to the
user.
After looking at it, my solution was to check the SQLException out of
the Failed EOAdaptorOperation (copying bits from
ERXAdaptorUtilities.isOptimisticLockingFailure()) and regex the
SQLException .getMessage() for the values. Seemed kinda hacky but
maybe because I'm comparing to clean regular EOValidation.
Any better ways to approach this or am I basically on the right track.
The only thing I see as a potential problem is that the errors that
come back maybe database specific and so therefore the code is not db
independant. I'm using FrontBase right now if it makes any difference.
See you in San Francisco!
Paul Stringer
Treasuremytext.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden