ThreadLocal « Session « JPA Q&A





2. Memory Leak session with ThreadLocal    forum.hibernate.org

I deployed webservices with tomcat6/axis2 using hibernate. I used a standard HibernateUtil class to provide the SessionFactory. Nevertheless, I had a memory leak due to the ThreadLocal within . Then I rewrote another one to be worked in multithreading environment. Do you think it is a good way to proceed ? package com.cambyze.myLibrary.hibernate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Session; import org.hibernate.SessionFactory; ...

3. Hibernate session from ThreadLocal problem    forum.hibernate.org

Caused by: net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at net.sf.hibernate.collection.PersistentCollection.setCurrentSession(PersistentCollection.java:257) at net.sf.hibernate.impl.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:38) at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69) at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36) at net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93) at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1448) at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1462) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1385) at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114) ...

4. Hibernate Threadlocal session is lost    forum.hibernate.org

Hello, The session is opened via Threadlocal as per http://www.hibernate.org/42.html Then I'm running a transaction: Code: try { Session session = HibernateSession.currentSession(); ...

5. ThreadLocal - when to close session    forum.hibernate.org

A bit of a hibernate newbie here, so bear with me if I'm missing something completely obvious - I'm using the ThreadLocal pattern suggested in the documentation in a Hibernate/Struts app. I'm trying to implement a fast paging strategy for large datasets. This means that I'm unsure about the usefulness of closing the session after each Struts Action finishes executing - ...

6. threadlocal session concept and web application    forum.hibernate.org

Hi, I have some bean with application logic Code: public class MyClass{ ... public void myMethod(){ try{ session=HibUtil.currentSession(); ... }catch (HibernateException ex){ }finally{ ...