axismundi wrote:
jliptak wrote:
So lets start at the top: Why are you trying to lazy load a collection after you has disconnected it?
The reason is because we are sending the objects over RMI to a swing client, and the session-instance of the pojo-proxy is lost. Therefore when we call person.getAdresses() the session-instance of the adresses-collection-proxy is lost. I think this is quite common issue.
What would you suggest to do?
So based on the code, you seem to be creating a hibernate session on the swing client and then you are trying to re-connect the objects there. If that's the case, why don't you just pass the key's of the objects around and load everything on the swing client?
What you are probably trying to do, is to have the RMI stubs provide you the data from the server. If so, your code does not really match what you are trying to do. What you need is a container for your session that matches the length of time your RMI calls are active. So if you have code such as:
Code:
//server
public daoX getData() {
Session session = openSession();
// get data with lazy
session.close();
}
It's not going to work.
You need something more like a CORBA servant. You would have your swing clients create a rmi session object that contains your hibernate session. All calls to get data would go through that session object so that lazy loading would work. You would also need some kind of ping protocol so that the session objects would get cleaned up if the swing client goes away.
As another poster suggested, you could use your mapping files to generate the code necessary to have your object walking functions put into the servant object.[/code]