• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Translating an oracle error message into something useful

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic