Translating an oracle error message into something useful
Cory Max
Ranch Hand
Joined: Jul 20, 2005
Posts: 83
posted
0
Hi Everyone,
We've written a very large app using hibernate. Our database has a ton of unique indexes and constraints. Rather than check that the constraint is satisfied prior to updating the database, I'd like to
1) update the database
2) If a constraint violation happens at the db, catch the constraint violation exception
3) use the constraint name that is returned in the exception to look up an english description of the problem
4) Display that message to the user... such as 'There is already a person record with that firstname/lastname/address'
Hopefully I've explained my problem well. Does anyone know if there is a faclity in oracle to attach a description to the constraints you create. If so we'd likely be able to look up that description from the database based on the constraint name? Is there a better way to do this using hibernate?
Thanks again for all your help.
Cory
There are only 10 types of people in this world... Those who understand binary and those who don't.
I don't think you can include any sort of meaningful message with a index that will be returned as part of the SQLException. The view user_constraints will give you all the information Oracle has about a specific constraint. If you need more you could add your own table of meta data and query that.
Sorry for the late reply and thanks for the answer Paul. That is exactly what I have done... should work well. Just wish there was a way to keep the message more coupled with the index itself.
Cheers,
Yeuker
subject: Translating an oracle error message into something useful