What does Criteria.list() return?
A List, obviously, but is it a session dependent list?
I need a detached List of objects, so I have this method:
Code:
public List getAll(Class c) throws HibernateException {
Session session = HibernateUtil.currentSession();
Criteria crit = session.createCriteria(c);
List list = new ArrayList(crit.list());
HibernateUtil.closeSession();
return list;
}
Which results in a:
java.sql.SQLException: Operation not allowed after ResultSet closed
If I don't close the session in that method (by just commenting out that line), I get no exception.
It's taken me a long time to track the error this far, and I'm not positive it's coming from this method. But commenting/uncommenting that line toggles the existence of the exception.
Any suggestions?