Hello,
I'm using Hibernate together with JPA, Spring and JSF 1.2.
In my data access layer I have methods to persist and update objects. These methods throw of course exceptions, but not the hibernate one.
Consider the following simple example:
Code:
public void persistObject(MyObject obj) throws MyPersistenceException {
try {
em.persist(obj);
}
catch(PersistenceException ex) {
throw new MyPersistenceException(ex, "some info stuff");
}
}
The presentation layer is realised by JSF 1.2. There I do the exception handling like this (in the FacesServlet):
Code:
public void service(ServletRequest req, ServletResponse res) {
try {
servlet.service(req, res);
}
catch (MyPersistenceException e) {
// do handling
}
catch (Throwable t) {
// ...
}
}
If an exception occurs (the persistObject method throws MyPersistenceException) it's always mapped into a SQLServerException (I use SQLServer 2005) although it should be a MyPersistenceException.
So it's pretty hard to do correct exception handling.
Does anybody know why MyPersistenceException is ommited somewhere?