allen petersen <al...@...
<http://gmane.org/get-address.php?address=allen%2dkZT4fACOnrjR7s880joybQ%40public.gmane.org>>
wrote:
>>Now consider the user press the 'cancel' button.
>>
>>- preBind() loads the domain object
>>- stripes binding binds the post back values.
>>- afterBind() kicks in, lookupService got invoked. Now since LookupService
>>is managed by the Transaction Manager, it is surrounded by open and commit
>>transaction.
>
>Wait. You have a method that just fetches some information from the DB,
>but, as a side effect, will also commit your current transaction? That
>sounds like a pretty serious problem to me. And not just for the binding
>direct to domain pattern--what if you have two changes that you need to make
>atomically, and the second relies on getting some of that information from
>the DB? So you do the first set of updates, then do your lookup, and find
>out that the second update won't work. So now you want to roll everything
>back. But, no, you can't, because your select query went and committed the
>first set of updates!
Yes, this is the crux of the problem. It is related to the Session per
request pattern in conjunction with Hibernate Managed Session
facility.
Hibernate 3.x introduced the Hibernate.getCurrentSession() method. The
idea is to facilitate the Session per request pattern, and replace the
ubiquitous HibernateUtil class.
I configured Spring Transacton Manager to use Hibernate Managed
Session, and there are some intricate interactions that I don't fully
understand here.
The first call customerService.findById() should begin and commit a
transaction, and the second call to lookupService is likewise bounded
by a transaction.begin() and transaction.commit().
Stripes binding to the domain model happens between the two
transactions. I would expect that the second transaction would leave
it alone. But it seems that transaction.commit() commits everything in
the session - not just objects touched between transaction.begin() and
transaction.commit().
Any hibernate expert here can shed some lights on this?
Best regards,
Yee
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users