Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Translating an oracle error message into something useful

 
Cory Max
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Cory Max
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic