简体   繁体   English

了解 Hibernate 异常处理

[英]Understanding Hibernate exception handling

I have been reading about the advantages of using Hibernate over JDBC.我一直在阅读有关使用 Hibernate 优于 JDBC 的优势。 One of the articles says其中一篇文章说

Hibernate wraps JDBC exceptions and throw an un-checked exception, so we don’t need to write code to handle it.

I am confused about where says "we don't need a code to handle it".我对哪里说“我们不需要代码来处理它”感到困惑。 Isn't exception handling important to maintain the normal flow?异常处理对于维持正常流程不是很重要吗?

Good exception handling is important.良好的异常处理很重要。 But all it is saying that Hibernate is giving the user an option NOT to catch the exception (a la RuntimeException).但它只是说 Hibernate 正在给用户一个选项来不捕获异常(a la RuntimeException)。 This can be useful for faster coding if you don't want to have to declare throws JDBCException through a long chain of method calls, or if you just want the exception to cause a fast fail (cannot proceed due to...)如果您不想通过一长串方法调用来声明throws JDBCException ,或者您只是希望异常导致快速失败(由于...而无法继续),这对于更快的编码很有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM