users@glassfish.java.net

Re: Lazy relationships and detached entities in Toplink Essentials

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Tue, 20 Feb 2007 08:41:08 -0500

Hello,
    Lazy retrieval post detachment is not a special feature. The exact
mechanism that provides for lazy retrieval within an active Persistence
Context provides retrieval outside an active Persistence Context as
well. There is no extra configuration step and no additional
resources. When building the entity instances TopLink places a "lazy
load" artifact in place of the entity instances in the relationship.
When the relationship is accessed a query is executed and the related
objects retrieved. If the Persistence Context that the parent was
loaded with is still active then these newly loaded objects are managed
as well if the Persistence Context is no longer active then the newly
loaded objects are detached.
    If you would like to look at source you can look atUnitOfWorkImpl,
UnitOfWorkValueHolder and both public and internal "indirection" packages.
    If you have more questions I would be happy to try and answer then
for you. What level of detail you are looking for?

--Gordon
  

glassfish_at_javadesktop.org wrote:
> I have a question about the Toplink Essentials implementation of LAZY relationships. As I understand it there is a special feature in Toplink Essentials that makes it possible to access LAZY relationships even after the entity manager/persistence context is closed, i.e. when the entity is detached (as long as the entity hasn't been serialized). I have verified that the implementation in fact makes a SQL select even after the em is closed.
>
> I have only found basic information about how this feature works in forums etc so if anybody please could give some more thourough information that would be very helpful. Is there any documentation on exaclty how it works to be found somewhere?
>
> I would also like to know if there is a way to turn it off?
> [Message sent by forum member 'sofiajonsson' (sofiajonsson)]
>
> http://forums.java.net/jive/thread.jspa?messageID=204393
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>