Hi,
  I've run into a confusing problem with the above combination. At this
point, I have a good understanding of what is happening but I'm looking for
suggestions on how to best deal with it.

I have a page displaying some data loaded via hibernate. My action bean
speaks to a service layer to load the data. The services are using spring's
@Transactional annotation and I'm using the OpenSessionInViewFilter to keep
the session open after the service method returns to allow for lazy loading
of data during view rendering. I need this data available regardless of
whether validation succeeds or not. To achieve this, I used the
*...@after(LifeCycleStage.BindingAndValidation) *on my action bean's data load
function to always load this data regardless of binding/validation outcomes
and regardless of which event handler will be run.

This was working fine until testing a case where my action bean's event
handler calls a service layer method that throws an exception. The exception
triggers a rollback (handled by the proxy supporting @Transactional) upon
exit of the service method. I've now learned that one of the activities that
takes place during the rollback is that the session opened by the
OpenSessionInViewFilter is cleared (not closed..cleared). This has something
to do with maintaining integrity of the session, as hibernate does not
rollback changes to objects in your session for you so it is a recomended
practice.  My event handler then catches the exception, adds some
information about it to the messages collection and forwards to a view.

 The hibernate session clearing performed by spring during the rollback
blows away hibernate state created when
t...@after(LifeCycleStage.BindingAndValidation)
* code ran. The final result is that that I get a LazyInitException when the
view finally renders even though the session is still open!  If I reload
this data after the rollback, then everything is fine. Great, so my solution
was to change to the data load code to @After(LifeCycleStage.EventHandling).
That works fine but now if there is a validation error, nothing gets loaded.


Is there a way I can set this up to 1) always load data if there is a
validation error and 2) if there is no validation error, only load data
after event handling completes.

Obviously I can do this myself through careful placement of calls to my data
load function, but I'd like a more general approach since I have a few
pages/action beans that work this way. I'm not really implying this is a
stripes issue at all. Just wondering if there is "clever" way to use what is
there to work-around this as cleanly as possible.



-- 
Ross Sargant

TVR Communications LLC
Software Engineer
3275 W Hillsboro Blvd,Suite 300,Deerfield Beach, Florida,33442

http://www.tvrc.com

p: 954-571-2017 x2108

email: [email protected]
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to