Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are exception in spring and hibernate most unchecked exception? [duplicate]

Possible Duplicate:
why hibernate changed HibernateException to RuntimeException (unchecked)

What is the reason for keeping exception in spring and hibernate as unchecked exception?

Is only to reduce the cluttering while coding or there is some other design principal behind it?

like image 831
Jyotirup Avatar asked Jul 15 '12 08:07

Jyotirup


2 Answers

While dealing with most of the database exceptions, there is hardly anything developer can do (I mean write something in catch block to recover from exception). Like database connection problem, incorrect query or column don't exist in table etc problems.
So unchecked exceptions rescue developers from adding unnecessary catch blocks. If you want still you can catch desired unchecked exception and leave the rest of them which is not the case with checked exceptions.

like image 60
Ajinkya Avatar answered Nov 14 '22 22:11

Ajinkya


The checked versus unchecked Exception debate is an age old one. Both camps have strong proponents. As a team you should pick a style and stick to it.

Although I can only guess the rationale, apparently spring and hibernate favored the unchecked exception camp.

The debate is (among others) discussed in the question "In Java, when should I create a checked exception, and when should it be a runtime exception?".

like image 21
dvberkel Avatar answered Nov 14 '22 21:11

dvberkel