The OSIV is read only by default, but also works in tandem with
Spring's transaction managers and could change its flush mode.
See 
http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html

2008/9/28 Jack_Ryde <[EMAIL PROTECTED]>:
>
> 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]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to