Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
How to handle HibernateException's correctly? For ex. I wanna show to user message "Object already exists" when he save Object to database, but all I have - HibernateException and I can't determine the reason.
Is that unique key violation or some column's constraint violation. How to determine that?
For example: I have a business method
// alsow throws unchecked SystemException which mean some database failure or external systems failure.
createUserAccount(UserAccount a) throws UserExistsException, ValidationException {
session.save(a) // HibernateException can be thrown in case of Account already exisit in database or Account name length < 1 char. Alsow in all cases HibernateException throws.
}
But I wanna throw specified exception for specifid case. How I should make it?