share « Session « JPA Q&A





1. Is it a good idea to share a Session in hibernate ?    coderanch.com

I am reading a book titled "Beginning Hibernate" byDave Minter. They use a "DAO.java" as Base DAO. It has methods like "commit", "close", "rollback", "getSession", etc. Interestingly, it specifies private static final ThreadLocal session = new ThreadLocal(); Then they created some "UserDAO", "ProductDAO" which extends "DAO" class. In each children DAO class, they call "getSession()" method defined in "DAO" class and ...

2. Sharing references across different sessions    forum.hibernate.org

3. Sharing session factory between multiple webapps    forum.hibernate.org

Hello, Maybe someone can help me, because i am quite confuse. I have an hibernate web application, i have used as recommended the local SessionFactory HibernateUtil strategy to get the SessionFactory, this worked perfectly. Now i have to build a second webapp using exactly the same mappings as the first one. I was wondering if i stick to the HibernateUtil strategy ...

4. Sharing the sessionfactory    forum.hibernate.org

Hi whats the best way of sharing the sessionfactory amongst a group of threads? I want to have a class that starts an application which will initialize the sessionfactory, this class will spawn threads that will periodically poll a database, whats the best way for these threads to access the sessionfactory? Thanks, M.

5. how to share session factory among several ears    forum.hibernate.org

Hi, all What about subj? I tried to bind SF by one applicaton and locate it from other ear. But it's unavailing way. Because of SessionFactoryObjectFactory.INSTANCES which used as singleton container for SFs (and implements JNDI bnding, in fact). I can't use this singleton beacuse hibernate.jar is putted into every ear, not into appserver libs. Is such sharing usefull? possible? how ...

6. best practice to share hibernate session on web app    forum.hibernate.org

if you use connection pooling it should be minimal. And you're saving yourself a lot of headaches with connection starvation if your load goes up or clients don't close their sessions properly (most users tend to just close their browser window rather than use your "logout" button to tell the server they're done).

7. Shared SessionFactory    forum.hibernate.org

I have an application that has domain model that spans across multiple web applications. I have an EAR that has a hibernate HAR, does the hibernate HAR file within JBoss provide a shared session factory across the multiple wars. Also, would there be a performance issue if you did not have a shared session factory and reloaded the domain for each ...

8. Sharing Hibernate Session between mutiple thread    forum.hibernate.org

Hi, Can i share hibernate session between multiple thread to save data?like... ArrayList threadList = new ArrayList(); Transaction tx = session.beginTransaction(); // Start Transaction for(Object object : objectList ){ PersistantThread persistantThread = new PersistantThread(session,object); threadList.add(persistantThread); persistantThread.start(); } for(Thread thread : threadList){ thread.join(); } session.flush(); tx.commit(); class PersistantThread extends Thread { Object object = null; Session session = null; public PersistantThread(Session session,Object ...