Hi,
I'm getting an error like:
Code:
net.sf.hibernate.HibernateException: disconnected session
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:335)
at net.sf.hibernate.impl.SessionImpl.prepareCollectionForUpdate(SessionImpl.java:2954)
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2881)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
which is bizarre, because I don't disconnect the session anywhere or destroy it in any way before the call that reports this. How can I track down when/why the session was disconnected? This is a webapp and I have a bunch of objects that carry references to sessions, but if one of these objects instantiates another one, it will just pass it the reference it is already using rather than trying to grab a new one from the context. Is this an erroneous way to design things?
For example,
Code:
class A {
static Session session;
getWhatever() {
S somethingManager = new S(session);
somethingManager.executeSomething();
}
}
class S {
static Session session;
S(Session s) {
session = s;
}
public void executeSomething() {
Query q = ....
...
q.list(); // at this point the session would already be disconnected!
}
}
The hibernate logs are not helpful at all:
Code:
2004-06-18 10:52:22,868 -- DEBUG net.sf.hibernate.SQL -- select tasktypes0_.task_type_id as task_typ2___, tasktypes0_.task_id
as task_id__, tasktype1_.id as id0_, tasktype1_.name as name0_ from task_task_type tasktypes0_ inner join task_type tasktype
1_ on tasktypes0_.task_type_id=tasktype1_.id where tasktypes0_.task_id=? order by tasktypes0_.task_type_id asc
2004-06-18 10:52:22,967 -- ERROR net.sf.hibernate.LazyInitializationException -- Failed to lazily initialize a collection - no session or session was closed