You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Marek Šabo <ms...@buk.cvut.cz> on 2010/11/19 20:52:06 UTC

getThreadObjectContext

Hi all,

just wanted to ask you how scoped ObjectContext does method 
getThreadObjectContext() return?
I mean javadoc says it's bound to current thread, and there is a new 
thread started during each request so is it "RequestScoped"? Or is it a 
global object that gets bound to the thread when new request arrives 
("SessionScoped")?
Friend of mine told me that he was only using this method for obtaining 
OC and that it remembered fk dependency issues between independent 
request so I'd go for "SessionScoped".

Regards,

-- 
Marek Šabo



Re: getThreadObjectContext

Posted by Marek Šabo <ms...@buk.cvut.cz>.
Hi,

thanks, that was exactly what I wanted to hear.

Regards,

-- 
Marek Šabo


On 11/19/2010 11:09 PM, Michael Gentry wrote:
> Hi Marek,
>
> I assume you are talking about using
> BaseContex.getThreadObjectContext() along with the
> WebApplicationContextFilter described here:
>
> http://cayenne.apache.org/doc30/web-applications.html
>
> The scope of those ObjectContexts are indeed session-based for the web
> application.  Each user gets a unique one, but the same ObjectContext
> is re-attached each request/response cycle for the user, so
> objects/etc in the ObjectContext stay around across requests.
>
> mrg
>
>
> On Fri, Nov 19, 2010 at 2:52 PM, Marek Šabo<ms...@buk.cvut.cz>  wrote:
>> Hi all,
>>
>> just wanted to ask you how scoped ObjectContext does method
>> getThreadObjectContext() return?
>> I mean javadoc says it's bound to current thread, and there is a new thread
>> started during each request so is it "RequestScoped"? Or is it a global
>> object that gets bound to the thread when new request arrives
>> ("SessionScoped")?
>> Friend of mine told me that he was only using this method for obtaining OC
>> and that it remembered fk dependency issues between independent request so
>> I'd go for "SessionScoped".
>>
>> Regards,
>>
>> --
>> Marek Šabo
>>
>>
>>


Re: getThreadObjectContext

Posted by Michael Gentry <mg...@masslight.net>.
Hi Marek,

I assume you are talking about using
BaseContex.getThreadObjectContext() along with the
WebApplicationContextFilter described here:

http://cayenne.apache.org/doc30/web-applications.html

The scope of those ObjectContexts are indeed session-based for the web
application.  Each user gets a unique one, but the same ObjectContext
is re-attached each request/response cycle for the user, so
objects/etc in the ObjectContext stay around across requests.

mrg


On Fri, Nov 19, 2010 at 2:52 PM, Marek Šabo <ms...@buk.cvut.cz> wrote:
> Hi all,
>
> just wanted to ask you how scoped ObjectContext does method
> getThreadObjectContext() return?
> I mean javadoc says it's bound to current thread, and there is a new thread
> started during each request so is it "RequestScoped"? Or is it a global
> object that gets bound to the thread when new request arrives
> ("SessionScoped")?
> Friend of mine told me that he was only using this method for obtaining OC
> and that it remembered fk dependency issues between independent request so
> I'd go for "SessionScoped".
>
> Regards,
>
> --
> Marek Šabo
>
>
>