Hello All,
I've just been working with hibernate for a short while and haven't quite figured out the best way to work with try, catch, finally statements.
Here is an idea I've been kicking around for a little while now...
Code:
try
{
Session session = SessionFactory.getSessionFactory().openSession();
try
{
//do database stuff here like loads, saves, updates...
session.load(object, new Integer(1));
}
finally
{
session.close();
}
}
catch(Exception e)
{
//Now handle any exceptions here...
}
Does anyone see any thing wrong with this approach? Does anyone do it differently?
Thanks for your time,
Nate