Seam / Hibernate - 获取 ORA 消息文本
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()
returns org.hibernate.exception.ConstraintViolationException: Could notexecute JDBC batch
在堆栈跟踪中也存在此错误: java.sql.BatchUpdateException: ORA-00001: 违反了唯一约束 (ACM.SCH_UK)
如何以字符串形式获取此 ORA-00001 消息,而不是 org.hibernate.exception。 ConstraintViolationException 文本?
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);
}
When I have duplicate key error err.getMessage()
returns org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch
In the stacktrace there is this error too:java.sql.BatchUpdateException: ORA-00001: unique constraint (ACM.SCH_UK) violated
How can I get this ORA-00001 message as a string, instead of the org.hibernate.exception.ConstraintViolationException
text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
java.sql.BatchUpdateException
是导致PersistenceException
的根本原因,您可以按如下方式提取它:。
java.sql.BatchUpdateException
is the root cause of yourPersistenceException
, you can extract it as follows:.