try {
if (schId != null) {
log.info(">>> save");
schedule = em.merge(schedule);
em.persist(schedule);
} else {
em.persist(schedule);
}
em.flush();
ret = "ok";
} catch (Exception err) {
ret = err.getMessage();
err.printStackTrace();
facesMessages.addFromResourceBundle(Severity.ERROR, "databaseError", ret);
}
当我有重复的键错误err.getMessage()
返回org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch
在堆栈跟踪中也有这个错误:
java.sql.BatchUpdateException: ORA-00001: unique constraint (ACM.SCH_UK) violated
我怎样才能得到这个 ORA-00001 消息作为一个字符串,而不是org.hibernate.exception.ConstraintViolationException
文本?