Possible Duplicate:
In Java, does return trump finally?
I came across a java code snippet in a dao implementation .It returns a List as shown below.
After the 'return' statement is executed,the finally block tries to close the session.Will this work? or will the session remain open?
thanks
mark
import org.hibernate.SessionFactory;
import org.hibernate.Criteria;
...
public List<Item> findItems(String name) {
    SessionFactory factory = HibernateUtil.getSessionFactory();
    Session session = factory.openSession();
    try{
        Criteria cri = session.createCriteria(Item.class);
        return (List<Item>) cri.add(Restrictions.eq("name", name)).list();
    } finally {
        session.close();
    }
}
 
     
     
     
     
    