struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriel Belingueres" <belingue...@gmail.com>
Subject Re: "Preparable" influence hibernate transaction management when using "OpenSessionInViewFilter"
Date Thu, 25 Sep 2008 14:02:30 GMT
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 <huichuan.liu@newsdigitalmedia.com.au>:
>
> 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: 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


Mime
View raw message