I think SessionContext makes senses especially for architecture involving
multiple layers like mine where manager <-> DAO interaction happens.

Thx Michael.

On 4/12/07, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
>
>
> On Apr 11, 2007, at 11:15 PM, Arun Kumar PG wrote:
>
> > Hi Michael,
> >
> > So how can I prevent this as I can't access the lazyload attributes
> > in my manager class once I get the result set from DAO as i get no
> > parent session/contextual session exists exception.
> >
> > should I maintain a reference to the session object in  the DAO
> > class so that it is not garbage collected ?
>
> heres the approaches in descending order of inconvenience:
>
> you can, as a workaround, immediately access all the lazy load
> relations in your getResults() method...i do this with hibernate a lot.
>
> otherwise, one option is to explicitly keep a Session around that
> doesnt get garbage collected, like you mention.
>
> but what a lot of people do is use the SessionContext extension with
> your mappers.  that way when the lazy loader fires off, it looks for
> the Session, but if it cant find it, calls mapper.get_session() which
> then calls the SessionContext....SessionContext then creates a new
> session if one does not exist already for the current thread.  so
> using SessionContext is kind of like replacing the weakly-referenced
> Session with a Session that is bound to a thread.
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to