-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: sharing session between threads - when reading only ?
PostPosted: Tue Mar 02, 2004 11:19 am 
Newbie

Joined: Thu Feb 26, 2004 11:13 am
Posts: 3
Hi,

it is specified that Session is not thread-safe.
But is this true also if I only read the objects from the database ?

My problem:
I have ConfigData object that holds the tree of persistent
Java beans representing the configuration data.
Some of the collections are set to be lazily loaded.
Now, I want to have single instance of the ConfigData
shared by all threads - they will only read the config.
How to do that ?
My environment is bussiness server accessed
by the clients through CORBA.

If the PersistentCollection.getSession() is public,
this would help me to solve the problem.
I would be able to synchronize and disconnect/reconnect
the session in the getter methods of the beans.
E.g.:
Code:
  public class Computer ...
  {
     Set devices;
     ...

  public Set getDevices()
  {
     if(devices instanceof PersistenCollection)
     {
         Session session = ((PersistenCollection)devices).getSession();
         synchronized(session)
         {
             try
             {
                session.reconnect();
                Hibernate.initialize(devices);
              }
              finally { session.disconnect(); }

          }
      }


Thanks in advance,
Stm.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.