All the Preparable Interface does (along with the prepare interceptor)
is to use reflection to call the prepare method) at some point in time
(depending on which order you configured it).
It you don't have any code in the prepare method, then, nothing should
occur with your transaction. It seems to me that you are confusing
transient objects with persistent objects during your test. Make sure
that you are not using either as the persistent object WILL record
changes to the database when dirty (by virtue of the OSIV).
Jack_Ryde wrote:
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
--
--
Alberto
http://www.linkedin.com/in/aflores
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]