This week's book giveaway is in the OCAJP forum. We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line! See this thread for details.
In my DAO, I try to catch a generic Spring exception i.e DataAccessException for all type of DB problems. Then I wrap the message from it into my custom business exception.
But still, when I try to add a record with an existing primary key the application throws a stack trace of org.hibernate.exception.ConstraintViolationException without proceeding into the catch block of DataAccessException.
I even tried catching the most generic form i.e Exception. Here too, the application fails and throws the same stack trace. How can I catch this exception without failing the application.
I am using hibernate 3 with spring 2. The code which I am referring to is: