Hi All,
The following question might sound dumb but I'll ask it anyway. how can I catch
org.hibernate.exception.ConstraintViolationException
exceptions if I'm using JPA?
In facade bean I have an Insert method that persists the object, something like:
public void insertObject(Object entity) {
try {
em.persist(entity);
} catch (javax.persistence.EntityExistsException e) {
System.err.println(e.getMessage());
} catch (java.lang.IllegalStateException e) {
System.err.println(e.getMessage());
} catch (java.lang.IllegalArgumentException e) {
System.err.println(e.getMessage());
} catch (javax.persistence.TransactionRequiredException e) {
System.err.println(e.getMessage());
}
}
if I add a catch block like:
catch (org.hibernate.exception.ConstraintViolationException e){
// do something
}
the exception isn't catch, so how can I do to catch this exception?
Thanks
|