pants wrote:
Sorry, I should've rephrased that, what I meant was I can find lots of postings about this problem but no useful answers.
One posting suggests that the session must be kept open while you traverse the object graph. How would this work if you've just sent the object to a tier with no access to the database.
The session only needs to be open if the object graph has no lazily loaded collections or proxies.
pants wrote:
Another posting suggests that you must fully populate the object graph before closing the session. This seems too inefficient to be practical.
pants wrote:
Another posting suggests that I should copy the hibernate proxied object to another non-hibernate proxied object before I transfer it across tiers. I suspect I'd have to do this manually as I'm guessing a reflective "automagic" copier would trigger Hibernate to lazily load. This seems like a lot of effort.
This is acutally pretty normal in an EJB application using Hibernate. DTOs are created from the PDOs and returned to the EJB clients. It's actually quite nice to have different DTOs for different purposes.
pants wrote:
Basically I just want to load an object and then ask hibernate to let go of it, so I can manipulate it manually. Hibernate doesn't seem to like "sharing" though.
Okay, here are some suggestions:
1) Instead of using 'detach', make deep clone methods for your PDOs and then manipulate the clones.
2) Use the 'constructor' feature in Hibernate3 (this might not work for collections though.