Mark, thanks lot for your feedback for the questions I asked about using
private static ThreadLocal session;
I guess now I understand it better --- Do you mean that, although this session is a static variable, it is a ThreadLocal, so for example, for a
servlet instance, when multiple servlet
thread call this DAO class, each servlet thread gets a separate Hibernate session from the DAO class. So when one thread closes the session it doesn't affect other threads' sessions. If it is not defined as "ThreadLocal" then it can be a problem -- this static variable can be modified by any client and will affect others. Is this what you meant ?
In the
test I did by myself, I created two classes that extend the DAO class, then I created two objects for these two classes, I found once one cobject closes its session, the other one gets null session value. I guess this is because they are not good example for threads. They are two separate objects. Is that right ?
Thanks.