yes OpenSessionInViewFilter acts on attributes contained in the Session

http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ParametersInterceptor.html
has access to ActionContext.getParameters()
and of course actionContext has access to getSession and setSession via Session 
attribute
http://www.opensymphony.com/xwork/api/com/opensymphony/xwork/ActionContext.html#SESSION

youl'll want to Read this info on OpenSessionInViewFilter:
If you want this
 filter to flush after completed request processing, 
override closeSession
 and 
invoke flush on the Session before closing it. Additionally, you will
 also need to 
override getSession() (to return a Session in a flush mode)

Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business 
of Sender. This transmission is of a confidential nature and Sender does not 
endorse distribution to any party other than intended recipient. Sender does 
not necessarily endorse content contained within this transmission. 


> Date: Sun, 28 Sep 2008 16:44:46 -0700
> From: [EMAIL PROTECTED]
> To: user@struts.apache.org
> Subject: Re: "Preparable" influence hibernate transaction management when 
> using "OpenSessionInViewFilter"
> 
> 
> Thanks for your reply, Gabriel.
> 
> First of all, in both A and B, we use the same action class variable (POJO)
> to represent the entity bean.
> The only difference is the initialize method. A uses a normal class method
> while B uses the prepare method.
> 
> Secondly, how does "OpenSessionInViewFilter" commits the session and perform
> the update? I thought it is read-only? But I agree with your idea and and I
> can see that from the logs "the session is closed with the hibernate
> update".  I just do not know why and how this happens.
> 
> 
> cheers
> Jack
> 
> 
> 
> 
> 
> Gabriel Belingueres-2 wrote:
> > 
> > I suspect that in case A) you are just creating a new POJO in memory
> > (never linked to the Hibernate's Session), that's why the
> > OpenSessionInViewFilter does nothing.
> > 
> > In case B), you are loading into the Session the POJO in the prepare
> > method. When submit the form, it is loaded again before action's
> > execute() method, then the ParametersInterceptor updates the POJO
> > field, and at the end the OpenSessionInViewFilter commits the Session
> > with the POJO's fields modified, so Hibernate performs the update.
> > 
> > 2008/9/24 Jack_Ryde <[EMAIL PROTECTED]>:
> >>
> >> Keyword: struts2 preparable, spring OpenSessionInViewFilter, hibernate
> >> transaction management.
> >>
> >> Background:
> >>
> >> We use OpenSessionInViewFilter in our web xml to enable lazy loading in
> >> web
> >> views.
> >>
> >> The struts action class provides a basic function in adding, updating and
> >> deleting data entity as a controller.
> >>
> >> Our form fields reference the entity object and its properties with a
> >> valid
> >> OGNL expression...
> >>  like <s:textfield name="organisation.phoneNumber"></s:textfield>
> >>
> >> The submitform's action does nothing to D.B.
> >>
> >> Problem:
> >>
> >> Case A:
> >>
> >> The struts action does not implement Preparable interface and we use some
> >> private method to initialize the data used .
> >>
> >> The jsp uses the entity expression directly. <s:textfield
> >> name="organisation.phoneNumber"></s:textfield>
> >>
> >> As a result, whenever you make any change in the jsp for this entity and
> >> submit the form, it does not go to the D.B.
> >>
> >> Which is good because this is exactly what we want as "Open Session in
> >> View", which is read-only.
> >>
> >>
> >>
> >> Case B:
> >>
> >> The struts action does implement Preparable interface and in the
> >> implementation, we retrieve the data from database and populate its
> >> original
> >> value.
> >>
> >> And the jsp uses the entity expression directly. <s:textfield
> >> name="organisation.phoneNumber"></s:textfield>
> >>
> >> As a result, whenever you make any change in the jsp for this entity and
> >> submit the form, it changes the D.B.
> >>
> >> My question is the case B:
> >>
> >> How does  "Preparable" influence hibernate transaction management? Anyone
> >> has any idea?
> >>
> >>
> >> I guess it is related to the struts 2 Interceptor, which does have some
> >> influence to the spring, which then influences the hibernate transaction
> >> control.
> >>
> >> I post the problem in struts forum, not spring or hibernate forum, 
> >> because
> >> if I do not use "Preparable", everything works as expected.
> >>
> >>
> >> cheers
> >> Jack
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/%22Preparable%22-influence-hibernate-transaction-management-when-using-%22OpenSessionInViewFilter%22-tp19660675p19660675.html
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/%22Preparable%22-influence-hibernate-transaction-management-when-using-%22OpenSessionInViewFilter%22-tp19660675p19716707.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

_________________________________________________________________
See how Windows Mobile brings your life together—at home, work, or on the go.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/

Reply via email to