You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Márcio Gurgel <ma...@gmail.com> on 2008/06/17 05:40:19 UTC

Struts 2 hibernate session-per-request

Hi Everyone,

Some time ago I asked you about a problem with old objects in session.
I noted that my application is using diferent sessions to recovery a data
from db.
Some times the application shows the corect result, other shows old results
(with old session).

I guess that if I use session-per-request I'll throw my problem away.

Does anyone knows how to implement a session-per-request in Struts 2?

Thanks so much.


Márcio Gurgel

Re: Struts 2 hibernate session-per-request

Posted by Al Sutton <al...@alsutton.com>.
I think he's trying to do whats at 
http://cwiki.apache.org/S2WIKI/struts-2-spring-2-jpa-ajax.html without 
using the great google first :).

Al.

Laurie Harper wrote:
> Márcio Gurgel wrote:
>> Hi Everyone,
>>
>> Some time ago I asked you about a problem with old objects in session.
>> I noted that my application is using diferent sessions to recovery a 
>> data
>> from db.
>> Some times the application shows the corect result, other shows old 
>> results
>> (with old session).
>>
>> I guess that if I use session-per-request I'll throw my problem away.
>>
>> Does anyone knows how to implement a session-per-request in Struts 2?
>
> The term 'session-per-request' doesn't really make a lot of sense, 
> unless you are using 'session' to mean something other than a web 
> application session (perhaps a database 'session'? a Hibernate 
> session? something else?).
>
> IIRC, though, your previous problem *was* about web application 
> sessions, as in unwanted sharing of session-scoped data. Perhaps you 
> could explain what you mean by session-per-request?
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 hibernate session-per-request

Posted by Laurie Harper <la...@holoweb.net>.
Márcio Gurgel wrote:
> Hi Everyone,
> 
> Some time ago I asked you about a problem with old objects in session.
> I noted that my application is using diferent sessions to recovery a data
> from db.
> Some times the application shows the corect result, other shows old results
> (with old session).
> 
> I guess that if I use session-per-request I'll throw my problem away.
> 
> Does anyone knows how to implement a session-per-request in Struts 2?

The term 'session-per-request' doesn't really make a lot of sense, 
unless you are using 'session' to mean something other than a web 
application session (perhaps a database 'session'? a Hibernate session? 
something else?).

IIRC, though, your previous problem *was* about web application 
sessions, as in unwanted sharing of session-scoped data. Perhaps you 
could explain what you mean by session-per-request?

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 hibernate session-per-request

Posted by Márcio Gurgel <ma...@gmail.com>.
I'm gonna try your sugestions and post the result.

Thanks a lot!

Márcio Gurgel

2008/6/17 Antonio Petrelli <an...@gmail.com>:

> 2008/6/17 Márcio Gurgel <ma...@gmail.com>:
> > Does anyone knows how to implement a session-per-request in Struts 2?
>
> If you mean a Hibernate session, you have to implement the "Open
> Session In View" pattern, for example using a filter.
> http://www.hibernate.org/43.html
>
> If you are using Spring, there is an already implemented
> OpenSessionInView filter:
>
> http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Struts 2 hibernate session-per-request

Posted by Antonio Petrelli <an...@gmail.com>.
2008/6/17 Márcio Gurgel <ma...@gmail.com>:
> Does anyone knows how to implement a session-per-request in Struts 2?

If you mean a Hibernate session, you have to implement the "Open
Session In View" pattern, for example using a filter.
http://www.hibernate.org/43.html

If you are using Spring, there is an already implemented
OpenSessionInView filter:
http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org