gavin wrote:
Quote:
Currently there is _NO_ way to efficiently pass complex graphs of objects to another level (maybe over the network).
Why is there "no way"? I actually don't understand this. Every serious Hibernate app I have ever written is multi-tiered and I simply havn't found this to be a problem.
I assume you mean that you initialize all of your proxies before handing them off? Is your graph of objects fairly flat or do you have some tricky code for traversing an arbitrary graph of objects?
Even if initializing the entire graph ahead of time is possible, I'm not sure it's always desirable--you obviously lose some of the benefits of lazy loading, especially if the next tier is not going to touch most of the objects.
gavin wrote:
Quote:
any changes to this object won't be persisted to the database and transactional isolation won't suffer a bit.
Just because it is a read only situation does NOT mean that it is correct to fetch data nontransactionally! Transaction isolation requires that data be READ transactionally, as well as written transactionally.
I can buy that, but why does it have to be the
same transaction? For example, I would like to commit all changes in my business layer, and then start a new transaction for the View layer to read in the proxies. Yes, the loaded objects may be "out of date" with respect the objects already loaded by the business layer, but depending on the isolation level this could happen within a single transaction too (I think it resembles "read committed").
What I would like to see is:
Code:
Hibernate.setFallbackSession(session);
Internally this would use a ThreadLocal. The specified session will be used when loading a proxy and the original session has been closed. Users would be required to call this method explicitly, so there is no "auto-reconnect" here, just a notion of the "current" session.