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.