30 diciembre 2009

A history of exceptions

Exceptions and how they should be handled always
end in heated debates between Java developers. It isn’t surprising that
Hibernate has some noteworthy history as well. Until Hibernate 3.x, all
exceptions thrown by Hibernate were checked exceptions, so every Hiber-
nate API forced the developer to catch and handle exceptions. This strat-
egy was influenced by JDBC, which also throws only checked exceptions.
However, it soon became clear that this doesn’t make sense, because all
exceptions thrown by Hibernate are fatal. In many cases, the best a
developer can do in this situation is to clean up, display an error message,
and exit the application. Therefore, starting with Hibernate 3.x, all
exceptions thrown by Hibernate are subtypes of the unchecked Runtime-
Exception, which is usually handled in a single location in an application.
This also makes any Hibernate template or wrapper API obsolete.

Manning.Java.Persistence.with.Hibernate.Nov.2006.pdf

No hay comentarios: