Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Eclipse not display warning if try catch is not present

Thread view: 
Mirror - 05 Apr 2007 16:14 GMT
Hello,
can you help me ?

i write this:
sf =    (SessionFactory) super
    .servlet
    .getServletContext()
    .getAttribute(
    HibernatePlugIn.SESSION_FACTORY_KEY);
hsession = sf.openSession();

the method signature is:
public org.hibernate.classic.Session openSession() throws
HibernateException;

Why eclipse not say that a try-catch block is missing ?

Thank's
Giulio
visionset - 05 Apr 2007 16:25 GMT
> the method signature is:
> public org.hibernate.classic.Session openSession() throws
> HibernateException;
>
> Why eclipse not say that a try-catch block is missing ?

Because it is a RuntimeException

--
Mike W
usenetuser@hotmail.co.uk - 05 Apr 2007 16:27 GMT
> Hello,
>  can you help me ?
[quoted text clipped - 15 lines]
> Thank's
> Giulio

HibernateException inherits from RuntimeException... that's why.  You
can still catch it if you want to, but you don't have to.
Jason Cavett - 05 Apr 2007 16:40 GMT
On Apr 5, 11:27 am, usenetu...@hotmail.co.uk wrote:

> > Hello,
> >  can you help me ?
[quoted text clipped - 20 lines]
>
> - Show quoted text -

...and...from what I've learned about RuntimeExceptions, you shouldn't
really catch them anyway.  If you're getting a RuntimeException you
have a deeper problem that needs fixed.
Uwe Plonus - 05 Apr 2007 16:48 GMT
> ...and...from what I've learned about RuntimeExceptions, you shouldn't
> really catch them anyway.  If you're getting a RuntimeException you
> have a deeper problem that needs fixed.

Which is not true for HibernateException. In former versions of
hibernate it was not a RuntimeException. I don't know exactly why they
changed that but in the case of a HibernateException there are many ways
to continue.

Also other RuntimeExceptions are worth catching. Often you have the
possibility to continue.

Another thing are Errors. They are not worth of catching because you
can't do anything useful in case of an Error.

Uwe
Oliver Wong - 05 Apr 2007 17:37 GMT
>> ...and...from what I've learned about RuntimeExceptions, you shouldn't
>> really catch them anyway.  If you're getting a RuntimeException you
[quoted text clipped - 10 lines]
> Another thing are Errors. They are not worth of catching because you
> can't do anything useful in case of an Error.

   Unless, of course, the people at Hibernate decide to change
HibernateException so that it no longer subclasses (Runtime)Exception, but
Error instead. In which case, you should catch that error, as there *is*
something useful you can do with it.

   In other words, forget the dogma. Catch an throwable if it makes sense
to do so, and don't catch it if it doesn't make sense to do so.

   - Oliver
Jason Cavett - 05 Apr 2007 17:50 GMT
> >> ...and...from what I've learned about RuntimeExceptions, you shouldn't
> >> really catch them anyway.  If you're getting a RuntimeException you
[quoted text clipped - 22 lines]
>
> - Show quoted text -

Good advice.  Thanks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.